CRM客户关系管理系统修改(十四)

修改的流程:

二:获取绑定数据依据

1.通过地址栏传参:Request.Query["ID"]
2.判断Request.Query["ID"]是否为空,如果不为空,则取出数据,用于绑定的条件筛选。
根据ID获取对应的城市:
   /// <summary>
        /// 根据省份ID获取对应的城市
        /// </summary>
        /// <param name="ProvinceID"></param>
        /// <returns></returns>
        public static DataTable getCityListByProvinceID(string ProvinceID)
        {
            SqlParameter[] pars;

            if (ProvinceID == null || ProvinceID == "")
            {
                pars = new SqlParameter[]{
                  new SqlParameter("@tableName","tbCityInfo"),
                  new SqlParameter("@columns"," * "),
                  new SqlParameter("@condition"," 1=1")
                };
            }
            else
            {
                pars = new SqlParameter[]{
                  new SqlParameter("@tableName","tbCityInfo"),
                  new SqlParameter("@columns"," * "),
                  new SqlParameter("@condition"," ProvinceInfoID ="+ProvinceID)
                };
            }

            return DataBaseHelper.SelectSQLReturnDataSet("GetDataByCondition", CommandType.StoredProcedure, pars).Tables[0];
        }

显示的页面:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CustomerListShow.aspx.cs" Inherits="BioErpWeb.CRMSystem.CustomerListShow" %>

<%@ Register assembly="AspNetPager" namespace="Wuqi.Webdiyer" tagprefix="webdiyer" %>

<!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/AspNetPagerStyle.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
    td{ text-align:center;}
    .tdsearch{ line-height:30px;}
    .menubar{ background:url(../Web/images/block_hd_bg.png); height:25px; width:100%;}
    .menubar ul{ margin:0px; padding:0px; list-style:none;}
    .menubar ul li{ display:inline; line-height:25px;}
    .menubar ul li a{display:inline-block;  text-align:center; width:100px; color:#0066CC; text-decoration:none;}

    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div class="menubar">
     <ul>
      <li>
          <asp:HyperLink ID="HyperLink1" NavigateUrl="~/CRMSystem/CustomerListShow.aspx" Target="MainFrame" runat="server">客户资料管理</asp:HyperLink>
      </li>

        <li>
         <asp:HyperLink ID="HyperLink2"  NavigateUrl="~/CRMSystem/LinkManAdd.aspx"  runat="server">客户联系人管理</asp:HyperLink>
      </li>
        <li>
         <asp:HyperLink ID="HyperLink3" runat="server">联系记录管理</asp:HyperLink>
      </li>
        <li>
         <asp:HyperLink ID="HyperLink4" runat="server">客户文档管理</asp:HyperLink>
      </li>
        <li>
         <asp:HyperLink ID="HyperLink5" runat="server">客户反馈信息管理</asp:HyperLink>
      </li>
     </ul>
    </div>
    <div>
         <table class="maintable" style=" width:900px;">
             <tr>
                 <td colspan="5" class="titlebar">
                     客户<span>信息管理系统</span>
                 </td>
             </tr>
             <tr>
                 <td class="tdsearch">
                     <asp:Label ID="Label1" runat="server" Text="客户名称:"></asp:Label>
                     <asp:TextBox ID="txtName" runat="server"></asp:TextBox>
                 </td>
                 <td class="tdsearch">
                     <asp:Label ID="Label2" runat="server" Text="等级"></asp:Label>
                         <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>
                 <td class="tdsearch">
                     <asp:Label ID="Label3" runat="server" Text="客户是否删除"></asp:Label>
                     <asp:DropDownList ID="ddlState" runat="server">
                         <asp:ListItem Value="0">否</asp:ListItem>
                         <asp:ListItem Value="1">是</asp:ListItem>
                     </asp:DropDownList>
                 </td>
                   <td class="tdsearch">
                     <asp:Label ID="Label11" runat="server" Text="省份"></asp:Label>
                           <asp:DropDownList ID="ddlProvince" runat="server" Width="150px">
                                                     </asp:DropDownList>
                 </td>
                 <td class="tdsearch">
                     <asp:ImageButton ID="imgbutnSearch" Width="60" Height="22" runat="server" 
                         ImageUrl="~/Web/images/Btnsearch.gif" onclick="imgbutnSearch_Click" /> 
                     <asp:ImageButton ID="imgbtnNew" runat="server"  Width="60" Height="22" 
                         ImageUrl="~/Web/images/btnadd.gif" onclick="imgbtnNew_Click"/>
                 </td>
             </tr>
             <tr>
                 <td colspan="5" class="bottomtd">
                     <asp:GridView ID="GridView1" Width="100%"  runat="server"  AutoGenerateColumns="False" DataKeyNames="CustomerID">
                         <Columns>                   
                             <asp:TemplateField HeaderText="客户编号" HeaderStyle-HorizontalAlign="Center">
                                 <ItemTemplate>
                                 
                                     <asp:Label ID="Label4" runat="server" Text='<%# Eval("CustomerNumber") %>'></asp:Label>
                                 </ItemTemplate>

<HeaderStyle HorizontalAlign="Center"></HeaderStyle>

                                 <ItemStyle HorizontalAlign="Center" />
                             </asp:TemplateField>
                             <asp:TemplateField HeaderText="客户名称" HeaderStyle-HorizontalAlign="Center">
                                 <ItemTemplate>
                                     <asp:Label ID="Label5" runat="server" Text='<%# Eval("CustomerName") %>'></asp:Label>
                                 </ItemTemplate>
                                 <ItemStyle Width="120px" HorizontalAlign="Center" />

<HeaderStyle HorizontalAlign="Center"></HeaderStyle>

                                 <ItemStyle HorizontalAlign="Center" />
                             </asp:TemplateField>
                             <asp:TemplateField HeaderText="法人代表" HeaderStyle-HorizontalAlign="Center">
                                 <ItemTemplate>
                                      <asp:Label ID="Label6" runat="server" Text='<%# Eval("JuridicalPerson") %>'></asp:Label>
                                 </ItemTemplate>

<HeaderStyle HorizontalAlign="Center"></HeaderStyle>

                                 <ItemStyle HorizontalAlign="Center" />
                             </asp:TemplateField>
                             <asp:TemplateField HeaderText="电话号码" HeaderStyle-HorizontalAlign="Center">
                                 <ItemTemplate>
                                      <asp:Label ID="Label7" runat="server" Text='<%# Eval("Tel1") %>'></asp:Label>
                                 </ItemTemplate>

<HeaderStyle HorizontalAlign="Center"></HeaderStyle>

                                 <ItemStyle HorizontalAlign="Center" />
                             </asp:TemplateField>
                             <asp:TemplateField HeaderText="Email" HeaderStyle-HorizontalAlign="Center">
                                <ItemTemplate>
                                      <asp:Label ID="Label8" runat="server" Text='<%# Eval("Email") %>'></asp:Label>
                                 </ItemTemplate>

<HeaderStyle HorizontalAlign="Center"></HeaderStyle>

                                 <ItemStyle HorizontalAlign="Center" />
                             </asp:TemplateField>
                             <asp:TemplateField HeaderText="客户等级" HeaderStyle-HorizontalAlign="Center">
                                <ItemTemplate>
                                      <asp:Label ID="Label9" runat="server" Text='<%# Eval("CustomerLevel") %>'></asp:Label>
                                 </ItemTemplate>   
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                 <ItemStyle HorizontalAlign="Center" />                          
                             </asp:TemplateField>
                              <asp:TemplateField HeaderText="客户等级" HeaderStyle-HorizontalAlign="Center">
                                <ItemTemplate>
                                      <asp:Label ID="Label9" runat="server" Text='<%# Eval("CustomerLevel") %>'></asp:Label>
                                 </ItemTemplate>   
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                 <ItemStyle HorizontalAlign="Center" />                          
                             </asp:TemplateField>
                             <asp:TemplateField HeaderText="下次联系时间" HeaderStyle-HorizontalAlign="Center">
                                <ItemTemplate>
                                      <asp:Label ID="Label10" runat="server" Text='<%# Convert.ToDateTime(Eval("NextTime")).ToString("yyyy/MM/dd") %>'></asp:Label>
                                 </ItemTemplate>

<HeaderStyle HorizontalAlign="Center"></HeaderStyle>

                                 <ItemStyle HorizontalAlign="Center" />
                             </asp:TemplateField>                      
                             <asp:HyperLinkField DataNavigateUrlFields="CustomerID" 
                                 DataNavigateUrlFormatString="CustomerUpdate.aspx?ID={0}" HeaderText="操作" 
                                 Text="查看并修改客户信息">
                             <HeaderStyle HorizontalAlign="Center" />
                             <ItemStyle HorizontalAlign="Center" />
                             </asp:HyperLinkField>
                         </Columns>
                     </asp:GridView>
                 </td>
             </tr>
             <tr>
              <td  colspan="5">
                  <webdiyer:AspNetPager ID="AspNetPager1" runat="server"   CssClass="paginator" CurrentPageButtonClass="cpb"
                      onpagechanged="AspNetPager1_PageChanged">
                  </webdiyer:AspNetPager>
                 </td>
             </tr>

     </table>

    </div>
    </form>
</body>
</html>

 后台代码:

 public partial class CustomerListShow : System.Web.UI.Page
    {
        
        public static int pageindex = 0;
        public static int pagesize = 10;
        public static string condition = "";

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {

                ddlProvinceBind();
                getallCustomerList();
            }
        }

        /// <summary>
        /// 绑定省份
        /// </summary>
        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";
        }


        /// <summary>
        /// 查询所有员工信息
        /// </summary>
        private void getallCustomerList()
        {
            this.AspNetPager1.RecordCount = SqlComm.getDataCountByCondition("dbo.View_CRMCustomerInfo", condition);
          this.AspNetPager1.PageSize = pagesize;
          this.GridView1.DataSource = SqlComm.getDataByPageIndex("dbo.View_CRMCustomerInfo", "*", "CustomerID", condition, pageindex, pagesize);
          this.GridView1.DataBind();
        }

        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            pageindex = this.AspNetPager1.CurrentPageIndex - 1;
            getallCustomerList();
        }

        protected void imgbutnSearch_Click(object sender, ImageClickEventArgs e)
        {
            pageindex = 0;
            condition = "";
            if (txtName.Text.Trim() != null && this.txtName.Text.Trim().Length != 0)
            {
                condition = condition + " and CustomerName like '" + txtName.Text + "%'";
            }
                     

          
            if (this.ddlState.SelectedValue == "1")
            {
                condition = condition + " and DeleteState ='True'";
            }
            else
            {
                condition = condition + " and DeleteState ='False'";
            }

             condition = condition + " and CustomerLevel='" + this.ddlCustomerLevel.SelectedItem.Text+"' ";

            if (this.ddlProvince.SelectedValue != "0")
            {
                condition = condition +" and Province='"+ this.ddlProvince.SelectedItem.Text+"'";
            }
               
           

            getallCustomerList();


        }

        protected void btnNew_Click(object sender, EventArgs e)
        {

        }

        protected void imgbtnNew_Click(object sender, ImageClickEventArgs e)
        {
            Server.Transfer("CustomerAdd.aspx");
        }

    }

 

 

修改的前台页面:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CustomerUpdate.aspx.cs" Inherits="BioErpWeb.CRMSystem.CustomerUpdate"  %>

<%@ 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 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>
               <asp:DropDownList ID="ddlDelete" runat="server">
                   <asp:ListItem Value="0">否</asp:ListItem>
                   <asp:ListItem Value="1">是</asp:ListItem>
               </asp:DropDownList>
           </td>
       </tr>

          <tr>
           <td> </td><td>
               </td>
           <td> </td><td>
                </td>
       </tr>

          <tr>
           <td>备注:</td><td colspan="3">
              <asp:TextBox ID="txtRemark" runat="server" Rows="2" TextMode="MultiLine" 
                  Width="580px"></asp:TextBox>
              </td>
       </tr>

         <tr>
             <td colspan="4" class="bottomtd">
             
                 <asp:Button ID="btnSubmit" runat="server" Text="客户资料编辑" 
                     onclick="btnSubmit_Click" />
                                  
                 <asp:Button ID="btnReturn" runat="server" Text="返回列表" onclick="btnReturn_Click" 
                     />
             
             </td>
         </tr>

     </table>
        <br />
    </div>
    </form>
</body>
</html>

 后台代码:

 public partial class CustomerUpdate : System.Web.UI.Page
    {

        BioCrmCustomerBLL cbll = new BioCrmCustomerBLL();
        static BioCrmCustomer customer = new BioCrmCustomer();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ddlProvinceBind();
                ddlCityBind();
                pageinfoband();
            }
        }

        /// <summary>
        /// 绑定页面信息
        /// </summary>
        public void pageinfoband()
        {
            if (Request.QueryString["ID"] == null)
            {
                Server.Transfer("CustomerListShow.aspx");
            }
            else
            {
                string id = Request.QueryString["ID"].ToString();
                customer= cbll.GetCustomerByID(id);
                    this.txtCustomerName.Text = customer.CustomerName;            
                    this.txtJuridicalPerson.Text=customer.JuridicalPerson ;
                    this.txtAddress.Text=customer.Address ;
                    this.txtFax.Text=customer.Fax ;
                    this.txtTel1.Text=customer.Tel1  ;
                    this.txtTel2.Text= customer.Tel2  ;
                    this.txtEmail.Text= customer.Email;
                    this.txtWebSite.Text= customer.WebSite;
                    this.txtRegisterTime.Text=   customer.RegisterTime.ToString() ;
                    this.txtUserName.Text=customer.UserID.ToString()  ;
                    this.txtTaxNumber.Text= customer.TaxNumber ;
                    this.txtNextTime.Text=customer.NextTime.ToString();
                    this.ddlState.SelectedItem.Text =  customer.State ;
                    this.ddlState.SelectedItem.Text= customer.Source ;
                    this.ddlCustomerLevel.SelectedItem.Text=   customer.CustomerLevel ;
                    this.ddlProperty.SelectedItem.Text=  customer.Property ;
                    this.ddlType.SelectedItem.Text=  customer.Type ;
                    this.ddlVocation.SelectedItem.Text=customer.Vocation ;
                    this.ddlProvince.SelectedItem.Text=customer.Province;
                    this.ddlCity.SelectedItem.Text=customer.City  ;
                    this.txtBank.Text=customer.Bank  ;
                    this.txtAccounts.Text=customer.Accounts  ;
                    this.txtIntegral.Text=customer.Integral.ToString();
                    this.txtCredit.Text= customer.Credit ;
                    this.txtRemark.Text=customer.Remark  ;
                    this.ddlArea.SelectedValue=customer.Area  ;
                    this.ddlDelete.SelectedValue = customer.DeleteState == true ? "1" : "0";
            }
        }
        //绑定省份信息
        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";
        }

        public void ddlCityBind()
        {
            this.ddlCity.DataSource = SqlComm.getCityListByProvinceID(null);
            this.ddlCity.DataTextField = "CityInfoName";
            this.ddlCity.DataValueField = "CityInfoID";
            this.ddlCity.DataBind();
            this.ddlCity.Items.Add(new ListItem("--请选择城市--", "0"));
            this.ddlCity.SelectedValue = "0";
        }


        protected void btnSubmit_Click(object sender, EventArgs e)
        {
           
            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;
            customer.DeleteState = this.ddlDelete.SelectedValue == "0" ? false : true;
            BioCrmCustomerBLL custormerbll = new BioCrmCustomerBLL();
            if (custormerbll.CustomerUpdate(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();
            }
        }

        protected void btnReturn_Click(object sender, EventArgs e)
        {
            Server.Transfer("CustomerListShow.aspx");
        }  
    }

 

 

posted @ 2016-10-24 21:52  石shi  阅读(341)  评论(0编辑  收藏  举报