CRM客户关系管理系统(十三)
—客户资料添加
1.事件流程:
-----增加的存储过程 ALTER PROCEDURE [dbo].[BioCrmCustomer_ADD] @CustomerName nvarchar(100), @JuridicalPerson nvarchar(100), @Address nvarchar(100), @Tel1 nvarchar(20), @Tel2 nvarchar(20), @Fax nvarchar(20), @Email nvarchar(100), @WebSite nvarchar(100), @RegisterTime datetime, @UserID int, @CustomerLevel nvarchar(50), @NextTime datetime, @Source nvarchar(100), @Type nvarchar(100), @Vocation nvarchar(100), @State nvarchar(50), @Property nvarchar(100), @Area nvarchar(100), @Province nvarchar(20), @City nvarchar(100), @Bank nvarchar(50), @Accounts nvarchar(100), @TaxNumber nvarchar(100), @Credit nvarchar(100), @Integral int, @Remark nvarchar(200) AS INSERT INTO [BioCrmCustomer]( [CustomerName],[JuridicalPerson],[Address],[Tel1],[Tel2],[Fax],[Email],[WebSite],[RegisterTime],[UserID],[CustomerLevel],[NextTime],[Source],[Type],[Vocation],[State],[Property],[Area],[Province],[City],[Bank],[Accounts],[TaxNumber],[Credit],[Integral],[Remark] )VALUES( @CustomerName,@JuridicalPerson,@Address,@Tel1,@Tel2,@Fax,@Email,@WebSite,@RegisterTime,@UserID,@CustomerLevel,@NextTime,@Source,@Type,@Vocation,@State,@Property,@Area,@Province,@City,@Bank,@Accounts,@TaxNumber,@Credit,@Integral,@Remark )
修改的存储过程:
ALTER PROCEDURE [dbo].[BioCrmCustomer_Update] @CustomerID int, @CustomerNumber nvarchar(80), @CustomerName nvarchar(100), @JuridicalPerson nvarchar(100), @Address nvarchar(100), @Tel1 nvarchar(20), @Tel2 nvarchar(20), @Fax nvarchar(20), @Email nvarchar(100), @WebSite nvarchar(100), @RegisterTime datetime, @UserID int, @CustomerLevel nvarchar(50), @NextTime datetime, @Source nvarchar(100), @Type nvarchar(100), @Vocation nvarchar(100), @State nvarchar(50), @Property nvarchar(100), @Area nvarchar(100), @Province nvarchar(20), @City nvarchar(100), @Bank nvarchar(50), @Accounts nvarchar(100), @TaxNumber nvarchar(100), @Credit nvarchar(100), @Integral int, @Remark nvarchar(200), @DeleteState bit AS
---- UPDATE [BioCrmCustomer] SET [CustomerNumber] = @CustomerNumber,[CustomerName] = @CustomerName,[JuridicalPerson]
= @JuridicalPerson,[Address] = @Address,[Tel1] = @Tel1,[Tel2] = @Tel2,[Fax] = @Fax,[Email]
= @Email,[WebSite] = @WebSite,[RegisterTime] = @RegisterTime,[UserID] = @UserID,[CustomerLevel]
= @CustomerLevel,[NextTime] = @NextTime,[Source] = @Source,[Type] = @Type,[Vocation] = @Vocation,[State]
= @State,[Property] = @Property,[Area] = @Area,[Province] = @Province,[City] = @City,[Bank] = @Bank,[Accounts]
= @Accounts,[TaxNumber] = @TaxNumber,[Credit] = @Credit,[Integral] = @Integral,[Remark]
= @Remark,[DeleteState] = @DeleteState WHERE CustomerID=@CustomerID
BLL层的代码:
public class BioCrmCustomerBLL { /// <summary> /// 添加一个客户资料 /// </summary> /// <param name="customer">BioCrmCustomer</param> /// <returns>int</returns> public int CustomerAdd(BioCrmCustomer customer) { SqlParameter[] parameters = { new SqlParameter("@CustomerName", SqlDbType.NVarChar,100), new SqlParameter("@JuridicalPerson", SqlDbType.NVarChar,100), new SqlParameter("@Address", SqlDbType.NVarChar,100), new SqlParameter("@Tel1", SqlDbType.NVarChar,20), new SqlParameter("@Tel2", SqlDbType.NVarChar,20), new SqlParameter("@Fax", SqlDbType.NVarChar,20), new SqlParameter("@Email", SqlDbType.NVarChar,100), new SqlParameter("@WebSite", SqlDbType.NVarChar,100), new SqlParameter("@RegisterTime", SqlDbType.DateTime), new SqlParameter("@UserID", SqlDbType.Int,4), new SqlParameter("@CustomerLevel", SqlDbType.NVarChar,50), new SqlParameter("@NextTime", SqlDbType.DateTime), new SqlParameter("@Source", SqlDbType.NVarChar,100), new SqlParameter("@Type", SqlDbType.NVarChar,100), new SqlParameter("@Vocation", SqlDbType.NVarChar,100), new SqlParameter("@State", SqlDbType.NVarChar,50), new SqlParameter("@Property", SqlDbType.NVarChar,100), new SqlParameter("@Area", SqlDbType.NVarChar,100), new SqlParameter("@Province", SqlDbType.NVarChar,20), new SqlParameter("@City", SqlDbType.NVarChar,100), new SqlParameter("@Bank", SqlDbType.NVarChar,50), new SqlParameter("@Accounts", SqlDbType.NVarChar,100), new SqlParameter("@TaxNumber", SqlDbType.NVarChar,100), new SqlParameter("@Credit", SqlDbType.NVarChar,100), new SqlParameter("@Integral", SqlDbType.Int,4), new SqlParameter("@Remark", SqlDbType.NVarChar,200), }; parameters[0].Value = customer.CustomerName; parameters[1].Value = customer.JuridicalPerson; parameters[2].Value = customer.Address; parameters[3].Value = customer.Tel1; parameters[4].Value = customer.Tel2; parameters[5].Value = customer.Fax; parameters[6].Value = customer.Email; parameters[7].Value = customer.WebSite; parameters[8].Value = customer.RegisterTime; parameters[9].Value = customer.UserID; parameters[10].Value = customer.CustomerLevel; parameters[11].Value = customer.NextTime; parameters[12].Value = customer.Source; parameters[13].Value = customer.Type; parameters[14].Value = customer.Vocation; parameters[15].Value = customer.State; parameters[16].Value = customer.Property; parameters[17].Value = customer.Area; parameters[18].Value = customer.Province; parameters[19].Value = customer.City; parameters[20].Value = customer.Bank; parameters[21].Value = customer.Accounts; parameters[22].Value = customer.TaxNumber; parameters[23].Value = customer.Credit; parameters[24].Value = customer.Integral; parameters[25].Value = customer.Remark; return DataBaseHelper.ExcuteSqlReturnInt("BioCrmCustomer_ADD", CommandType.StoredProcedure, parameters); } /// <summary> /// 修改客户资料 /// </summary> /// <param name="model"></param> /// <returns></returns> public int CustomerUpdate(BioCrmCustomer model) { SqlParameter[] parameters = { new SqlParameter("@CustomerID", SqlDbType.Int,4), new SqlParameter("@CustomerNumber", SqlDbType.NVarChar,80), new SqlParameter("@CustomerName", SqlDbType.NVarChar,100), new SqlParameter("@JuridicalPerson", SqlDbType.NVarChar,100), new SqlParameter("@Address", SqlDbType.NVarChar,100), new SqlParameter("@Tel1", SqlDbType.NVarChar,20), new SqlParameter("@Tel2", SqlDbType.NVarChar,20), new SqlParameter("@Fax", SqlDbType.NVarChar,20), new SqlParameter("@Email", SqlDbType.NVarChar,100), new SqlParameter("@WebSite", SqlDbType.NVarChar,100), new SqlParameter("@RegisterTime", SqlDbType.DateTime), new SqlParameter("@UserID", SqlDbType.Int,4), new SqlParameter("@CustomerLevel", SqlDbType.NVarChar,50), new SqlParameter("@NextTime", SqlDbType.DateTime), new SqlParameter("@Source", SqlDbType.NVarChar,100), new SqlParameter("@Type", SqlDbType.NVarChar,100), new SqlParameter("@Vocation", SqlDbType.NVarChar,100), new SqlParameter("@State", SqlDbType.NVarChar,50), new SqlParameter("@Property", SqlDbType.NVarChar,100), new SqlParameter("@Area", SqlDbType.NVarChar,100), new SqlParameter("@Province", SqlDbType.NVarChar,20), new SqlParameter("@City", SqlDbType.NVarChar,100), new SqlParameter("@Bank", SqlDbType.NVarChar,50), new SqlParameter("@Accounts", SqlDbType.NVarChar,100), new SqlParameter("@TaxNumber", SqlDbType.NVarChar,100), new SqlParameter("@Credit", SqlDbType.NVarChar,100), new SqlParameter("@Integral", SqlDbType.Int,4), new SqlParameter("@Remark", SqlDbType.NVarChar,200), new SqlParameter("@DeleteState", SqlDbType.Bit,1)}; parameters[0].Value = model.CustomerID; parameters[1].Value = model.CustomerNumber; parameters[2].Value = model.CustomerName; parameters[3].Value = model.JuridicalPerson; parameters[4].Value = model.Address; parameters[5].Value = model.Tel1; parameters[6].Value = model.Tel2; parameters[7].Value = model.Fax; parameters[8].Value = model.Email; parameters[9].Value = model.WebSite; parameters[10].Value = model.RegisterTime; parameters[11].Value = model.UserID; parameters[12].Value = model.CustomerLevel; parameters[13].Value = model.NextTime; parameters[14].Value = model.Source; parameters[15].Value = model.Type; parameters[16].Value = model.Vocation; parameters[17].Value = model.State; parameters[18].Value = model.Property; parameters[19].Value = model.Area; parameters[20].Value = model.Province; parameters[21].Value = model.City; parameters[22].Value = model.Bank; parameters[23].Value = model.Accounts; parameters[24].Value = model.TaxNumber; parameters[25].Value = model.Credit; parameters[26].Value = model.Integral; parameters[27].Value = model.Remark; parameters[28].Value = model.DeleteState; return DataBaseHelper.ExcuteSqlReturnInt("BioCrmCustomer_Update", CommandType.StoredProcedure, parameters); } /// <summary> /// 根据客户id获取客户信息 /// </summary> /// <param name="id">id</param> /// <returns>BioCrmCustomer</returns> public BioCrmCustomer GetCustomerByID(string id) { SqlDataReader reader= SqlComm.GetDataReaderByCondition("BioCrmCustomer", "*", " CustomerID=" + id); BioCrmCustomer customer = new BioCrmCustomer(); while (reader.Read()) { customer.CustomerID = int.Parse(reader["CustomerID"].ToString()); customer.CustomerNumber = reader["CustomerNumber"].ToString(); customer.CustomerName= reader["CustomerNumber"].ToString(); customer.JuridicalPerson = reader["JuridicalPerson"].ToString(); customer.Address = reader["Address"].ToString(); customer.Tel1 = reader["Tel1"].ToString(); customer.Tel2 = reader["Tel2"].ToString(); customer.Fax = reader["Fax"].ToString(); customer.Email = reader["Email"].ToString(); customer.WebSite = reader["WebSite"].ToString(); customer.RegisterTime =Convert.ToDateTime(reader["RegisterTime"].ToString()); customer.UserID = int.Parse(reader["UserID"].ToString()); customer.CustomerLevel = reader["CustomerLevel"].ToString(); customer.NextTime =Convert.ToDateTime(reader["NextTime"].ToString()); customer.Source = reader["Source"].ToString(); customer.Type = reader["Type"].ToString(); customer.Vocation = reader["Vocation"].ToString(); customer.State = reader["State"].ToString(); customer.Property = reader["Property"].ToString(); customer.Area = reader["Area"].ToString(); customer.Province = reader["Province"].ToString(); customer.City = reader["City"].ToString(); customer.Bank = reader["Bank"].ToString(); customer.Accounts = reader["Accounts"].ToString(); customer.TaxNumber = reader["TaxNumber"].ToString(); customer.Credit = reader["Credit"].ToString(); customer.Integral =int.Parse( reader["Integral"].ToString()); customer.Remark = reader["Remark"].ToString(); customer.DeleteState =Convert.ToBoolean(reader["DeleteState"].ToString()); } reader.Close(); return customer; } }
获取省份的代码:
/// <summary> /// 获取省份列表 /// </summary> /// <returns></returns> public static DataTable getProvinceInfoList() { SqlParameter[] pars = new SqlParameter[]{ new SqlParameter("@tableName","tbProvinceInfo"), new SqlParameter("@columns","*") }; return DataBaseHelper.SelectSQLReturnDataSet("getDataByTableNameValue", CommandType.StoredProcedure, pars).Tables[0]; } /// <summary> /// 根据省份ID获取对应的城市 /// </summary> /// <param name="ProvinceID"></param> /// <returns></returns> public static DataTable getCityListByProvinceID(string ProvinceID) { SqlParameter[] pars = new SqlParameter[]{ new SqlParameter("@tableName","tbCityInfo"), new SqlParameter("@columns"," * "), new SqlParameter("@condition"," ProvinceInfoID ="+ProvinceID) }; return DataBaseHelper.SelectSQLReturnDataSet("GetDataByCondition", CommandType.StoredProcedure, pars).Tables[0]; }
存储过程:
ALTER PROCEDURE [dbo].[getDataByTableNameValue] @tableName nvarchar(500), @columns nvarchar(2000) AS BEGIN SET NOCOUNT ON; DECLARE @Sql nvarchar(4000) SET @Sql=\'select \'+@columns+\' from \'+@tableName EXEC(@Sql) END ----根据指定列,指定条件,指定表查询数据 ALTER PROCEDURE [dbo].[GetDataByCondition] @tableName nvarchar(200), @columns nvarchar(500), @condition nvarchar(500)=\' 1=1\' AS BEGIN SET NOCOUNT ON; DECLARE @sqlStr nvarchar(2000) SET @sqlStr=\'select \'+@columns+\' from \'+@tableName+\' where \'+@condition EXEC(@sqlStr) END
触发器的定义:
触发器是一种DBMS响应特殊表或列的INSERT,UPDATE,DELETE操作的特殊类型的存储过程
自动生成客户编号的触发器:
SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER TRIGGER [dbo].[CreateCustomerNoByCustomerID] ON [dbo].[BioCrmCustomer] AFTER INSERT AS BEGIN DECLARE @str nvarchar(10) DECLARE @CustomerNo nvarchar(50) DECLARE @CustomerID nvarchar(50) SET @str=\'0000000\' SELECT @CustomerID=MAX(CustomerID) FROM dbo.BioCrmCustomer SET @CustomerNo=RIGHT(@str+@CustomerID,7) UPDATE dbo.BioCrmCustomer SET CustomerNumber=@CustomerNo WHERE CustomerID=@CustomerID end
添加的前台页面:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CustomerAdd.aspx.cs" Inherits="BioErpWeb.CRMSystem.CustomerAdd" %> <%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <link href="../Styles/ERPBaseStyle.css" rel="stylesheet" type="text/css" /> <link href="../Styles/CalenderStyle.css" rel="stylesheet" type="text/css" /> <script src="../JS/CheckUserName.js" type="text/javascript"></script> <script src="../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script> <style type="text/css"> .style1 { height: 22px; } .style3 { width: 252px; } .style4 { width: 94px; } .style5 { width: 71px; } </style> <script type="text/javascript"> $(document).ready(function () { $("#btnSubmit").click(function () { var customer = $("#txtCustomerName"); if (customer.val() == \'\') { alert(\'必须填写客户名称\'); return false; } var JuridicalPerson = $("#txtJuridicalPerson"); if (JuridicalPerson.val() == \'\') { alert(\'必须填写法人代表\'); return false; } var txtRegisterTime = $("#txtRegisterTime"); if (txtRegisterTime.val() == \'\') { alert(\'公司注册时间必须填写\'); txtRegisterTime.focus(); return false; } var txtNextTime = $("#txtNextTime"); if (txtNextTime.val() == \'\') { alert(\'下次联系时间必须填写\'); txtNextTime.focus(); return false; } var txtUserName = $("#txtUserName"); if (txtUserName.val() == \'\') { alert(\'所属销售代表\'); txtRegisterTime.focus(); return false; } var ddlProvince = $("#ddlProvince"); var selectCaption = ddlProvince.select(); if (selectCaption.val() == 0) { alert("请选择所属省份"); ddlProvince.focus(); return false; } var ddlCity = $("#ddlCity"); var selectCityCaption = ddlCity.select(); if (selectCityCaption.val() ==\'\') { alert("请选择所属城市"); ddlCity.focus(); return false; } var txtIntegral = $("#txtIntegral"); if (txtIntegral.val() == \'\') { alert(\'请填写用户积分\'); txtIntegral.focus(); return false; } return true; }); }); </script> </head> <body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <div> <table class="maintable"> <tr> <td colspan="4" class="titlebar"><span>客户信息添加</span></td> </tr> <tr> <td>客户名</td><td><asp:TextBox ID="txtCustomerName" runat="server"></asp:TextBox></td> <td>法人代表</td><td><asp:TextBox ID="txtJuridicalPerson" runat="server"></asp:TextBox></td> </tr> <tr> <td>企业地址</td><td><asp:TextBox ID="txtAddress" runat="server"></asp:TextBox></td> <td>传真</td><td><asp:TextBox ID="txtFax" runat="server"></asp:TextBox></td> </tr> <tr> <td>电话号码1</td><td><asp:TextBox ID="txtTel1" runat="server"></asp:TextBox></td> <td>电话号码2</td><td><asp:TextBox ID="txtTel2" runat="server"></asp:TextBox></td> </tr> <tr> <td>Email邮件</td><td><asp:TextBox ID="txtEmail" runat="server"></asp:TextBox></td> <td>公司网址</td><td><asp:TextBox ID="txtWebSite" runat="server"></asp:TextBox></td> </tr> <tr> <td>注册时间</td><td><asp:TextBox ID="txtRegisterTime" runat="server"></asp:TextBox> <cc1:CalendarExtender ID="ceRegisterTime" TargetControlID="txtRegisterTime" Format="yyyy-MM-dd" runat="server"> </cc1:CalendarExtender> </td> <td>所属销售代表</td><td><asp:TextBox ID="txtUserName" runat="server"></asp:TextBox><input type="button" style=" width:60px" value="选择" onclick="showDialog()"/></td> </tr> <tr> <td>税号</td><td><asp:TextBox ID="txtTaxNumber" runat="server"></asp:TextBox></td> <td>下次联系时间</td><td><asp:TextBox ID="txtNextTime" runat="server"></asp:TextBox> <cc1:CalendarExtender ID="ceNextTime" TargetControlID="txtNextTime" Format="yyyy-MM-dd" runat="server"> </cc1:CalendarExtender> </td> </tr> <tr> <td>客户状态</td><td> <asp:DropDownList ID="ddlState" runat="server"> <asp:ListItem>良好</asp:ListItem> <asp:ListItem>一般</asp:ListItem> </asp:DropDownList> </td> <td>客户来源</td><td> <asp:DropDownList ID="ddlSource" runat="server"> <asp:ListItem>国内</asp:ListItem> <asp:ListItem>国外</asp:ListItem> </asp:DropDownList> </td> </tr> <tr> <td class="style1">客户类型</td><td class="style1"> <asp:DropDownList ID="ddlType" runat="server"> <asp:ListItem>国有</asp:ListItem> <asp:ListItem>民营</asp:ListItem> <asp:ListItem>外资</asp:ListItem> <asp:ListItem>合资</asp:ListItem> <asp:ListItem>个体</asp:ListItem> </asp:DropDownList> </td> <td class="style1">所属行业</td><td class="style1"> <asp:DropDownList ID="ddlVocation" runat="server"> <asp:ListItem>制造</asp:ListItem> <asp:ListItem>服务</asp:ListItem> <asp:ListItem>教育</asp:ListItem> <asp:ListItem>医疗</asp:ListItem> </asp:DropDownList> </td> </tr> <tr> <td>客户性质</td><td> <asp:DropDownList ID="ddlProperty" runat="server"> <asp:ListItem>高端客户</asp:ListItem> <asp:ListItem>中端客户</asp:ListItem> <asp:ListItem>低端客户</asp:ListItem> </asp:DropDownList> </td> <td>客户等级</td><td> <asp:DropDownList ID="ddlCustomerLevel" runat="server"> <asp:ListItem>一级</asp:ListItem> <asp:ListItem>二级</asp:ListItem> <asp:ListItem>三级</asp:ListItem> <asp:ListItem>四级</asp:ListItem> </asp:DropDownList> </td> </tr> <tr> <td colspan="4"> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <table style=" width:100%; border:0px;"> <tr> <td class="style5">省份</td><td class="style3"> <asp:DropDownList ID="ddlProvince" runat="server" Width="150px" AutoPostBack="True" onselectedindexchanged="ddlProvince_SelectedIndexChanged"> </asp:DropDownList> </td> <td class="style4">城市</td> <td> <asp:DropDownList ID="ddlCity" Width="150px" runat="server"> </asp:DropDownList> </td> </tr> </table> </ContentTemplate> </asp:UpdatePanel> </td> </tr> <tr> <td>开户银行</td><td><asp:TextBox ID="txtBank" runat="server"></asp:TextBox></td> <td>银行账号</td><td><asp:TextBox ID="txtAccounts" runat="server"></asp:TextBox></td> </tr> <tr> <td>积分</td><td><asp:TextBox ID="txtIntegral" runat="server"></asp:TextBox></td> <td>信用级别</td><td><asp:TextBox ID="txtCredit" runat="server"></asp:TextBox></td> </tr> <tr> <td>所属区域</td><td> <asp:DropDownList ID="ddlArea" runat="server" Width="150px" > <asp:ListItem>东</asp:ListItem> <asp:ListItem>西</asp:ListItem> <asp:ListItem>南</asp:ListItem> <asp:ListItem>北</asp:ListItem> </asp:DropDownList> </td> <td> </td><td> </td> </tr> <tr> <td>备注:</td><td colspan="3"> <asp:TextBox ID="txtRemark" runat="server" Rows="5" TextMode="MultiLine" Width="580px"></asp:TextBox> </td> </tr> <tr> <td colspan="4" class="bottomtd"> <asp:Button ID="btnSubmit" runat="server" Text="客户资料添加" onclick="btnSubmit_Click" /> </td> </tr> </table> <br /> </div> </form> </body> </html>
后台代码:
public partial class CustomerAdd : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ddlProvinceBind(); } } public void ddlProvinceBind() { this.ddlProvince.DataSource = SqlComm.getProvinceInfoList(); this.ddlProvince.DataTextField = "ProvinceInfoName"; this.ddlProvince.DataValueField = "ProvinceInfoID"; this.ddlProvince.DataBind(); this.ddlProvince.Items.Add(new ListItem("--请选择省份--","0")); this.ddlProvince.SelectedValue="0"; } protected void btnSubmit_Click(object sender, EventArgs e) { BioCrmCustomer customer = new BioCrmCustomer(); customer.CustomerName = this.txtCustomerName.Text; customer.JuridicalPerson = this.txtJuridicalPerson.Text; customer.Address = this.txtAddress.Text; customer.Fax = this.txtFax.Text; customer.Tel1 = this.txtTel1.Text; customer.Tel2 = this.txtTel2.Text; customer.Email = this.txtEmail.Text; customer.WebSite = this.txtWebSite.Text; customer.RegisterTime = Convert.ToDateTime(this.txtRegisterTime.Text); customer.UserID = int.Parse(this.txtUserName.Text); customer.TaxNumber = this.txtTaxNumber.Text; customer.NextTime = Convert.ToDateTime(this.txtNextTime.Text); customer.State= this.ddlState.SelectedItem.Text; customer.Source = this.ddlState.SelectedItem.Text; customer.CustomerLevel = this.ddlCustomerLevel.SelectedItem.Text; customer.Property = this.ddlProperty.SelectedItem.Text; customer.Type = this.ddlType.SelectedItem.Text; customer.Vocation = this.ddlVocation.SelectedItem.Text; customer.Province = this.ddlProvince.SelectedItem.Text; customer.City = this.ddlCity.SelectedItem.Text; customer.Bank = this.txtBank.Text; customer.Accounts = this.txtAccounts.Text; customer.Integral =int.Parse(this.txtIntegral.Text.Trim()); customer.Credit = this.txtCredit.Text; customer.Remark = this.txtRemark.Text; customer.Area = this.ddlArea.SelectedValue; BioCrmCustomerBLL custormerbll = new BioCrmCustomerBLL(); if (custormerbll.CustomerAdd(customer) != 0) { ScriptManager.RegisterStartupScript(this, this.GetType(), "test", "alert(\'添加成功\')", true); Server.Transfer("CustomerListShow.aspx"); } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "test", "alert(\'添加失败\')", true); Server.Transfer("CustomerListShow.aspx"); } } protected void ddlProvince_SelectedIndexChanged(object sender, EventArgs e) { if (this.ddlProvince.SelectedValue != "0") { string ProvinceId = this.ddlProvince.SelectedValue.ToString(); ddlCity.DataSource = SqlComm.getCityListByProvinceID(ProvinceId); ddlCity.DataTextField = "CityInfoName"; ddlCity.DataValueField = "CityInfoID"; ddlCity.DataBind(); } } }