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.

1073 lines
48 KiB
C#

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.Drawing;
using System.IO;
namespace DSWeb.CRM
{
public partial class CRMClientInfo : System.Web.UI.Page
{
public string strHandleType = String.Empty;
public string sSQL = String.Empty;
public string gvid = String.Empty;
public string strUserID = String.Empty;
public string strCompanyID;//公司GID
public string strShowName;//用户显示名
public string strDeptName;//部门名称
T_ALL_DA T_ALL_DA = new T_ALL_DA();
RangeDA RangeDA = new RangeDA();
public int isOpenAnnounce;
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;
//strUserID = "";
}
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 (Request.QueryString["id"] != null)//if (Request.QueryString["id"] != null)
{
ViewState["GID"] = Request.QueryString["id"].ToString();//"topseaeusername129481962859531250";
this.hdGid.Value = ViewState["GID"].ToString().Trim();
}
if (Request.QueryString["isenabled"] != null)//if (Request.QueryString["id"] != null)
{
ViewState["isenabled"] = Request.QueryString["isenabled"].ToString();
this.hdEnabled.Value = ViewState["isenabled"].ToString().Trim();
}
//
//权限菜单范围
//string strAction = T_ALL_DA.GetStrSQL("USERID", "select USERID from [user_action] where USERID='" + strUserID.Trim() + "' and ACTIONID='7309DD9E-3A7F-44E9-93A2-3CA571C374E9'");
//if (strAction.Trim().Equals(""))
//{
// Response.Write("<script>alert('无权限打开往来单位信息!');window.parent.close();window.close();</script>");
// Response.End();
// //Response.Close();
// return;
//}
//权限可视范围
//if (strHandleType.Trim() == "edit")
//{
//
string strV = RangeDA.GetVISIBLERANGE(this.hdUserID.Value.Trim(), "modCRMClientList");
string strO = RangeDA.GetOPERATERANGE(this.hdUserID.Value.Trim(), "modCRMClientList");
string alt = "";
if (strV.Trim().Equals("4"))
{
Response.Write("<script>alert('无权限打开往来单位信息!');window.parent.close();window.close();</script>");
Response.End();
//Response.Close();
return;
}
else if (strV.Trim().Equals("0"))
{
if (strV.Trim() != strO.Trim())
{
if (strO.Trim().Equals("1"))//分公司
{
if (ViewState["GID"] != null)
{
alt = RangeDA.GetCRMClientListCompany(this.hdUserID.Value.Trim(), ViewState["GID"].ToString().Trim());
if (alt == "")
{
getEnabled();
}
}
ibAdd.Enabled = true;
}
else if (strO.Trim().Equals("2"))//部门
{
ibAdd.Enabled = true;
}
else if (strO.Trim().Equals("3"))//个人
{
if (ViewState["GID"] != null)
{
alt = RangeDA.GetCRMClientListPerson(this.hdUserID.Value.Trim(), ViewState["GID"].ToString().Trim());
if (alt == "")
{
getEnabled();
}
}
ibAdd.Enabled = true;
}
else if (strO.Trim().Equals("4"))//无
{
if (ViewState["GID"] == null)
{
Response.Write("<script>alert('无权限新建往来单位信息!');</script>");
Response.End();
//Response.Close();
return;
}
getEnabled();
}
}
}
else if (strV.Trim().Equals("1"))
{
if (strO.Trim().Equals("1"))//公司
{
if (ViewState["GID"] != null)
{
alt = RangeDA.GetCRMClientListCompany(this.hdUserID.Value.Trim(), ViewState["GID"].ToString().Trim());
if (alt == "")
{
getEnabled();
}
}
ibAdd.Enabled = true;
}
if (strO.Trim().Equals("2"))//部门
{
ibAdd.Enabled = true;
}
else if (strO.Trim().Equals("3"))//个人
{
if (ViewState["GID"] != null)
{
alt = RangeDA.GetCRMClientListPerson(this.hdUserID.Value.Trim(), ViewState["GID"].ToString().Trim());
if (alt == "")
{
getEnabled();
}
}
ibAdd.Enabled = true;
}
else if (strO.Trim().Equals("4"))//无
{
if (ViewState["GID"] == null)
{
Response.Write("<script>alert('无权限打开往来单位信息!');</script>");
Response.End();
//Response.Close();
return;
}
getEnabled();
}
}
else if (strV.Trim().Equals("2"))
{
if (strO.Trim().Equals("2"))//个人
{
ibAdd.Enabled = true;
}
else if (strO.Trim().Equals("3"))//个人
{
if (ViewState["GID"] != null)
{
alt = RangeDA.GetCRMClientListPerson(this.hdUserID.Value.Trim(), ViewState["GID"].ToString().Trim());
if (alt == "")
{
getEnabled();
}
}
ibAdd.Enabled = true;
}
else if (strO.Trim().Equals("4"))//无
{
if (ViewState["GID"] == null)
{
Response.Write("<script>alert('无权限打开往来单位信息!');</script>");
Response.End();
//Response.Close();
return;
}
getEnabled();
}
}
else if (strV.Trim().Equals("3"))
{
if (strO.Trim().Equals("3"))//个人
{
if (ViewState["GID"] != null)
{
alt = RangeDA.GetCRMClientListPerson(this.hdUserID.Value.Trim(), ViewState["GID"].ToString().Trim());
if (alt == "")
{
getEnabled();
}
}
ibAdd.Enabled = true;
}
else if (strO.Trim().Equals("4"))//无
{
if (ViewState["GID"] == null)
{
Response.Write("<script>alert('无权限打开往来单位信息!');window.parent.close();window.close();</script>");
Response.End();
//Response.Close();
return;
}
getEnabled();
}
}
//}
//else
//{
// getEnabledTrue();
//}
if (!IsPostBack)
{
if (Request.QueryString["handle"] != null)
{
ViewState["strHandleType"] = Request.QueryString["handle"].ToString();//"edit";
strHandleType = ViewState["strHandleType"].ToString().Trim();
this.hdhandle.Value = Request.QueryString["handle"].ToString();
//
switch (strHandleType)
{
case "add"://新增
getaddnull();
break;
case "edit"://录入
CRMInfoClientDA CRMInfoClientDA = new CRMInfoClientDA();
CRMInfoClientEntity model = new CRMInfoClientEntity();
model = CRMInfoClientDA.GetModel(ViewState["GID"].ToString().Trim());
//
if (model == null)
{
strHandleType = "add";
ViewState["strHandleType"] = "add";
//
getaddnull();
}
else
{
this.hd_Name.Value = model.DESCRIPTION.ToString().Trim();
this.hd_Code.Value = model.CODENAME.ToString().Trim();
this.hd_ShortName.Value = model.CODENAME.ToString().Trim();
//
txtName.Text = model.DESCRIPTION.ToString().Trim();
txtCode.Text = model.CODENAME.ToString().Trim();
txtShortName.Text = model.SHORTNAME.ToString().Trim();
//
txtEnShortName.Text = model.NAME.ToString().Trim();
txtEnName.Text = model.EnFullName.ToString().Trim();
txtAddress.Text = model.ADDR.ToString().Trim();
txtPrincipal.Text = model.CHIEF.ToString().Trim();
txtWeb.Text = model.WEB.ToString().Trim();
txtPhone1.Text = model.TEL.ToString().Trim();
//
int iPhone = model.TEL.ToString().Trim().IndexOf("-");
if (iPhone != 0)
{
string[] strPhones = model.TEL.ToString().Trim().Split(new string[] { "-" }, StringSplitOptions.RemoveEmptyEntries);
for (int i = 1; i < strPhones.Length; i++)
{
if (strPhones[0].Trim() == "" || strPhones[0].Trim() == "0")
{
txtPhone1.Text = "86";
}
else
{
txtPhone1.Text = strPhones[0].Trim();
}
if (strPhones[1].Trim() == "" || strPhones[1].Trim() == "0")
{
txtPhone2.Text = "";
}
else
{
txtPhone2.Text = strPhones[1].Trim();
}
if (strPhones[2].Trim() == "" || strPhones[2].Trim() == "0")
{
txtPhone3.Text = "";
}
else
{
txtPhone3.Text = strPhones[2].Trim();
}
}
}
else
{
txtPhone1.Text = "86";
txtPhone2.Text = "";
txtPhone3.Text = "";
}
//
int iFAX = model.FAX.ToString().Trim().IndexOf("-");
if (iFAX != 0)
{
string[] strFAXs = model.FAX.ToString().Trim().Split(new string[] { "-" }, StringSplitOptions.RemoveEmptyEntries);
for (int i = 1; i < strFAXs.Length; i++)
{
if (strFAXs[0].Trim() == "" || strFAXs[0].Trim() == "0")
{
txtFax1.Text = "86";
}
else
{
txtFax1.Text = strFAXs[0].Trim();
}
if (strFAXs[1].Trim() == "" || strFAXs[1].Trim() == "0")
{
txtFax2.Text = "";
}
else
{
txtFax2.Text = strFAXs[1].Trim();
}
if (strFAXs[2].Trim() == "" || strFAXs[2].Trim() == "0")
{
txtFax3.Text = "";
}
else
{
txtFax3.Text = strFAXs[2].Trim();
}
}
}
else
{
txtFax1.Text = "86";
txtFax2.Text = "";
txtFax3.Text = "";
}
//
txtEmail.Text = model.EMAIL.ToString().Trim();
txtAREA.Text = model.AREA.ToString().Trim();
txtPRODUCT.Text = model.PRODUCT.ToString().Trim();
txtCTNNUM.Text = model.CTNNUM.ToString().Trim();
//财务信息
txtFPTT1.Text = model.BillRises1.ToString().Trim();
txtFPTT2.Text = model.BillRises2.ToString().Trim();
txtRMBZPTT.Text = model.RMBBillRises.ToString().Trim();
txtRMBBank.Text = model.RMBBank.ToString().Trim();
txtRMBCode.Text = model.RMBAccount.ToString().Trim();
txtRMBNum.Text = model.RMBOnlineNO.ToString().Trim();
txtUSDZPTT.Text = model.USDBillRises.ToString().Trim();
txtUSDBank.Text = model.USDBank.ToString().Trim();
txtUSDCode.Text = model.USDAccount.ToString().Trim();
txtUSDNum.Text = model.USDOnlineNO.ToString().Trim();
ddlJSFS.SelectedItem.Text = model.STLNAME.ToString().Trim();
txtUSDHL.Text = model.USDExchangeRate.ToString().Trim();
txtREMARK.Text = model.REMARK.ToString().Trim();
//
cbISLANE1.Checked = model.ISLANE1;
cbISLANE2.Checked = model.ISLANE2;
cbISLANE3.Checked = model.ISLANE3;
cbISLANE4.Checked = model.ISLANE4;
cbISLANE5.Checked = model.ISLANE5;
cbISLANE6.Checked = model.ISLANE6;
cbISLANE7.Checked = model.ISLANE7;
cbISLANE8.Checked = model.ISLANE8;
cbISLANE9.Checked = model.ISLANE9;
cbISLANE10.Checked = model.ISLANE10;
cbISLANE11.Checked = model.ISLANE11;
cbISLANE12.Checked = model.ISLANE12;
cbISLANE13.Checked = model.ISLANE13;
txtENFULLNAME2.Text = model.ENFULLNAME2.ToString().Trim();
txtENFULLNAME3.Text = model.ENFULLNAME3.ToString().Trim();
//
Image1.ImageUrl = model.IMAGEURL.ToString().Trim();
Image2.ImageUrl = model.IMAGEURL2.ToString().Trim();
this.hdIMAGEURL.Value = model.IMAGEURL.ToString().Trim();
this.hdIMAGEURL2.Value = model.IMAGEURL2.ToString().Trim();
}
break;
}
}
else
{
}
}
//
if (this.hdEnabled.Value.ToString() == "false")
{
getEnabled();
}
}
protected void getaddnull()
{
txtName.Text = "";
txtCode.Text = "";
txtShortName.Text = "";
this.hd_Name.Value = "";
this.hd_Code.Value = "";
this.hd_ShortName.Value = "";
//
txtEnShortName.Text = "";
txtEnName.Text = "";
txtAddress.Text = "";
txtPrincipal.Text = "";
txtPhone1.Text = "86";
txtPhone2.Text = "";
txtPhone3.Text = "";
txtWeb.Text = "";
txtFax1.Text = "86";
txtFax2.Text = "";
txtFax3.Text = "";
txtEmail.Text = "";
txtAREA.Text = "";
txtPRODUCT.Text = "";
txtCTNNUM.Text = "";
txtFPTT1.Text = "";
txtFPTT2.Text = "";
txtRMBZPTT.Text = "";
txtRMBBank.Text = "";
txtRMBCode.Text = "";
txtRMBNum.Text = "";
txtUSDZPTT.Text = "";
txtUSDBank.Text = "";
txtUSDCode.Text = "";
txtUSDNum.Text = "";
ddlJSFS.Text = "";
txtUSDHL.Text = "0.00";
txtREMARK.Text = "";
//
Image1.ImageUrl = "images/noImage.gif";
Image2.ImageUrl = "images/noImage.gif";
this.hdIMAGEURL.Value = "images/noImage.gif";
this.hdIMAGEURL2.Value = "images/noImage.gif";
txtENFULLNAME2.Text = "";
txtENFULLNAME3.Text = "";
cbISLANE1.Checked = false;
cbISLANE2.Checked = false;
cbISLANE3.Checked = false;
cbISLANE4.Checked = false;
cbISLANE5.Checked = false;
cbISLANE6.Checked = false;
cbISLANE7.Checked = false;
cbISLANE8.Checked = false;
cbISLANE9.Checked = false;
cbISLANE10.Checked = false;
cbISLANE11.Checked = false;
cbISLANE12.Checked = false;
cbISLANE13.Checked = false;
}
protected void getEnabled()
{
ibAdd.Enabled = false;
this.ibEnter.Disabled = true;
this.imgDel.Disabled = true;
//ibDel.Enabled = false;
//
this.hdEnabled.Value = "false";
//
txtName.Enabled = false;
txtCode.Enabled = false;
txtShortName.Enabled = false;
txtEnShortName.Enabled = false;
txtEnName.Enabled = false;
txtAddress.Enabled = false;
txtPrincipal.Enabled = false;
txtPhone1.Enabled = false;
txtPhone2.Enabled = false;
txtPhone3.Enabled = false;
txtWeb.Enabled = false;
txtFax1.Enabled = false;
txtFax2.Enabled = false;
txtFax3.Enabled = false;
txtEmail.Enabled = false;
txtAREA.Enabled = false;
txtPRODUCT.Enabled = false;
txtCTNNUM.Enabled = false;
txtFPTT1.Enabled = false;
txtFPTT2.Enabled = false;
txtRMBZPTT.Enabled = false;
txtRMBBank.Enabled = false;
txtRMBCode.Enabled = false;
txtRMBNum.Enabled = false;
txtUSDZPTT.Enabled = false;
txtUSDBank.Enabled = false;
txtUSDCode.Enabled = false;
txtUSDNum.Enabled = false;
ddlJSFS.Enabled = false;
txtUSDHL.Enabled = false;
txtREMARK.Enabled = false;
FileUpload1.Enabled = false;
FileUpload2.Enabled = false;
txtENFULLNAME2.Enabled = false;
txtENFULLNAME3.Enabled = false;
cbISLANE1.Enabled = false;
cbISLANE2.Enabled = false;
cbISLANE3.Enabled = false;
cbISLANE4.Enabled = false;
cbISLANE5.Enabled = false;
cbISLANE6.Enabled = false;
cbISLANE7.Enabled = false;
cbISLANE8.Enabled = false;
cbISLANE9.Enabled = false;
cbISLANE10.Enabled = false;
cbISLANE11.Enabled = false;
cbISLANE12.Enabled = false;
cbISLANE13.Enabled = false;
}
protected void getEnabledTrue()
{
ibAdd.Enabled = true;
this.ibEnter.Disabled = false;
this.imgDel.Disabled = false;
//ibDel.Enabled = true;
//
this.hdEnabled.Value = "true";
//
txtName.Enabled = true;
txtCode.Enabled = true;
txtShortName.Enabled = true;
txtEnShortName.Enabled = true;
txtEnName.Enabled = true;
txtAddress.Enabled = true;
txtPrincipal.Enabled = true;
txtPhone1.Enabled = true;
txtPhone2.Enabled = true;
txtPhone3.Enabled = true;
txtWeb.Enabled = true;
txtFax1.Enabled = true;
txtFax2.Enabled = true;
txtFax3.Enabled = true;
txtEmail.Enabled = true;
txtAREA.Enabled = true;
txtPRODUCT.Enabled = true;
txtCTNNUM.Enabled = true;
txtFPTT1.Enabled = true;
txtFPTT2.Enabled = true;
txtRMBZPTT.Enabled = true;
txtRMBBank.Enabled = true;
txtRMBCode.Enabled = true;
txtRMBNum.Enabled = true;
txtUSDZPTT.Enabled = true;
txtUSDBank.Enabled = true;
txtUSDCode.Enabled = true;
txtUSDNum.Enabled = true;
ddlJSFS.Enabled = true;
txtUSDHL.Enabled = true;
txtREMARK.Enabled = true;
FileUpload1.Enabled = true;
FileUpload2.Enabled = true;
txtENFULLNAME2.Enabled = true;
txtENFULLNAME3.Enabled = true;
cbISLANE1.Enabled = true;
cbISLANE2.Enabled = true;
cbISLANE3.Enabled = true;
cbISLANE4.Enabled = true;
cbISLANE5.Enabled = true;
cbISLANE6.Enabled = true;
cbISLANE7.Enabled = true;
cbISLANE8.Enabled = true;
cbISLANE9.Enabled = true;
cbISLANE10.Enabled = true;
cbISLANE11.Enabled = true;
cbISLANE12.Enabled = true;
cbISLANE13.Enabled = true;
}
protected String getBSNO()
{
string strBSNO = Guid.NewGuid().ToString();
strBSNO = strBSNO.Replace("-", "");
strBSNO = "InfoClient" + strBSNO;
return strBSNO;
}
protected bool getAdd()
{
CRMInfoClientDA CRMInfoClientDA = new CRMInfoClientDA();
CRMInfoClientEntity model = new CRMInfoClientEntity();
//基本信息
model.GID = getBSNO();
model.DESCRIPTION = this.hd_Name.Value.Trim();
model.CODENAME = this.hd_Code.Value.Trim();
model.SHORTNAME = this.hd_ShortName.Value.Trim();
//
model.NAME = txtEnShortName.Text.Trim();
model.EnFullName = txtEnName.Text.Trim();
model.ADDR = txtAddress.Text.Trim();
model.CHIEF = txtPrincipal.Text.Trim();
model.WEB = txtWeb.Text.Trim();
model.TEL = txtPhone1.Text.Trim() + "-" + txtPhone2.Text.Trim() + "-" + txtPhone3.Text.Trim();
model.FAX = txtFax1.Text.Trim() + "-" + txtFax2.Text.Trim() + "-" + txtFax3.Text.Trim();
model.EMAIL = txtEmail.Text.Trim();
model.AREA = txtAREA.Text.Trim();
model.PRODUCT = txtPRODUCT.Text.Trim();
model.CTNNUM = txtCTNNUM.Text.Trim() == "" ? "" : txtCTNNUM.Text.Trim();
model.LANE = "";
model.SALE = "";
model.OPNAME = strShowName;
model.OPTIME = DateTime.Now;
model.MODIFIEDUSER = Session["UserID"].ToString();
model.MODIFIEDTIME = DateTime.Now;
model.CORPID = "";
model.BLCONTENT = "";
model.CustomAttributes1 = "";
model.CustomAttributes2 = "";
model.REMARK = txtREMARK.Text.Trim();
//财务信息
model.BillRises1 = txtFPTT1.Text.Trim();
model.BillRises2 = txtFPTT2.Text.Trim();
model.RMBBillRises = txtRMBZPTT.Text.Trim();
model.RMBBank = txtRMBBank.Text.Trim();
model.RMBAccount = txtRMBCode.Text.Trim();
model.RMBOnlineNO = txtRMBNum.Text.Trim();
model.USDBillRises = txtUSDZPTT.Text.Trim();
model.USDBank = txtUSDBank.Text.Trim();
model.USDAccount = txtUSDCode.Text.Trim();
model.USDOnlineNO = txtUSDNum.Text.Trim();
model.STLNAME = ddlJSFS.SelectedItem.Text.Trim();
model.USDExchangeRate = txtUSDHL.Text.Trim() == "" ? decimal.Parse("0.00") : decimal.Parse(txtUSDHL.Text.Trim());
//
model.ISLANE1 = cbISLANE1.Checked;
model.ISLANE2 = cbISLANE2.Checked;
model.ISLANE3 = cbISLANE3.Checked;
model.ISLANE4 = cbISLANE4.Checked;
model.ISLANE5 = cbISLANE5.Checked;
model.ISLANE6 = cbISLANE6.Checked;
model.ISLANE7 = cbISLANE7.Checked;
model.ISLANE8 = cbISLANE8.Checked;
model.ISLANE9 = cbISLANE9.Checked;
model.ISLANE10 = cbISLANE10.Checked;
model.ISLANE11 = cbISLANE11.Checked;
model.ISLANE12 = cbISLANE12.Checked;
model.ISLANE13 = cbISLANE13.Checked;
model.ENFULLNAME2 = txtENFULLNAME2.Text.ToString().Trim();
model.ENFULLNAME3 = txtENFULLNAME3.Text.ToString().Trim();
//
model.IMAGEURL = this.hdIMAGEURL.Value.Trim();
model.IMAGEURL2 = this.hdIMAGEURL2.Value.Trim();
//
int iResult = CRMInfoClientDA.Add(model);
if (iResult > 0)
{
ViewState["GID"] = model.GID.Trim();
this.hdGid.Value = model.GID.Trim();
ViewState["strHandleType"] = "edit";
this.hdhandle.Value = "edit";
return true;
}
else
{
return false;
}
}
protected bool getEdit()
{
CRMInfoClientDA CRMInfoClientDA = new CRMInfoClientDA();
CRMInfoClientEntity model = new CRMInfoClientEntity();
model.GID = ViewState["GID"].ToString().Trim();
model.DESCRIPTION = this.hd_Name.Value.Trim();
model.CODENAME = this.hd_Code.Value.Trim();
model.SHORTNAME = this.hd_ShortName.Value.Trim();
model.NAME = txtEnShortName.Text.Trim();
model.EnFullName = txtEnName.Text.Trim();
model.ADDR = txtAddress.Text.Trim();
model.CHIEF = txtPrincipal.Text.Trim();
model.WEB = txtWeb.Text.Trim();
model.TEL = txtPhone1.Text.Trim() + "-" + txtPhone2.Text.Trim() + "-" + txtPhone3.Text.Trim();
model.FAX = txtFax1.Text.Trim() + "-" + txtFax2.Text.Trim() + "-" + txtFax3.Text.Trim();
model.EMAIL = txtEmail.Text.Trim();
model.AREA = txtAREA.Text.Trim();
model.PRODUCT = txtPRODUCT.Text.Trim();
model.CTNNUM = txtCTNNUM.Text.Trim() == "" ? "" : txtCTNNUM.Text.Trim();
model.LANE = "";
//model.SALE = "";
model.OPNAME = strShowName;
model.OPTIME = DateTime.Now;
model.MODIFIEDUSER = Session["UserID"].ToString();
model.MODIFIEDTIME = DateTime.Now;
model.CORPID = "";
model.BLCONTENT = "";
model.CustomAttributes1 = "";
model.CustomAttributes2 = "";
model.REMARK = txtREMARK.Text.Trim();
//财务信息
model.BillRises1 = txtFPTT1.Text.Trim();
model.BillRises2 = txtFPTT2.Text.Trim();
model.RMBBillRises = txtRMBZPTT.Text.Trim();
model.RMBBank = txtRMBBank.Text.Trim();
model.RMBAccount = txtRMBCode.Text.Trim();
model.RMBOnlineNO = txtRMBNum.Text.Trim();
model.USDBillRises = txtUSDZPTT.Text.Trim();
model.USDBank = txtUSDBank.Text.Trim();
model.USDAccount = txtUSDCode.Text.Trim();
model.USDOnlineNO = txtUSDNum.Text.Trim();
model.STLNAME = ddlJSFS.SelectedItem.Text.Trim();
model.USDExchangeRate = txtUSDHL.Text.Trim() == "" ? decimal.Parse("0.00") : decimal.Parse(txtUSDHL.Text.Trim());
//
model.ISLANE1 = cbISLANE1.Checked;
model.ISLANE2 = cbISLANE2.Checked;
model.ISLANE3 = cbISLANE3.Checked;
model.ISLANE4 = cbISLANE4.Checked;
model.ISLANE5 = cbISLANE5.Checked;
model.ISLANE6 = cbISLANE6.Checked;
model.ISLANE7 = cbISLANE7.Checked;
model.ISLANE8 = cbISLANE8.Checked;
model.ISLANE9 = cbISLANE9.Checked;
model.ISLANE10 = cbISLANE10.Checked;
model.ISLANE11 = cbISLANE11.Checked;
model.ISLANE12 = cbISLANE12.Checked;
model.ISLANE13 = cbISLANE13.Checked;
model.ENFULLNAME2 = txtENFULLNAME2.Text.ToString().Trim();
model.ENFULLNAME3 = txtENFULLNAME3.Text.ToString().Trim();
//
model.IMAGEURL = this.hdIMAGEURL.Value.Trim();
model.IMAGEURL2 = this.hdIMAGEURL2.Value.Trim();
//
int iResult = CRMInfoClientDA.Update(model);
if (iResult > 0)
{
return true;
}
else
{
return false;
}
}
protected void btnEnter_Click(object sender, EventArgs e)
{
if (txtPhone1.Text.Trim().Equals(""))
{
txtPhone1.Text = "86";
}
if (txtPhone2.Text.Trim().Equals(""))
{
txtPhone2.Text = "0";
}
if (txtPhone3.Text.Trim().Equals(""))
{
txtPhone3.Text = "0";
}
if (txtFax1.Text.Trim().Equals(""))
{
txtFax1.Text = "86";
}
if (txtFax2.Text.Trim().Equals(""))
{
txtFax2.Text = "0";
}
if (txtFax3.Text.Trim().Equals(""))
{
txtFax3.Text = "0";
}
//
bool bl = false;
strHandleType = ViewState["strHandleType"].ToString();
if (strHandleType.Equals("add"))//新增
{
string simg1 = setFileUpload1();
if (simg1.Trim() == "")
{
this.hdIMAGEURL.Value = "images/noImage.gif";
}
else
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>alert('"+simg1+"');</script>");
return;
}
string simg2 = setFileUpload2();
if (simg2.Trim() == "")
{
this.hdIMAGEURL2.Value = "images/noImage.gif";
}
else
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "key2", "<script>alert('" + simg2 + "');</script>");
return;
}
bl = getAdd();
}
else if (strHandleType.Equals("edit"))//录入
{
string simg1 = setFileUpload1();
if (simg1.Trim() != "")
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "key3", "<script>alert('" + simg1 + "');</script>");
return;
}
string simg2 = setFileUpload2();
if (simg2.Trim() != "")
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "key4", "<script>alert('" + simg2 + "');</script>");
return;
}
bl = getEdit();
}
//ibDel.Enabled = true;
this.imgDel.Disabled = false;
ibAdd.Enabled = true;
if (bl)
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "key5", "<script>reloadParent('" + ViewState["GID"].ToString().Trim() + "');</script>");
return;
}
else
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "key6", "<script>alert('出错,请重新填写!');</script>");
return;
}
}
protected void btnAdd_Click(object sender, ImageClickEventArgs e)
{
getEnabledTrue();
ViewState["strHandleType"] = "add";
this.hdGid.Value = "";
//ViewState["GID"] = getBSNO();
//this.hdGid.Value = ViewState["GID"].ToString().Trim();
getaddnull();
//
//ibDel.Enabled = false;
this.imgDel.Disabled = true;
ibAdd.Enabled = true;
this.ibEnter.Disabled = false;
}
protected void btnDel_Click(object sender, EventArgs e)
{
CRMInfoClientDA CRMInfoClientDA = new CRMInfoClientDA();
CRMInfoClientEntity model = new CRMInfoClientEntity();
string str = "select count(*) as num from crm_info_client where gid in('" + ViewState["GID"].ToString().Trim() + "') and SALE in (select SHOWNAME from [user] where (GID in(select USERID from user_company where COMPANYID='" + strCompanyID + "' and USERID in(select USERID from user_userattribute where ATTRIBUTEID in(select GID from user_attribute where [NAME]='issaleman') and value='true')) and ISDISABLE=0 and ISDELETED=0))";
string ls = T_ALL_DA.GetStrSQL("num", str);
if (ls.Trim() == "0")
{
int idel = CRMInfoClientDA.Delete(ViewState["GID"].ToString().Trim());
if (idel < 1)
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "key7", "<script>alert('删除失败!');</script>");
return;
}
else
{
//window.opener.location.reload();
Page.ClientScript.RegisterStartupScript(this.GetType(), "key8", "<script>alert('删除成功!');window.parent.opener.location.href = window.parent.opener.location.href;</script>");
}
}
else
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "key9", "<script>alert('已经分配销售的客户,不允许删除!');</script>");
return;
}
//
ViewState["strHandleType"] = "edit";
this.hdhandle.Value = "edit";
//
model = CRMInfoClientDA.GetModelTop1();
if (model != null)
{
ViewState["GID"] = model.GID.Trim();
this.hdGid.Value = model.GID.Trim();
//
this.hd_Name.Value = model.DESCRIPTION.ToString().Trim();
this.hd_Code.Value = model.CODENAME.ToString().Trim();
this.hd_ShortName.Value = model.CODENAME.ToString().Trim();
//
txtName.Text = model.DESCRIPTION.ToString().Trim();
txtCode.Text = model.CODENAME.ToString().Trim();
txtShortName.Text = model.SHORTNAME.ToString().Trim();
txtEnShortName.Text = model.NAME.ToString().Trim();
txtEnName.Text = model.EnFullName.ToString().Trim();
txtAddress.Text = model.ADDR.ToString().Trim();
txtPrincipal.Text = model.CHIEF.ToString().Trim();
txtPhone1.Text = model.TEL.ToString().Trim();
txtWeb.Text = model.WEB.ToString().Trim();
txtFax1.Text = model.FAX.ToString().Trim();
txtEmail.Text = model.EMAIL.ToString().Trim();
txtAREA.Text = model.AREA.ToString().Trim();
txtPRODUCT.Text = model.PRODUCT.ToString().Trim();
txtCTNNUM.Text = model.CTNNUM.ToString().Trim();
//财务信息
txtFPTT1.Text = model.BillRises1.ToString().Trim();
txtFPTT2.Text = model.BillRises2.ToString().Trim();
txtRMBZPTT.Text = model.RMBBillRises.ToString().Trim();
txtRMBBank.Text = model.RMBBank.ToString().Trim();
txtRMBCode.Text = model.RMBAccount.ToString().Trim();
txtRMBNum.Text = model.RMBOnlineNO.ToString().Trim();
txtUSDZPTT.Text = model.USDBillRises.ToString().Trim();
txtUSDBank.Text = model.USDBank.ToString().Trim();
txtUSDCode.Text = model.USDAccount.ToString().Trim();
txtUSDNum.Text = model.USDOnlineNO.ToString().Trim();
ddlJSFS.SelectedItem.Text = model.STLNAME.ToString().Trim();
txtUSDHL.Text = model.USDExchangeRate.ToString().Trim();
txtREMARK.Text = model.REMARK.ToString().Trim();
txtENFULLNAME2.Text = model.ENFULLNAME2.ToString().Trim();
txtENFULLNAME3.Text = model.ENFULLNAME3.ToString().Trim();
//
cbISLANE1.Checked = model.ISLANE1;
cbISLANE2.Checked = model.ISLANE2;
cbISLANE3.Checked = model.ISLANE3;
cbISLANE4.Checked = model.ISLANE4;
cbISLANE5.Checked = model.ISLANE5;
cbISLANE6.Checked = model.ISLANE6;
cbISLANE7.Checked = model.ISLANE7;
cbISLANE8.Checked = model.ISLANE8;
cbISLANE9.Checked = model.ISLANE9;
cbISLANE10.Checked = model.ISLANE10;
cbISLANE11.Checked = model.ISLANE11;
cbISLANE12.Checked = model.ISLANE12;
cbISLANE13.Checked = model.ISLANE13;
//
Image1.ImageUrl = model.IMAGEURL.ToString().Trim();
Image2.ImageUrl = model.IMAGEURL2.ToString().Trim();
this.hdIMAGEURL.Value = model.IMAGEURL.ToString().Trim();
this.hdIMAGEURL2.Value = model.IMAGEURL2.ToString().Trim();
}
//
//ibDel.Enabled = false;
this.imgDel.Disabled = true;
ibAdd.Enabled = false;
//权限可视范围
if (ViewState["strHandleType"].ToString().Trim() == "edit")
{
string strV = RangeDA.GetVISIBLERANGE(this.hdUserID.Value.Trim(), "modCRMClientList");
string strO = RangeDA.GetOPERATERANGE(this.hdUserID.Value.Trim(), "modCRMClientList");
string alt = "";
if (strV.Trim() != strO.Trim())
{
if (strO.Trim().Equals("0"))//全部
{
}
else if (strO.Trim().Equals("1"))//分公司
{
alt = RangeDA.GetCRMClientListCompany(this.hdUserID.Value.Trim(), ViewState["GID"].ToString().Trim());
if (alt == "")
{
getEnabled();
}
ibAdd.Enabled = true;
}
else if (strO.Trim().Equals("2"))//部门
{
ibAdd.Enabled = true;
}
else if (strO.Trim().Equals("3"))//个人
{
alt = RangeDA.GetCRMClientListPerson(this.hdUserID.Value, ViewState["GID"].ToString().Trim());
if (alt == "")
{
getEnabled();
}
ibAdd.Enabled = true;
}
else if (strO.Trim().Equals("4"))//无
{
getEnabled();
}
}
}
else
{
getEnabledTrue();
}
//
}
public bool IsNumeric(string s)
{
bool bReturn = true;
try
{
int inum = int.Parse(s);
}
catch
{
bReturn = false;
}
return bReturn;
}
protected string setFileUpload1()
{
if (FileUpload1.HasFile == true)//如果用户确实选择了上传控件的浏览按钮,浏览文件成功.
{
string fuName = FileUpload1.FileName.Replace(" ", "_");
string AbsPath = Server.MapPath("images/");
string sPath = AbsPath + fuName;
string imgurl = "images/" + fuName;
//
Int32 FileLength = 0;//有可能图片的大小会超出INT的范围所以声明为Int32,当然这和下面大小的判断有关系
FileLength = this.FileUpload1.PostedFile.ContentLength;//获取上传文件的字节大小
//取web中的最大限制数FTPMaxRequestLength
string strFTPMaxRequestLength = System.Configuration.ConfigurationSettings.AppSettings["FTPMaxRequestLength"].ToString() as string;
Int32 iFTPMaxRequestLength = 2091151;
if (strFTPMaxRequestLength == null)
{
iFTPMaxRequestLength = Int32.Parse(strFTPMaxRequestLength);
}
//
if (FileLength > iFTPMaxRequestLength)
{
//Page.ClientScript.RegisterStartupScript(this.GetType(), "key10", "<script>alert('文件最大不能超过4M');</script>");
return "图片1的大小超过最大限制";
}
if (File.Exists(sPath)) //判断文件是否寸在
{
//Page.ClientScript.RegisterStartupScript(this.GetType(), "key11", "<script>alert('文件上传FTP失败');</script>");
return "当前路径下已经存在同名的图片1文件";
}
this.FileUpload1.SaveAs(sPath); //保存到服务器的目录,需要根据服务器具体情况修改FileUpload1.FileName会自动获取上传文件名.
Image1.ImageUrl = imgurl.Trim();
this.hdIMAGEURL.Value = imgurl.Trim();
}
return "";
}
protected string setFileUpload2()
{
if (FileUpload2.HasFile == true)//如果用户确实选择了上传控件的浏览按钮,浏览文件成功.
{
string fuName = FileUpload2.FileName.Replace(" ", "_");
string AbsPath = Server.MapPath("images/");
string sPath = AbsPath + fuName;
string imgurl = "images/" + fuName;
//
Int32 FileLength = 0;//有可能图片的大小会超出INT的范围所以声明为Int32,当然这和下面大小的判断有关系
FileLength = this.FileUpload2.PostedFile.ContentLength;//获取上传文件的字节大小
//取web中的最大限制数FTPMaxRequestLength
string strFTPMaxRequestLength = System.Configuration.ConfigurationSettings.AppSettings["FTPMaxRequestLength"].ToString() as string;
Int32 iFTPMaxRequestLength = 2091151;
if (strFTPMaxRequestLength == null)
{
iFTPMaxRequestLength = Int32.Parse(strFTPMaxRequestLength);
}
//
if (FileLength > iFTPMaxRequestLength)
{
//Page.ClientScript.RegisterStartupScript(this.GetType(), "key12", "<script>alert('文件最大不能超过4M');</script>");
return "图片2的大小超过最大限制";
}
if (File.Exists(sPath)) //判断文件是否寸在
{
//Page.ClientScript.RegisterStartupScript(this.GetType(), "key13", "<script>alert('文件上传FTP失败');</script>");
return "当前路径下已经存在同名的图片2文件";
}
this.FileUpload2.SaveAs(sPath); //保存到服务器的目录,需要根据服务器具体情况修改FileUpload2.FileName会自动获取上传文件名.
Image2.ImageUrl = imgurl.Trim();
this.hdIMAGEURL2.Value = imgurl.Trim();
}
return "";
}
}
}