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 JsonHelper; using DSWeb.Log; using System.Xml.Linq; using System.Xml; using System.IO; using System.Text.RegularExpressions; using DSWeb.Authority; using System.Data.OleDb; namespace DSWeb.PriceCarrier { public partial class CrmProxyMailInfo : System.Web.UI.Page { CrmProxyMailEntity CrmProxyMailEntity = new CrmProxyMailEntity(); CrmProxyMailDA CrmProxyMailDA = new CrmProxyMailDA(); public string strHandleType = String.Empty; 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(); this.hdUserID.Value = strUserID.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) { Session["strHandleType"] = Request.QueryString["handle"].ToString();//"edit"; strHandleType = Session["strHandleType"].ToString().Trim(); this.hdHandle.Value = Session["strHandleType"].ToString().Trim(); // if (Request.QueryString["id"] != null) { Session["GID"] = Request.QueryString["id"].ToString(); this.hdGid.Value = Session["GID"].ToString().Trim(); } // switch (strHandleType) { case "add"://新增 getaddnull(); // ibDel.Enabled = false; ibAdd.Enabled = false; ibFullAdd.Enabled = false; btISISSUE.Enabled = false; break; case "addfull"://新增 btISISSUE.Text = "取消发布"; // CrmProxyMailEntity = CrmProxyMailDA.GetID(Session["GID"].ToString().Trim()); if (CrmProxyMailEntity.GID != null) { tbTITLE.Text = CrmProxyMailEntity.TITLE == null ? "" : CrmProxyMailEntity.TITLE.ToString().Trim(); tbCONTENTS.Text = CrmProxyMailEntity.CONTENTS == null ? "" : CrmProxyMailEntity.CONTENTS.ToString().Trim(); // Session["GID"] = getBSNO("Sail"); this.hdGid.Value = Session["GID"].ToString().Trim(); // ibDel.Enabled = false; ibAdd.Enabled = false; ibFullAdd.Enabled = false; btISISSUE.Enabled = false; } else { Session["strHandleType"] = "add"; strHandleType = "add"; this.hdHandle.Value = Session["strHandleType"].ToString().Trim(); getaddnull(); // ibDel.Enabled = false; ibAdd.Enabled = false; ibFullAdd.Enabled = false; btISISSUE.Enabled = false; } break; case "edit"://录入 CrmProxyMailEntity = CrmProxyMailDA.GetID(Session["GID"].ToString().Trim()); if (CrmProxyMailEntity.GID != null) { tbTITLE.Text = CrmProxyMailEntity.TITLE == null ? "" : CrmProxyMailEntity.TITLE.ToString().Trim(); tbCONTENTS.Text = CrmProxyMailEntity.CONTENTS == null ? "" : CrmProxyMailEntity.CONTENTS.ToString().Trim(); // if (CrmProxyMailEntity.ISISSUE) { getEnabled(); btISISSUE.Text = "取消发布"; this.hdISISSUE.Value = "1"; btISISSUE.Enabled = true; } else { getEnabledTrue(); btISISSUE.Text = "发布"; this.hdISISSUE.Value = "0"; } } else { Session["strHandleType"] = "add"; strHandleType = "add"; this.hdHandle.Value = Session["strHandleType"].ToString().Trim(); getaddnull(); // ibDel.Enabled = false; ibAdd.Enabled = false; ibFullAdd.Enabled = false; btISISSUE.Enabled = false; } break; } } else { } } //集装箱 if (Session["GID"] != null) { if (this.hdEnter.Value != "") { getEnter(); } if (Session["GID"].ToString().Trim().Equals("")) { this.hdGid.Value = Session["GID"].ToString().Trim(); } else { this.hdGid.Value = Session["GID"].ToString().Trim(); } } else { //Response.Write("-1"); //Response.End(); } } protected void getEnabled() { ibAdd.Enabled = false; ibFullAdd.Enabled = false; divibEnter.Disabled = true; ibDel.Enabled = false; btISISSUE.Enabled = false; tbTITLE.Enabled = false; tbCONTENTS.Enabled = false; } protected void getEnabledTrue() { ibAdd.Enabled = true; ibFullAdd.Enabled = true; divibEnter.Disabled = false; ibDel.Enabled = true; btISISSUE.Enabled = true; tbTITLE.Enabled = true; tbCONTENTS.Enabled = true; } protected String getBSNO(string strName) { string strBSNO = Guid.NewGuid().ToString(); strBSNO = strBSNO.Replace("-", ""); strBSNO = strName + strBSNO; return strBSNO; } protected void getaddnull() { getEnabledTrue(); // btISISSUE.Text = "发布"; Session["GID"] = getBSNO("Sail"); this.hdGid.Value = Session["GID"].ToString().Trim(); // tbTITLE.Text = ""; tbCONTENTS.Text = ""; // ibDel.Enabled = false; ibAdd.Enabled = false; ibFullAdd.Enabled = false; btISISSUE.Enabled = false; } protected void getEnter() { bool bl = false; strHandleType = Session["strHandleType"].ToString(); this.hdHandle.Value = Session["strHandleType"].ToString().Trim(); // if (strHandleType.Equals("add") || strHandleType.Equals("addfull"))//新增 { CrmProxyMailEntity.GID = Session["GID"].ToString().Trim();// 惟一编号 CrmProxyMailEntity.TITLE = tbTITLE.Text.ToString().Trim();// 标题 CrmProxyMailEntity.CONTENTS = tbCONTENTS.Text;// 内容 CrmProxyMailEntity.CREATEUSER = strUserID;// 创建人 CrmProxyMailEntity.MODIFIEDUSER = strUserID;// 最后一次更新操作人 CrmProxyMailEntity.DELETEUSER = strUserID; // 删除操作人 CrmProxyMailEntity.CORPID = strCompanyID.Trim(); // int iResult = CrmProxyMailDA.InserInfo(CrmProxyMailEntity); if (iResult > 0) { bl = true; } else { bl = false; } } else if (strHandleType.Equals("edit"))//录入 { CrmProxyMailEntity.GID = Session["GID"].ToString().Trim();// 惟一编号 CrmProxyMailEntity.TITLE = tbTITLE.Text.ToString().Trim();// 标题 CrmProxyMailEntity.CONTENTS = tbCONTENTS.Text;// 内容 CrmProxyMailEntity.MODIFIEDUSER = strUserID;// 最后一次更新操作人 // int iResult = CrmProxyMailDA.UpdateInfo(CrmProxyMailEntity); if (iResult > 0) { //Response.Write(""); bl = true; } else { //Response.Write(""); bl = false; } } this.hdEnter.Value = ""; // if (bl) { // ibDel.Enabled = true; ibAdd.Enabled = true; ibFullAdd.Enabled = true; //window.opener.location.reload();history.back(); //Response.Write(""); Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", ""); return; } else { Response.Write(""); return; } } protected void ibFullAdd_Click(object sender, EventArgs e) { getEnabledTrue(); Session["strHandleType"] = "addfull"; this.hdHandle.Value = Session["strHandleType"].ToString().Trim(); Session["GID"] = getBSNO("Sail"); this.hdGid.Value = Session["GID"].ToString().Trim(); // ibDel.Enabled = false; ibAdd.Enabled = false; ibFullAdd.Enabled = false; btISISSUE.Enabled = false; } protected void ibAdd_Click(object sender, EventArgs e) { getEnabledTrue(); Session["strHandleType"] = "add"; this.hdHandle.Value = Session["strHandleType"].ToString().Trim(); // getaddnull(); // ibDel.Enabled = false; ibAdd.Enabled = false; ibFullAdd.Enabled = false; btISISSUE.Enabled = false; } protected void ibDel_Click(object sender, EventArgs e) { if (this.hdISISSUE.Value.Trim().Equals("1")) { Response.Write(""); return; } // string alt = CrmProxyMailDA.GetCrmProxyMailDel(" or gid='" + Session["GID"].ToString().Trim() + "'", strUserID.Trim()); if (alt != "") { Response.Write(""); return; } // T_ALL_DA T_ALL_DA = new T_ALL_DA(); alt = T_ALL_DA.GetStrSQL("gid", "select top 1 gid from [crm_proxy_mail] where GID<>'" + Session["GID"].ToString().Trim() + "' and ISDELETE=0"); if (alt.Trim() != "") { Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", ""); return; } // getEnabledTrue(); Session["strHandleType"] = "add"; this.hdHandle.Value = Session["strHandleType"].ToString().Trim(); // getaddnull(); // ibDel.Enabled = false; ibAdd.Enabled = false; ibFullAdd.Enabled = false; btISISSUE.Enabled = false; } public bool IsNumeric(string s) { bool bReturn = true; try { int inum = int.Parse(s); } catch { bReturn = false; } return bReturn; } protected void btISISSUE_Click(object sender, EventArgs e) { int iii = 0; if (this.hdISISSUE.Value.Trim().Equals("0")) { iii = CrmProxyMailDA.UpdateInfoCNTRTOTAL("update crm_proxy_mail set ISISSUE='1',BEGINTIME=getdate() where GID='" + Session["GID"].ToString().Trim() + "'", strUserID.Trim()); if (iii == 1) { btISISSUE.Text = "取消发布"; this.hdISISSUE.Value = "1"; getEnabled(); btISISSUE.Enabled = true; // Page.ClientScript.RegisterStartupScript(this.GetType(), "key2", ""); return; } else { Response.Write(""); return; } } else { iii = CrmProxyMailDA.UpdateInfoCNTRTOTAL("update crm_proxy_mail set ISISSUE='0',ENDTIME=getdate() where GID='" + Session["GID"].ToString().Trim() + "'", strUserID.Trim()); if (iii == 1) { btISISSUE.Text = "发布"; this.hdISISSUE.Value = "0"; getEnabledTrue(); Page.ClientScript.RegisterStartupScript(this.GetType(), "key3", ""); return; } else { Response.Write(""); return; } } } } }