📄 customeredit.ascx.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class CustomerManage_Ctrls_CustomerEdit : PageBaseUserCtrl
{
public WYX.Dataport.Dataport dataport = new WYX.Dataport.Dataport();
private int ComId;
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
ComId = Convert.ToInt32(Request.QueryString["code"]);
GetComType();
GetRelation();
GetIndustry();
GetComResource();
GetNation();
GetCity();
GetCompanyType();
GetCompanySize();
GetTrack();
SetData();
}
}
/// <summary>
/// 初始化数据
/// </summary>
protected void SetData()
{
string sql = " select * from ITSV_CustomerManager where code = " + ComId + "";
DataRow dr = null;
try
{
dr = dataport.GetRowResult(sql);
}
catch
{
dr = null;
}
if (dr == null)
{
ShowAndClose("客户编号错误,请您重试!!", "");
return;
}
this.txtComId.Text = dr["code"].ToString();
this.txtComName.Text = dr["name"].ToString();
this.ddlRelation.SelectedValue = dr["relation"].ToString();
this.ddlComType.SelectedValue = dr["type"].ToString();
this.ddlWay.SelectedValue = dr["industry"].ToString();
this.ddlComResource.SelectedValue = dr["source"].ToString();
this.ddlnation.SelectedValue = dr["district"].ToString();
this.ddlCity.SelectedValue = dr["province"].ToString();
this.ddlCompanyType.SelectedValue = dr["property"].ToString();
this.ddlCompanySize.SelectedValue = dr["customer_size"].ToString();
this.txtCompanyTel.Text = dr["tel"].ToString();
this.txtFax.Text = dr["fax"].ToString();
this.txtZip.Text = dr["zip"].ToString();
this.txtAdress.Text = dr["address"].ToString();
this.txtEmail.Text = dr["email"].ToString();
this.txtHomePage.Text = dr["homepage"].ToString();
this.txtRemark.Text = dr["note"].ToString();
this.ddlTrack.SelectedValue = dr["tracking_persen"].ToString();
this.ddlIsUse.SelectedValue = dr["is_use"].ToString();
this.txtAddTime.Text = dr["date_time"].ToString();
this.lblAcc.Text = dr["organization"].ToString();
BindDtlAccList(lblAcc.Text);
}
#region 邦定DataList
/// <summary>
/// 邦定DataList
/// </summary>
/// <param name="sourceStr"></param>
private void BindDtlAccList(string sourceStr)
{
DataTable dt = ItemSplit(sourceStr);
if (dt != null)
{
this.dtlAccList.DataSource = dt;
this.dtlAccList.DataBind();
}
}
/// <summary>
/// 分解附件到DataTable
/// </summary>
/// <param name="document">附件的字符串</param>
/// <returns></returns>
private DataTable ItemSplit(string document)
{
if (document == null)
{
return null;
}
string[] documentItems = document.Split('|');
if (documentItems.Length == 0)
{
return null;
}
DataTable accTable = new DataTable();
accTable.Columns.Add("documentName");
accTable.Columns.Add("documentPath");
foreach (string str in documentItems)
{
if (str != null && str.Trim().Length > 0)
{
int charIndex = str.IndexOf(']');
if (charIndex < 0)
{
continue;
}
DataRow row = accTable.NewRow();
string documentName = str.Substring(0, charIndex + 1);
string documentPath = str.Substring(charIndex + 1);
row[0] = documentName;
row[1] = documentPath;
accTable.Rows.Add(row);
}
}
return accTable;
}
#endregion
#region 绑定数据
/// <summary>
/// 绑定客户类型
/// </summary>
private void GetComType()
{
this.BindDictionary(this.ddlComType, "105", true);
}
/// <summary>
/// 绑定关系程度
/// </summary>
private void GetRelation()
{
this.BindDictionary(this.ddlRelation, "104", true);
}
/// <summary>
/// 绑定行业
/// </summary>
private void GetIndustry()
{
this.BindDictionary(this.ddlWay, "106", true);
}
/// <summary>
/// 客户来源
/// </summary>
private void GetComResource()
{
this.BindDictionary(this.ddlComResource, "107", true);
}
/// <summary>
/// 国家
/// </summary>
private void GetNation()
{
this.BindDictionary(this.ddlnation, "108", true);
}
/// <summary>
/// 城市
/// </summary>
private void GetCity()
{
this.BindDictionary(this.ddlCity, "109", true);
}
/// <summary>
/// 公司性质
/// </summary>
private void GetCompanyType()
{
this.BindDictionary(this.ddlCompanyType, "110", true);
}
/// <summary>
/// 公司规模
/// </summary>
private void GetCompanySize()
{
this.BindDictionary(this.ddlCompanySize, "111", true);
}
/// <summary>
/// 跟踪人员
/// </summary>
private void GetTrack()
{
string sql = null;
if (GetSystemRole(this.CurrentUser.account))
{
sql = " SELECT user_id,account,name FROM Users";
}
else
{
sql = " SELECT user_id,account,name FROM Users where account = '" + this.CurrentUser.account + "'";
}
DataTable dt = null;
try
{
dt = dataport.GetTableResult(sql);
}
catch
{
dt = null;
}
if (dt == null || dt.Rows.Count == 0)
{
ddlTrack.DataSource = dt;
ddlTrack.DataBind();
ddlTrack.Items.Add("请选择...");
return;
}
ddlTrack.DataSource = dt;
ddlTrack.DataTextField = "name";
ddlTrack.DataValueField = "user_id";
ddlTrack.DataBind();
ddlTrack.Items.Insert(0, new ListItem("请选择...", "0"));
}
#endregion
/// <summary>
/// 数据验证
/// </summary>
protected bool CheckData()
{
this.msg = String.Empty;
if (this.txtComName.Text.Trim().Replace("'", "\"").Length < 0 || this.txtComName.Text == "")
{
msg += "客户名称不能为空\\r\\n";
}
else
{
if (this.txtComName.Text.Trim().Replace("'", "\"").Length > 50)
{
msg += "客户名称长度填写不能大于50\\r\\n";
}
}
if (this.ddlRelation.SelectedIndex == 0 || this.ddlRelation.SelectedItem.Value.Trim().Length <= 0)
{
msg += "关系程度不能为空\\r\\n";
}
if (this.ddlComType.SelectedIndex == 0 || this.ddlComType.SelectedItem.Value.Trim().Length <= 0)
{
msg += "客户类型不能为空\\r\\n";
}
if (this.ddlTrack.SelectedIndex == 0 || this.ddlTrack.SelectedItem.Value.Trim().Length <= 0)
{
msg += "跟踪人员不能为空\\r\\n";
}
if (this.ddlIsUse.SelectedIndex == 0 || this.ddlIsUse.SelectedItem.Value.Trim().Length <= 0)
{
msg += "有效性不能为空\\r\\n";
}
if (this.txtAdress.Text.Trim().Replace("'", "\"").Length > 50)
{
msg += "详细地址长度填写不能大于50\\r\\n";
}
if (this.txtHomePage.Text.Trim().Replace("'", "\"").Length > 25)
{
msg += "公司主页长度填写不能大于25\\r\\n";
}
if (this.txtRemark.Text.Trim().Replace("'", "\"").Length > 250)
{
msg += "备注长度填写不能大于250\\r\\n";
}
if (this.txtZip.Text.Trim().Replace("'", "\"").Length > 0)
{
if (txtZip.Text.Trim().Replace("'", "\"").Length > 6)
{
msg += "邮编填写必须为6为数字\\r\\n";
}
else
{
String express = @"\d{6}";
System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(express);
System.Text.RegularExpressions.Match match = reg.Match(txtZip.Text.Trim());
if (!match.Success)
{
msg += "邮编必须为6位数字\\r\\n";
}
}
}
if (this.txtCompanyTel.Text.Trim().Replace("'", "\"").Length > 0)
{
String express = @"(\(\d{3}\)|\d{3}-)?\d{8}";
System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(express);
System.Text.RegularExpressions.Match match = reg.Match(txtCompanyTel.Text.Trim());
if (!match.Success)
{
msg += "公司电话填写格式错误\\r\\n";
}
}
if (this.txtFax.Text.Trim().Replace("'", "\"").Length > 0)
{
String express = @"(\(\d{3}\)|\d{3}-)?\d{8}";
System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(express);
System.Text.RegularExpressions.Match match = reg.Match(txtFax.Text.Trim());
if (!match.Success)
{
msg += "公司传真填写格式错误\\r\\n";
}
}
if (this.txtEmail.Text.Trim().Replace("'", "\"").Length > 0)
{
String express = @"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*";
System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(express);
System.Text.RegularExpressions.Match match = reg.Match(txtEmail.Text.Trim());
if (!match.Success)
{
msg += "公司邮件地址填写格式错误\\r\\n";
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -