You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
D7QUANTAI/DSWeb/CRM/CRMInfoFaqInfo.aspx.cs

540 lines
26 KiB
C#

10 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Text;
using DSWeb.DataAccess;
using System.Data.SqlClient;
using DSWeb.Models;
using DSWeb.EntityDA;
using System.Web.Script.Serialization;
using System.Xml;
using System.Text.RegularExpressions;
namespace DSWeb.CRM
{
public partial class CRMInfoFaqInfo : System.Web.UI.Page
{
public string sSQL = String.Empty;
public string gvid = String.Empty;
RangeDA RangeDA = new RangeDA();
public string strUserID;//用户GID
public string strCompanyID;//公司GID
public string strShowName;//用户显示名
public string strDeptName;//部门名称
protected void Page_Load(object sender, EventArgs e)
{
if (Session["USERID"] != null)
{
strUserID = Session["USERID"].ToString().Trim();
}
else
{
Server.Transfer("~/Error/FriendError.aspx");
return;
}
if (Session["SHOWNAME"] != null)
{
strShowName = Session["SHOWNAME"].ToString();
}
if (Session["COMPANYID"] != null)
{
strCompanyID = Session["COMPANYID"].ToString();
}
if (Session["DEPTNAME"] != null)
{
strDeptName = Session["DEPTNAME"].ToString();
}
//
if (!IsPostBack)
{
if (Request.QueryString["handle"] != null)
{
ViewState["strHandleType"] = Request.QueryString["handle"].ToString();
if (Request.QueryString["id"] != null)
{
ViewState["GID"] = Request.QueryString["id"].ToString();
this.hdGID.Value = ViewState["GID"].ToString().Trim();
}
//
if (Request.QueryString["LINKID"] != null && Request.QueryString["LINKID"].ToString().Trim() != "")
{
UnicodeEncoding unicode = new UnicodeEncoding();
this.hdLINKID.Value = unicode.GetString(unicode.GetBytes(Regex.Unescape(Request.QueryString["LINKID"].ToString().Trim())));
T_ALL_DA T_ALL_DA = new T_ALL_DA();
this.hd_comboSHORTNAME.Value = T_ALL_DA.GetStrSQL("SHORTNAME", "select SHORTNAME from crm_info_client where gid='" + this.hdLINKID.Value.Trim() + "'");
this.hdISLINKID.Value = this.hdLINKID.Value.Trim() == "" ? "" : "1";
}
else
{
this.hd_comboSHORTNAME.Value = "";
this.hdISLINKID.Value = "";
}
//
getddlDataSet();
//
switch (ViewState["strHandleType"].ToString().Trim())
{
case "add"://新增
//ddlPROBLEMTYPE.Text = "";
tbPROBLEMCONTENT.Text = "";
tbETD.Text = "";
tbCNTRTOTAL.Text = "";
tbKGS.Text = "";
tbPRICE.Text = "";
cbISTHROUGH.Checked=false;
tbGOODSNAME.Text = "";
this.hd_comboPORTLOAD.Value = "";
this.hd_comboPORTDISCHARGE.Value = "";
this.hd_comboFAQREPLYMAN.Value = "";
//
T_ALL_DA T_ALL_DA = new T_ALL_DA();
this.hd_comboPORTLOAD.Value = T_ALL_DA.GetStrSQL("PORTLOAD", "select PORTLOAD from subcomp_seae_def where CORPID='" + strCompanyID + "'");
//
ibEnter.Disabled = false;
tbEnter.Disabled = false;
break;
case "edit"://录入
CRMInfoFAQDA CRMInfoFAQDA = new CRMInfoFAQDA();
CRMInfoFAQEntity model = new CRMInfoFAQEntity();
model = CRMInfoFAQDA.GetModel(ViewState["GID"].ToString().Trim());
if (model != null)
{
this.hd_CREATEUSER.Value = model.CREATEUSER.ToString().Trim();
ddlPROBLEMTYPE.Text = model.PROBLEMTYPE.ToString().Trim();
//tbPROBLEMCONTENT.Text = "";
tbETD.Text = model.ETD.ToString().Trim().IndexOf("0001")>-1?"":model.ETD.ToString("yyyy-MM-dd").Trim();
tbCNTRTOTAL.Text = model.CNTRTOTAL.ToString().Trim();
tbKGS.Text = model.KGS.ToString("F2").Trim();
tbPRICE.Text = model.PRICE.ToString("F2").Trim();
cbISTHROUGH.Checked = model.ISTHROUGH;
this.hd_comboSHORTNAME.Value = model.SHORTNAME.ToString().Trim();
tbGOODSNAME.Text = model.GOODSNAME.ToString().Trim();
this.hd_comboPORTLOAD.Value = model.PORTLOAD.ToString().Trim();
this.hd_comboPORTDISCHARGE.Value = model.PORTDISCHARGE.ToString().Trim();
this.hd_comboFAQREPLYMAN.Value = model.FAQREPLYMAN.ToString().Trim();
//
if (model.ISTYPE.ToString().Trim() == "True")
{
getEnabled();
}
else
{
getEnabledEdit();
}
}
else
{
getEnabledEdit();
}
//
getDLInfoShipper();
//
if (this.hdLINKID.Value.Trim() != "")
{
//权限可视范围
string strV = RangeDA.GetVISIBLERANGE(strUserID.Trim(), "modCRMInfoFaqList");
string strO = RangeDA.GetOPERATERANGE(strUserID.Trim(), "modCRMInfoFaqList");
string alt = "";
if (strV.Trim().Equals("4"))//全部
{
//ibEnter.Enabled = true;
//tbEnter.Enabled = true;
//ibFresh.Enabled = true;
//imgAdd.Disabled = false;
//btCopy.Disabled = false;
}
else if (strV.Trim().Equals("1"))//分公司
{
if (strO.Trim().Equals("1"))//公司
{
alt = RangeDA.GetCRMInfoFaqListCompany(strUserID.Trim(), ViewState["GID"].ToString().Trim());
if (alt == "")
{
getEnabled();
}
}
else if (strO.Trim().Equals("3"))//个人
{
alt = RangeDA.GetCRMInfoFaqListPerson(strUserID.Trim(), ViewState["GID"].ToString().Trim());
if (alt == "")
{
getEnabled();
}
}
}
else if (strV.Trim().Equals("3"))
{
if (strO.Trim().Equals("3"))//个人
{
alt = RangeDA.GetCRMInfoFaqListPerson(strUserID.Trim(), ViewState["GID"].ToString().Trim());
if (alt == "")
{
getEnabled();
}
}
else if (strO.Trim().Equals("4"))//无
{
getEnabled();
}
}
}
//
break;
}
}
else
{
}
//加载下拉框
Page.ClientScript.RegisterStartupScript(this.GetType(), "key", "<script>getonload2();</script>");
//
}
}
protected String getBSNO()
{
string strBSNO = Guid.NewGuid().ToString();
strBSNO = strBSNO.Replace("-", "");
strBSNO = "CFAQ" + strBSNO;
return strBSNO;
}
protected void getddlDataSet()
{
T_ALL_DA T_ALL_DA = new T_ALL_DA();
ddlPROBLEMTYPE.Items.Clear();
DataSet ds = T_ALL_DA.GetAllSQL("select KEYVALUE from crm_key_code where KEYTYPE='询价报价问题类型' and KEYVALUE<>'' and KEYVALUE is not null");
if (ds != null)
{
ddlPROBLEMTYPE.DataSource = ds.Tables[0];
ddlPROBLEMTYPE.DataTextField = "KEYVALUE";
ddlPROBLEMTYPE.DataValueField = "KEYVALUE";
ddlPROBLEMTYPE.DataBind();
}
//ddlPROBLEMTYPE.Items.Add("");
}
protected void getEnabled()
{
ibEnter.Disabled = true;
tbEnter.Disabled = true;
ibFresh.Enabled = false;
imgAdd.Disabled = true;
//btCopy.Disabled = true;
//
this.hdEnabled.Value = "false";
tbPROBLEMCONTENT.Enabled = false;
tbETD.Enabled = false;
tbCNTRTOTAL.Enabled = false;
tbKGS.Enabled = false;
tbPRICE.Enabled = false;
cbISTHROUGH.Enabled = false;
//
dlInfoShipper.Enabled = false;
//Panel1.Enabled = false;
Panel2.Enabled = false;
Panel3.Enabled = false;
}
protected void getEnabledEdit()
{
ibEnter.Disabled = false;
tbEnter.Disabled = false;
ibFresh.Enabled = true;
//imgAdd.Disabled = true;
//btCopy.Disabled = true;
//
this.hdEnabled.Value = "false";
ddlPROBLEMTYPE.Enabled = false;
tbPROBLEMCONTENT.Enabled = true;
tbETD.Enabled = false;
tbCNTRTOTAL.Enabled = false;
tbKGS.Enabled = false;
tbPRICE.Enabled = false;
cbISTHROUGH.Enabled = false;
//
dlInfoShipper.Enabled = false;
Panel1.Enabled = false;
Panel2.Enabled = false;
Panel3.Enabled = true;
}
protected void getDLInfoShipper()
{
if (ViewState["GID"] != null && ViewState["GID"].ToString().Trim() != "")
{
T_ALL_DA T_ALL_DA = new T_ALL_DA();
DataSet ds = T_ALL_DA.GetAllSQL("select GID,PROBLEMGID,PROBLEMTYPE,PROBLEMTITLE,PROBLEMCONTENT,(case ISPROBLEM when 0 then '回复' else '问题' end) as ISPROBLEM,ISTYPE,(select SHOWNAME from [user] where gid=crm_info_faq.CREATEUSER) as CREATEUSER,CREATETIME from crm_info_faq where gid = '" + ViewState["GID"].ToString().Trim() + "' or PROBLEMGID = '" + ViewState["GID"].ToString().Trim() + "' order by CREATETIME");
dlInfoShipper.DataSource = ds;
dlInfoShipper.DataBind();
}
}
protected bool getAdd()
{
CRMInfoFAQDA CRMInfoFAQDA = new CRMInfoFAQDA();
CRMInfoFAQEntity model = new CRMInfoFAQEntity();
T_ALL_DA T_ALL_DA = new T_ALL_DA();
ViewState["GID"] = getBSNO();
model.GID = ViewState["GID"].ToString().Trim();
model.PROBLEMGID = "#";
model.PROBLEMTYPE = ddlPROBLEMTYPE.Text;
model.PROBLEMCONTENT = tbPROBLEMCONTENT.Text;
model.ISPROBLEM = true;
model.ISTYPE = false;
model.CREATEUSER = strUserID;
//
model.ETD = tbETD.Text.Trim() == "" ? DateTime.Parse("0001-01-01 00:00:00") : DateTime.Parse(tbETD.Text.Trim());
model.CNTRTOTAL = tbCNTRTOTAL.Text.Trim();
model.KGS = tbKGS.Text.Trim() == "" ? 0 : Decimal.Parse(Decimal.Parse(tbKGS.Text.Trim()).ToString("F2"));
model.PRICE = tbPRICE.Text.Trim() == "" ? 0 : Decimal.Parse(Decimal.Parse(tbPRICE.Text.Trim()).ToString("F2"));
model.ISTHROUGH = cbISTHROUGH.Checked;
model.SHORTNAME = this.hd_comboSHORTNAME.Value.Trim();
model.CLIENTGID = T_ALL_DA.GetStrSQL("gid", "select gid from crm_info_client where SHORTNAME='" + this.hd_comboSHORTNAME.Value.Trim() + "'");
model.GOODSNAME = tbGOODSNAME.Text.Trim();
model.PORTLOAD = this.hd_comboPORTLOAD.Value.Trim();
model.PORTDISCHARGE = this.hd_comboPORTDISCHARGE.Value.Trim();
model.FAQREPLYMAN = this.hd_comboFAQREPLYMAN.Value.Trim();
//
string stitle = "";
//stitle += this.hd_comboSHORTNAME.Value.Trim() == "" ? "" : "询价客户:" + this.hd_comboSHORTNAME.Value.Trim() + ""; ;
//stitle += "问题类型:" + ddlPROBLEMTYPE.Text + "";
stitle += this.hd_comboPORTLOAD.Value.Trim() == "" ? "" : "起运港:" + this.hd_comboPORTLOAD.Value.Trim() + "";
stitle += this.hd_comboPORTDISCHARGE.Value.Trim() == "" ? "" : "目的港:" + this.hd_comboPORTDISCHARGE.Value.Trim() + "";
stitle += tbETD.Text.Trim() == "" ? "" : "船期:" + tbETD.Text.Trim() + "";
stitle += tbCNTRTOTAL.Text.Trim() == "" ? "" : "箱型箱量:" + tbCNTRTOTAL.Text.Trim() + "";
stitle += tbGOODSNAME.Text.Trim() == "" ? "" : "品名:" + tbGOODSNAME.Text.Trim() + "";
stitle += tbKGS.Text.Trim() == "" ? "" : "重量:" + Decimal.Parse(tbKGS.Text.Trim()).ToString("F2") + "";
//stitle += tbPRICE.Text.Trim() == "" ? "" : "期望价格:" + Decimal.Parse(tbPRICE.Text.Trim()).ToString("F2") + "";
if (cbISTHROUGH.Checked)
{
stitle += "是否直达:是;";
}
else
{
stitle += "是否直达:否;";
}
model.PROBLEMTITLE = stitle;
//
int iResult = CRMInfoFAQDA.Add(model);
if (iResult > 0)
{
//消息提醒
//64784D94-420F-46D2-BDC1-471437278965 审核
IList<MessageEntity> messageEntities = new List<MessageEntity>();
MessageDA messageDA = new MessageDA();
//查看是否此用户相关的行为信息
//DataSet ds = T_ALL_DA.GetAllSQL("select AUDITOR from workflow_step where WORKFLOWID='703a1a9c-6fe5-4f49-a446-66c1cc07457f'");
//if (ds != null)
//{
//foreach (DataRow myRow in ds.Tables[0].Rows)
//{
MessageEntity messageEntity = new MessageEntity();
messageEntity.GID = Guid.NewGuid().ToString();
messageEntity.Name = "CRMInfoFaqInfo";//英文名称自定义
messageEntity.Description = "询价报价申请";
messageEntity.IsRead = false;
messageEntity.ReadCount = 0;
messageEntity.MessageContent = strShowName + " 提交了“" + ddlPROBLEMTYPE.Text.Trim() + "”申请:询价客户“" + this.hd_comboSHORTNAME.Value.Trim() + "”";//消息内容
messageEntity.TaskID = ViewState["GID"].ToString().Trim();//bsno
//messageEntity.Receiver = myRow["AUDITOR"].ToString().Trim();//收件人id
string strreceiver = T_ALL_DA.GetStrSQL("GID", "select GID from [user] where SHOWNAME = '" + this.hd_comboFAQREPLYMAN.Value.Trim() + "'");
messageEntity.Receiver = strreceiver.Trim();//收件人id
messageEntity.TaskUrl = messageEntity.TaskUrl = "CRM/CRMInfoFaqList.aspx";//审核页面的地址
messageEntity.Type = messageDA.GetMessageType(MessageType.CRMInfoFaqInfo);
messageEntities.Add(messageEntity);
// }
//}
if (messageEntities.Count > 0)
{
messageDA.CreateMessage(MessageType.CRMInfoFaqInfo, messageEntities);
}
//
ViewState["strHandleType"] = "edit";
return true;
}
else
{
return false;
}
}
protected bool getEdit()
{
CRMInfoFAQDA CRMInfoFAQDA = new CRMInfoFAQDA();
CRMInfoFAQEntity model = new CRMInfoFAQEntity();
T_ALL_DA T_ALL_DA = new T_ALL_DA();
model.GID = getBSNO();
model.PROBLEMGID = ViewState["GID"].ToString().Trim();
model.PROBLEMTYPE = ddlPROBLEMTYPE.Text;
model.PROBLEMCONTENT = tbPROBLEMCONTENT.Text;
bool bl = false;
if (this.hd_CREATEUSER.Value.Trim() == strUserID.Trim())
{
bl = true;
}
else
{
bl = false;
}
model.ISPROBLEM = bl;
model.ISTYPE = false;
model.CREATEUSER = strUserID;
//
model.ETD = tbETD.Text.Trim() == "" ? DateTime.Parse("0001-01-01 00:00:00") : DateTime.Parse(tbETD.Text.Trim());
model.CNTRTOTAL = tbCNTRTOTAL.Text.Trim();
model.KGS = tbKGS.Text.Trim() == "" ? 0 : Decimal.Parse(Decimal.Parse(tbKGS.Text.Trim()).ToString("F2"));
model.PRICE = tbPRICE.Text.Trim() == "" ? 0 : Decimal.Parse(Decimal.Parse(tbPRICE.Text.Trim()).ToString("F2"));
model.ISTHROUGH = cbISTHROUGH.Checked;
model.SHORTNAME = this.hd_comboSHORTNAME.Value.Trim();
model.CLIENTGID = T_ALL_DA.GetStrSQL("gid", "select gid from crm_info_client where SHORTNAME='" + this.hd_comboSHORTNAME.Value.Trim() + "'");
model.GOODSNAME = tbGOODSNAME.Text.Trim();
model.PORTLOAD = this.hd_comboPORTLOAD.Value.Trim();
model.PORTDISCHARGE = this.hd_comboPORTDISCHARGE.Value.Trim();
model.FAQREPLYMAN = this.hd_comboFAQREPLYMAN.Value.Trim();
//
string stitle = "";
//stitle += this.hd_comboSHORTNAME.Value.Trim() == "" ? "" : "询价客户:" + this.hd_comboSHORTNAME.Value.Trim() + ""; ;
//stitle += "问题类型:" + ddlPROBLEMTYPE.Text + "";
stitle += this.hd_comboPORTLOAD.Value.Trim() == "" ? "" : "起运港:" + this.hd_comboPORTLOAD.Value.Trim() + "";
stitle += this.hd_comboPORTDISCHARGE.Value.Trim() == "" ? "" : "目的港:" + this.hd_comboPORTDISCHARGE.Value.Trim() + "";
stitle += tbETD.Text.Trim() == "" ? "" : "船期:" + tbETD.Text.Trim() + "";
stitle += tbCNTRTOTAL.Text.Trim() == "" ? "" : "箱型箱量:" + tbCNTRTOTAL.Text.Trim() + "";
stitle += tbGOODSNAME.Text.Trim() == "" ? "" : "品名:" + tbGOODSNAME.Text.Trim() + "";
stitle += tbKGS.Text.Trim() == "" ? "" : "重量:" + Decimal.Parse(tbKGS.Text.Trim()).ToString("F2") + "";
//stitle += tbPRICE.Text.Trim() == "" ? "" : "期望价格:" + Decimal.Parse(tbPRICE.Text.Trim()).ToString("F2") + "";
if (cbISTHROUGH.Checked)
{
stitle += "是否直达:是;";
}
else
{
stitle += "是否直达:否;";
}
model.PROBLEMTITLE = stitle;
//
int iResult = CRMInfoFAQDA.Add(model);
if (iResult > 0)
{
if (bl)
{
//消息提醒
//64784D94-420F-46D2-BDC1-471437278965 审核
IList<MessageEntity> messageEntities = new List<MessageEntity>();
MessageDA messageDA = new MessageDA();
//查看是否此用户相关的行为信息
//DataSet ds = T_ALL_DA.GetAllSQL("select AUDITOR from workflow_step where WORKFLOWID='703a1a9c-6fe5-4f49-a446-66c1cc07457f'");
//if (ds != null)
//{
// foreach (DataRow myRow in ds.Tables[0].Rows)
// {
MessageEntity messageEntity = new MessageEntity();
messageEntity.GID = Guid.NewGuid().ToString();
messageEntity.Name = "CRMInfoFaqInfo";//英文名称自定义
messageEntity.Description = "询价报价申请";
messageEntity.IsRead = false;
messageEntity.ReadCount = 0;
messageEntity.MessageContent = strShowName + " 提交了“" + ddlPROBLEMTYPE.Text.Trim() + "”申请:询价客户“" + this.hd_comboSHORTNAME.Value.Trim() + "”";//消息内容
messageEntity.TaskID = ViewState["GID"].ToString().Trim();//bsno
//messageEntity.Receiver = myRow["AUDITOR"].ToString().Trim();//收件人id
string strreceiver = T_ALL_DA.GetStrSQL("GID", "select GID from [user] where SHOWNAME = '" + this.hd_comboFAQREPLYMAN.Value.Trim() + "'");
messageEntity.Receiver = strreceiver.Trim();//收件人id
messageEntity.TaskUrl = messageEntity.TaskUrl = "CRM/CRMInfoFaqList.aspx";//审核页面的地址
messageEntity.Type = messageDA.GetMessageType(MessageType.CRMInfoFaqInfo);
messageEntities.Add(messageEntity);
// }
//}
if (messageEntities.Count > 0)
{
messageDA.CreateMessage(MessageType.CRMInfoFaqInfo, messageEntities);
}
}
else
{
//消息提醒
//64784D94-420F-46D2-BDC1-471437278965 审核
IList<MessageEntity> messageEntities = new List<MessageEntity>();
MessageDA messageDA = new MessageDA();
//查看是否此用户相关的行为信息
MessageEntity messageEntity = new MessageEntity();
messageEntity.GID = Guid.NewGuid().ToString();
messageEntity.Name = "CRMInfoFaqInfo";//英文名称自定义
messageEntity.Description = "询价报价回复";
messageEntity.IsRead = false;
messageEntity.ReadCount = 0;
messageEntity.MessageContent = strShowName + " 回复了“" + ddlPROBLEMTYPE.Text.Trim() + "”申请:询价客户“" + this.hd_comboSHORTNAME.Value.Trim() + "”";//消息内容
messageEntity.TaskID = ViewState["GID"].ToString().Trim();//bsno
messageEntity.Receiver = this.hd_CREATEUSER.Value.Trim();//收件人id
messageEntity.TaskUrl = messageEntity.TaskUrl = "CRM/CRMInfoFaqList.aspx";//审核页面的地址
messageEntity.Type = messageDA.GetMessageType(MessageType.CRMInfoFaqInfo);
messageEntities.Add(messageEntity);
if (messageEntities.Count > 0)
{
messageDA.CreateMessage(MessageType.CRMInfoFaqInfo, messageEntities);
}
}
//
ViewState["strHandleType"] = "edit";
return true;
}
else
{
return false;
}
}
protected void btnEnter_Click(object sender, EventArgs e)
{
bool bl = false;
if (ViewState["strHandleType"].ToString().Trim().Equals("add"))//新增
{
bl = getAdd();
}
else if (ViewState["strHandleType"].ToString().Trim().Equals("edit"))//录入
{
bl = getEdit();
}
//
if (bl)
{
this.hd_CREATEUSER.Value = strUserID.Trim();
tbPROBLEMCONTENT.Text = "";
//
getEnabledEdit();
getDLInfoShipper();
Page.ClientScript.RegisterStartupScript(this.GetType(), "key0", "<script>getonload2();window.opener.location.reload();</script>");
return;
}
else
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>getonload2();alert('出错,请重新填写!');</script>");
return;
}
}
protected void ibFresh_Click(object sender, ImageClickEventArgs e)
{
getDLInfoShipper();
}
public bool IsNumeric(string s)
{
bool bReturn = true;
try
{
int inum = int.Parse(s);
}
catch
{
bReturn = false;
}
return bReturn;
}
//
}
}