ERP渠道管理添加验证和查询(二十二)
添加联系人的后台代码:
protected void btnSubmit_Click(object sender, EventArgs e) { BioErpCrmManageChannel channel = new BioErpCrmManageChannel() { ChannelName = this.txtChannelName.Text, AccountName = this.txtBank.Text, Accounts = this.txtAccounts.Text, Address = this.txtAddress.Text, Areal = this.ddlArea.SelectedItem.Text, ChannelLevel = this.ddlLevel.Text, ChannelSize = this.ddlChannelSize.SelectedItem.Text, ChannelType = this.ddlType.Text, City = this.ddlCity.SelectedItem.Text, Province = this.ddlProvince.SelectedItem.Text, CoreOperttion = this.txtCoreOperttion.Text, Tel1 = this.txtTel1.Text, Tel2 = this.txtTel2.Text, TaxNumber = this.txtTaxNumber.Text, CoSummary = this.txtCoSummary.Text, Email = this.txtEmail.Text, Fax = this.txtFax.Text, NetAddress = this.txtNextTime.Text, Vocation = this.ddlVocation.SelectedItem.Text, SuperiorChannel = this.txtSuperChannelID.Text == "" ? 0 : int.Parse(this.txtSuperChannelID.Text), UserID = int.Parse(this.txtUserName.Text), NextContactTime = Convert.ToDateTime(this.txtNextTime.Text), Status = this.ddlState.SelectedItem.Text, CreditStanding = this.txtCredit.Text, EnrollTime = Convert.ToDateTime(this.txtRegisterTime.Text) }; BioErpCrmManageChannelBLL channelbll = new BioErpCrmManageChannelBLL(); BioErpCrmChannelLinkManBLL linkmanbll = new BioErpCrmChannelLinkManBLL(); int channelid = channelbll.BioErpCrmManageChannelAdd(channel); //渠道基本信息添加成功,才能添加联系人基本信息 if (channelid != 0) { string linkman = Request["txtLinkMan1"].ToString(); string ddlSex = Request["ddlSex1"].ToString(); string Birthday = Request["txtBirthday1"].ToString(); string MainLink = Request["ddlMainLink1"].ToString(); string OfficePhone = Request["txtOfficePhone"].ToString(); string Mobile = Request["txtOfficePhone"].ToString(); string Email = Request["txtEmail11"].ToString(); string Address = Request["txtAddress1"].ToString(); string QQ = Request["txtQQ1"].ToString(); string Remark = Request["txtRemark1"].ToString(); string[] linkmans = linkman.Split(','); string[] ddlSexs = ddlSex.Split(','); string[] Birthdays = Birthday.Split(','); string[] MainLinks = MainLink.Split(','); string[] OfficePhones = OfficePhone.Split(','); string[] Mobiles = Mobile.Split(','); string[] Emails = Email.Split(','); string[] Addresses = Address.Split(','); string[] QQs = QQ.Split(','); string[] Remarks = Remark.Split(','); BioErpCrmChannelLinkMan linkmanobj = null; for (int i = 0; i < linkmans.Length; i++) { linkmanobj = new BioErpCrmChannelLinkMan() { LinkmanName = linkmans[i], Address = Addresses[i], Email = Emails[i], Remark = Remarks[i], Sex = ddlSexs[i] == "0" ? false : true, QQ = QQs[i].ToString(), OfficialPhone = OfficePhones[i], MobilePhone = Mobiles[i], Birthday = Convert.ToDateTime(Birthdays[i]), ChannelID = channelid, IsMainLinkman = MainLinks[i] == "0" ? false : true }; linkmanbll.BioErpCrmChannelLinkManADD(linkmanobj); } } }
添加的时候字符串的验证:
1.验证的js代码:
// 字符验证 jQuery.validator.addMethod("stringCheck", function(value, element) { return this.optional(element) || /^[\u0391-\uFFE5\w]+$/.test(value); }, "只能包括中文字、英文字母、数字和下划线"); // 中文字两个字节 jQuery.validator.addMethod("byteRangeLength", function(value, element, param) { var length = value.length; for(var i = 0; i < value.length; i++){ if(value.charCodeAt(i) > 127){ length++; } } return this.optional(element) || ( length >= param[0] && length <= param[1] ); }, "请确保输入的值在3-15个字节之间(一个中文字算2个字节)"); // 身份证号码验证 jQuery.validator.addMethod("isIdCardNo", function(value, element) { return this.optional(element) || isIdCardNo(value); }, "请正确输入您的身份证号码"); // 手机号码验证 jQuery.validator.addMethod("isMobile", function(value, element) { var length = value.length; var mobile = /^(((13[0-9]{1})|(15[0-9]{1}))+\d{8})$/; return this.optional(element) || (length == 11 && mobile.test(value)); }, "请正确填写您的手机号码"); // 电话号码验证 jQuery.validator.addMethod("isTel", function(value, element) { var tel = /^\d{3,4}-?\d{7,9}$/; //电话号码格式010-12345678 return this.optional(element) || (tel.test(value)); }, "请正确填写您的电话号码"); // 联系电话(手机/电话皆可)验证 jQuery.validator.addMethod("isPhone", function(value,element) { var length = value.length; var mobile = /^(((13[0-9]{1})|(15[0-9]{1}))+\d{8})$/; var tel = /^\d{3,4}-?\d{7,9}$/; return this.optional(element) || (tel.test(value) || mobile.test(value)); }, "请正确填写您的联系电话"); // 邮政编码验证 jQuery.validator.addMethod("isZipCode", function(value, element) { var tel = /^[0-9]{6}$/; return this.optional(element) || (tel.test(value)); }, "请正确填写您的邮政编码");
2.样式代码:
*{ font-size: 96%; } label{ width: 10em; float: left; } label.error{ float: none; color: red; padding-left: .5em; vertical-align: top; } p{ clear: both; } .submit { margin-left: 12em; } em{ font-weight: bold; padding-right: 1em; vertical-align: top; }
显示的信息:
jQuery.extend( jQuery.validator.messages, { required: "必选字段", remote: "请修正该字段", email: "请输入正确格式的电子邮件", url: "请输入合法的网址", date: "请输入合法的日期", dateISO: "请输入合法的日期 (如:2011-11-02).", number: "请输入合法的数字", digits: "只能输入整数", creditcard: "请输入合法的信用卡号", equalTo: "请再次输入相同的值", accept: "请输入拥有合法后缀名的字符串", maxlength: $.validator.format("请输入一个长度最多是 {0} 的字符串"), minlength: $.validator.format("请输入一个长度最少是 {0} 的字符串"), rangelength: $.validator.format("请输入一个长度介于 {0} 和 {1} 之间的字符串"), range: $.validator.format("请输入一个介于 {0} 和 {1} 之间的值"), max: $.validator.format("请输入一个最大为 {0} 的值"), min: $.validator.format("请输入一个最小为 {0} 的值") });
在前端js中调用:
<script type="text/javascript"> $(document).ready(function () { $("#form1").validate(); var i = 0; jQuery("#btnAddNew").click(function () { i++; tr = ''; tr = tr + ' <tr id="tr' + i + '">'; tr = tr + ' <td><input name="txtLinkMan1" MaxLength="10"></input></td>'; tr = tr + ' <td>'; tr = tr + ' <select name="ddlSex1" > <option Value="0">男</option> <option Value="1">女</option></select>'; tr = tr + ' </td>'; tr = tr + ' <td>'; tr = tr + ' <input name="txtBirthday1" onfocus="setday(this)" onclick="setday(this)" MaxLength="20"></input></td>'; tr = tr + ' <td><select name="ddlMainLink1"> <option Value="1">是</option> <option Value="0">否</option> </select></td>'; tr = tr + ' <td> <input name="txtOfficePhone" MaxLength="20" ></input></td>'; tr = tr + ' <td> <input name="txtMobile1" MaxLength="20" ></input></td>'; tr = tr + ' <td> <input name="txtEmail11" MaxLength="20"></input></td>'; tr = tr + ' <td> <input name="txtAddress1" MaxLength="50" ></input></td>'; tr = tr + ' <td> <input name="txtQQ1" MaxLength="15"></input></td>'; tr = tr + ' <td> <input name="txtRemark1" MaxLength="200"></input></td>'; tr = tr + ' </tr>'; $("#caption").before(tr); }); jQuery("#btnDelete").click(function () { $("#tr" + i).remove(); i--; }); }); </script>
验证的时候添加:
<td>渠道名</td><td><asp:TextBox ID="txtChannelName" CssClass="required" runat="server"></asp:TextBox></td>
查询的代码:
在数据库中定义视图:
CREATE VIEW [dbo].[View_CRMChannelInfo] AS SELECT ChannelID, ChannelName,SuperiorChannelID=SuperiorChannel, SuperiorChannel=ISNULL(dbo.getFatherChannelNamebyFatherID(SuperiorChannel),'一级渠道') ,Tel1,Tel2,Email,Fax,NextContactTime=ISNULL(NextContactTime,'1970-1-1'),LinkMans=dbo.GetUserListByChannelID(ChannelID), UserID,DeleteState,UserName=dbo.getUserNameByUserID(UserID), Address,ChannelLevel,NetAddress,CreditStanding,EnrollTime= ISNULL(EnrollTime,'1970-1-1'), ChannelSize,Vocation,ChannelType,Status,Areal,Province,City, TaxNumber,AccountName,Accounts,CoSummary,CoreOperttion FROM dbo.BioErpCrmManageChannel
SELECT CONVERT(nvarchar(10),getdate(),102)
自定义函数的定义:
-- ============================================= -- Description: 根据渠道编号获取渠道联系人姓名 -- ============================================= ALTER FUNCTION [dbo].[GetUserListByChannelID] ( @ChannelID int ) RETURNS nvarchar(200) AS BEGIN declare cur cursor for SELECT LinkmanName FROM BioErpCrmChannelLinkMan WHERE ChannelID =@ChannelID open cur DECLARE @name nvarchar(20) DECLARE @names nvarchar(1000) SET @names='' FETCH next FROM cur INTO @name WHILE @@FETCH_STATUS =0 BEGIN SET @names=@names+@name+',' FETCH next FROM cur INTO @name END CLOSE cur DEALLOCATE cur RETURN @names END
自定义函数:
-- ============================================= -- Description:根据上级渠道编号查询对应上级渠道名称 -- ============================================= ALTER FUNCTION [dbo].[getFatherChannelNamebyFatherID] ( @FatherID int ) RETURNS nvarchar(20) AS BEGIN -- Declare the return variable here DECLARE @fatherChannelName nvarchar(20) -- Add the T-SQL statements to compute the return value here SELECT @fatherChannelName=ChannelName FROM dbo.BioErpCrmManageChannel WHERE ChannelID=@FatherID -- Return the result of the function RETURN @fatherChannelName END
前端代码:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ChannelListShow.aspx.cs" Inherits="BioErpWeb.CRMSystem.CrmChannel.ChannelListShow" %> <%@ Register assembly="AspNetPager" namespace="Wuqi.Webdiyer" tagprefix="webdiyer" %> <%@ Register src="../../UserControl/CRMChannelMenuBar.ascx" tagname="CRMChannelMenuBar" tagprefix="uc1" %> <!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> <uc1:CRMChannelMenuBar ID="CRMChannelMenuBar1" runat="server" /> </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="ChannelID"> <Columns> <asp:TemplateField HeaderText="渠道编号" HeaderStyle-HorizontalAlign="Center"> <ItemTemplate> <asp:Label ID="Label4" runat="server" Text='<%# Eval("ChannelID") %>'></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("ChannelName") %>'></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="Label9" runat="server" Text='<%# Eval("SuperiorChannel") %>'></asp:Label> </ItemTemplate> <HeaderStyle HorizontalAlign="Center"></HeaderStyle> <ItemStyle HorizontalAlign="Center" /> </asp:TemplateField> <asp:TemplateField HeaderText="渠道联系人" HeaderStyle-HorizontalAlign="Center"> <ItemTemplate> <asp:Label ID="Label6" runat="server" Text='<%# Eval("LinkMans") %>'></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")+" "+Eval("Tel2") %>'></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("Fax") %>'></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("NextContactTime")).ToString("yyyy/MM/dd") %>'></asp:Label> </ItemTemplate> <HeaderStyle HorizontalAlign="Center"></HeaderStyle> <ItemStyle HorizontalAlign="Center" /> </asp:TemplateField> <asp:HyperLinkField DataNavigateUrlFields="ChannelID" 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 static int pageindex = 0; public static int pagesize = 10; public static string condition = ""; protected void Page_Load(object sender, EventArgs e) { //if (UserLogin.user.RoleId != 6 && UserLogin.user.RoleId != 7) //{ // Response.Write("<script>window.history.back()</script>"); // //Response.Redirect("../Web/Desk.aspx"); // //Server.Transfer("../Web/Desk.aspx"); // return; //} Session["Userid"] = "29"; 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() { //如果是市场部经理,或客服部经理可以查看所有 if (UserLogin.user.RoleId == 6 || UserLogin.user.RoleId == 7) { this.AspNetPager1.RecordCount = SqlComm.getDataCountByCondition("dbo.View_CRMChannelInfo", condition); this.AspNetPager1.PageSize = pagesize; this.GridView1.DataSource = SqlComm.getDataByPageIndex("dbo.View_CRMChannelInfo", "*", "ChannelID", condition, pageindex, pagesize); this.GridView1.DataBind(); } else //员工只能看自己的客户信息 { condition = condition + " and userid=" + Session["Userid"].ToString(); this.AspNetPager1.RecordCount = SqlComm.getDataCountByCondition("dbo.View_CRMChannelInfo", condition); this.AspNetPager1.PageSize = pagesize; this.GridView1.DataSource = SqlComm.getDataByPageIndex("dbo.View_CRMChannelInfo", "*", "ChannelID", 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 imgbtnNew_Click(object sender, ImageClickEventArgs e) { Server.Transfer("CustomerAdd.aspx"); }
查询的后台的代码:
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 ChannelName like '" + txtName.Text + "%'"; } if (this.ddlState.SelectedValue == "1") { condition = condition + " and DeleteState ='True'"; } else { condition = condition + " and DeleteState ='False'"; } getallCustomerList(); }
调用视图生成的实体类:
private int _channelid; private string _channelname; private int? _superiorchannelid; private string _superiorchannel; private string _tel1; private string _tel2; private string _email; private string _fax; private DateTime _nextcontacttime; private string _linkmans; private int? _userid; private bool? _deletestate; private string _username; private string _address; private string _channellevel; private string _netaddress; private string _creditstanding; private DateTime? _enrolltime; private string _channelsize; private string _vocation; private string _channeltype; private string _status; private string _areal; private string _province; private string _city; private string _taxnumber; private string _accountname; private string _accounts; private string _cosummary; private string _coreoperttion; /// <summary> /// /// </summary> public int ChannelID { set{ _channelid=value;} get{return _channelid;} } /// <summary> /// /// </summary> public string ChannelName { set{ _channelname=value;} get{return _channelname;} } /// <summary> /// /// </summary> public int? SuperiorChannelID { set{ _superiorchannelid=value;} get{return _superiorchannelid;} } /// <summary> /// /// </summary> public string SuperiorChannel { set{ _superiorchannel=value;} get{return _superiorchannel;} } /// <summary> /// /// </summary> public string Tel1 { set{ _tel1=value;} get{return _tel1;} } /// <summary> /// /// </summary> public string Tel2 { set{ _tel2=value;} get{return _tel2;} } /// <summary> /// /// </summary> public string Email { set{ _email=value;} get{return _email;} } /// <summary> /// /// </summary> public string Fax { set{ _fax=value;} get{return _fax;} } /// <summary> /// /// </summary> public DateTime NextContactTime { set{ _nextcontacttime=value;} get{return _nextcontacttime;} } /// <summary> /// /// </summary> public string LinkMans { set{ _linkmans=value;} get{return _linkmans;} } /// <summary> /// /// </summary> public int? UserID { set{ _userid=value;} get{return _userid;} } /// <summary> /// /// </summary> public bool? DeleteState { set{ _deletestate=value;} get{return _deletestate;} } /// <summary> /// /// </summary> public string UserName { set{ _username=value;} get{return _username;} } /// <summary> /// /// </summary> public string Address { set{ _address=value;} get{return _address;} } /// <summary> /// /// </summary> public string ChannelLevel { set{ _channellevel=value;} get{return _channellevel;} } /// <summary> /// /// </summary> public string NetAddress { set{ _netaddress=value;} get{return _netaddress;} } /// <summary> /// /// </summary> public string CreditStanding { set{ _creditstanding=value;} get{return _creditstanding;} } /// <summary> /// /// </summary> public DateTime? EnrollTime { set{ _enrolltime=value;} get{return _enrolltime;} } /// <summary> /// /// </summary> public string ChannelSize { set{ _channelsize=value;} get{return _channelsize;} } /// <summary> /// /// </summary> public string Vocation { set{ _vocation=value;} get{return _vocation;} } /// <summary> /// /// </summary> public string ChannelType { set{ _channeltype=value;} get{return _channeltype;} } /// <summary> /// /// </summary> public string Status { set{ _status=value;} get{return _status;} } /// <summary> /// /// </summary> public string Areal { set{ _areal=value;} get{return _areal;} } /// <summary> /// /// </summary> public string Province { set{ _province=value;} get{return _province;} } /// <summary> /// /// </summary> public string City { set{ _city=value;} get{return _city;} } /// <summary> /// /// </summary> public string TaxNumber { set{ _taxnumber=value;} get{return _taxnumber;} } /// <summary> /// /// </summary> public string AccountName { set{ _accountname=value;} get{return _accountname;} } /// <summary> /// /// </summary> public string Accounts { set{ _accounts=value;} get{return _accounts;} } /// <summary> /// /// </summary> public string CoSummary { set{ _cosummary=value;} get{return _cosummary;} } /// <summary> /// /// </summary> public string CoreOperttion { set{ _coreoperttion=value;} get{return _coreoperttion;} }
BLL层代码:
/// <summary> /// 根据渠道编号返回渠道的视图对象 /// </summary> /// <param name="id"></param> /// <returns>ViewCRMChannelInfo</returns> public ViewCRMChannelInfo BioErpCrmManagerChannelViewByID(string id) { SqlDataReader reader=SqlComm.GetDataReaderByCondition("View_CRMChannelInfo", "*", " ChannelID=" + id); ViewCRMChannelInfo viewchannel=null; while (reader.Read()) { viewchannel = new ViewCRMChannelInfo() { AccountName = reader["AccountName"].ToString(), Accounts = reader["Accounts"].ToString(), Address = reader["Address"].ToString(), Areal = reader["Areal"].ToString(), ChannelID = int.Parse(reader["ChannelID"].ToString()), ChannelLevel = reader["ChannelLevel"].ToString(), ChannelName = reader["ChannelName"].ToString(), ChannelSize = reader["ChannelSize"].ToString(), ChannelType = reader["ChannelType"].ToString(), City = reader["City"].ToString(), CoreOperttion = reader["CoreOperttion"].ToString(), CoSummary = reader["CoSummary"].ToString(), CreditStanding = reader["CreditStanding"].ToString(), DeleteState = Convert.ToBoolean(reader["DeleteState"].ToString()), Email = reader["Email"].ToString(), EnrollTime = Convert.ToDateTime(reader["EnrollTime"].ToString()), Fax = reader["Fax"].ToString(), LinkMans = reader["LinkMans"].ToString(), NetAddress = reader["NetAddress"].ToString(), NextContactTime = Convert.ToDateTime(reader["NextContactTime"].ToString()), Province = reader["Province"].ToString(), Status = reader["Status"].ToString(), SuperiorChannel = reader["SuperiorChannel"].ToString(), SuperiorChannelID = int.Parse(reader["SuperiorChannelID"].ToString()), TaxNumber = reader["TaxNumber"].ToString(), Tel1 = reader["Tel1"].ToString(), Tel2 = reader["Tel2"].ToString(), UserID = int.Parse(reader["UserID"].ToString()), UserName = reader["UserName"].ToString(), Vocation = reader["Vocation"].ToString() }; } reader.Close(); return viewchannel; }
前端代码:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ChannelDetail.aspx.cs" Inherits="BioErpWeb.CRMSystem.CrmChannel.ChannelDetail" %> <!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="../../JS/ChannelChoose.js" type="text/javascript"></script> <script src="../../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script> <script src="../../Scripts/jquery.validate.js" type="text/javascript"></script> <script src="../../Scripts/validateExtender.js" type="text/javascript"></script> <script src="../../Scripts/ValidateMessage_ZW.js" type="text/javascript"></script> <script src="../../Scripts/cld.js" type="text/javascript"></script> <style type="text/css"> .style1 { height: 22px; } .style4 { width: 114px; } .linkmantable{ width:100%; border:solid 1px; border-collapse:collapse; } .linkmantable td{ border:solid 1px ;} .linkmantable input{ width:70px;} </style> <script type="text/javascript"> $(document).ready(function () { $("#form1").validate(); var i = 0; jQuery("#btnAddNew").click(function () { i++; tr = ''; tr = tr + ' <tr id="tr' + i + '">'; tr = tr + ' <td><input name="txtLinkMan1" MaxLength="10"></input></td>'; tr = tr + ' <td>'; tr = tr + ' <select name="ddlSex1" > <option Value="0">男</option> <option Value="1">女</option></select>'; tr = tr + ' </td>'; tr = tr + ' <td>'; tr = tr + ' <input name="txtBirthday1" onfocus="setday(this)" onclick="setday(this)" MaxLength="20"></input></td>'; tr = tr + ' <td><select name="ddlMainLink1"> <option Value="1">是</option> <option Value="0">否</option> </select></td>'; tr = tr + ' <td> <input name="txtOfficePhone" MaxLength="20" ></input></td>'; tr = tr + ' <td> <input name="txtMobile1" MaxLength="20" ></input></td>'; tr = tr + ' <td> <input name="txtEmail11" MaxLength="20"></input></td>'; tr = tr + ' <td> <input name="txtAddress1" MaxLength="50" ></input></td>'; tr = tr + ' <td> <input name="txtQQ1" MaxLength="15"></input></td>'; tr = tr + ' <td> <input name="txtRemark1" MaxLength="200"></input></td>'; tr = tr + ' </tr>'; $("#caption").before(tr); }); jQuery("#btnDelete").click(function () { $("#tr" + i).remove(); i--; }); }); </script> </head> <body> <form id="form1" runat="server"> <div style=" width:960px; margin:0px auto; height:550px; overflow:scroll;"> <table class="maintable" style=" width:900px;"> <tr> <td colspan="4" class="titlebar">渠道详细信息浏览</td> </tr> <tr> <td>渠道名</td><td><asp:Label ID="txtChannelName" runat="server"></asp:Label></td> <td>上级渠道</td><td><asp:Label ID="txtSuperChannelID" runat="server"></asp:Label> </td> </tr> <tr> <td>注册时间</td><td><asp:Label ID="txtRegisterTime" runat="server"></asp:Label> </td> <td>渠道规模</td><td><asp:Label ID="ddlChannelSize" runat="server"></asp:Label> </td> </tr> <tr> <td>开户银行</td><td><asp:Label ID="txtBank" runat="server"></asp:Label></td> <td>银行账号</td><td><asp:Label ID="txtAccounts" runat="server"></asp:Label> </td> </tr> <tr> <td>公司网址</td><td><asp:Label ID="txtWebSite" runat="server"></asp:Label></td> <td>企业地址</td><td><asp:Label ID="txtAddress" runat="server"></asp:Label></td> </tr> <tr> <td>Email邮件</td><td><asp:Label ID="txtEmail" runat="server"></asp:Label></td> <td>传真</td><td><asp:Label ID="txtFax" runat="server"></asp:Label></td> </tr> <tr> <td>电话号码1</td><td><asp:Label ID="txtTel1" runat="server"></asp:Label></td> <td>电话号码2</td><td><asp:Label ID="txtTel2" runat="server"></asp:Label></td> </tr> <tr> <td>渠道等级</td><td> <asp:Label ID="ddlLevel" CssClass="isTel" runat="server"></asp:Label> </td> <td>信用级别</td><td><asp:Label ID="txtCredit" runat="server"></asp:Label></td> </tr> <tr> <td>税号</td><td><asp:Label ID="txtTaxNumber" runat="server"></asp:Label></td> <td>下次联系时间</td><td><asp:Label ID="txtNextTime" runat="server"></asp:Label> </td> </tr> <tr> <td>客户状态</td><td><asp:Label ID="ddlState" runat="server"></asp:Label> </td> <td>所属区域</td><td> <asp:Label ID="ddlArea" runat="server"></asp:Label> </td> </tr> <tr> <td class="style1">客户类型</td><td class="style1"> <asp:Label ID="ddlType" runat="server"></asp:Label> </td> <td class="style1">所属行业</td><td class="style1"> <asp:Label ID="ddlVocation" runat="server"></asp:Label> </td> </tr> <tr> <td> 省份 </td> <td> <asp:Label ID="ddlProvince" runat="server"></asp:Label> </td> <td class="style4">城市</td> <td> <asp:Label ID="ddlCity" runat="server"></asp:Label> </td> </tr> <tr> <td>所属代表</td><td><asp:Label ID="txtUserName" CssClass="required" runat="server"></asp:Label></td> <td> </td><td> </td> </tr> <tr> <td>公司概要:</td><td colspan="3"> <asp:Label ID="txtCoSummary" runat="server" Rows="2" TextMode="MultiLine" Width="580px"></asp:Label> </td> </tr> <tr> <td>主要业务:</td><td colspan="3"> <asp:Label ID="txtCoreOperttion" runat="server" Rows="2" TextMode="MultiLine" Width="580px"></asp:Label> </td> </tr> <tr> <td colspan="4"> <asp:GridView ID="GridView1" Width="100%" runat="server"> </asp:GridView> </td> </tr> <tr> <td colspan="4" class="bottomtd"> <asp:Button ID="btnSubmit" runat="server" Text="渠道资料编辑" onclick="btnSubmit_Click" /> </td> </tr> </table> </div> </form> </body> </html>
后端代码:
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { pageInfobind(); } } private void pageInfobind() { if (Request.QueryString["ID"] == null) { Response.Redirect("ChannelListShow.aspx"); return; } string channelid = Request.QueryString["ID"].ToString(); ViewCRMChannelInfo viewchannel=new ViewCRMChannelInfo(); BioErpCrmManageChannelBLL channelbll=new BioErpCrmManageChannelBLL(); viewchannel= channelbll.BioErpCrmManagerChannelViewByID(channelid); this.txtChannelName.Text = viewchannel.ChannelName; this.txtSuperChannelID.Text = viewchannel.SuperiorChannel; if (viewchannel.NextContactTime.ToString() != "1970/1/1 0:00:00") { this.txtNextTime.Text = viewchannel.NextContactTime.ToString(); } if (viewchannel.EnrollTime.ToString() != "1970/1/1 0:00:00") { this.txtRegisterTime.Text = viewchannel.EnrollTime.ToString(); } this.ddlChannelSize.Text = viewchannel.ChannelSize.ToString(); this.txtAccounts.Text = viewchannel.Accounts; this.txtBank.Text = viewchannel.Accounts; this.txtWebSite.Text = viewchannel.NetAddress; this.txtAddress.Text = viewchannel.Address; this.txtEmail.Text = viewchannel.Email; this.txtFax.Text=viewchannel.Fax; this.txtTel1.Text=viewchannel.Tel1; this.txtTel2.Text=viewchannel.Tel2; this.ddlLevel.Text=viewchannel.ChannelLevel; this.txtCredit.Text=viewchannel.CreditStanding; this.txtTaxNumber.Text=viewchannel.TaxNumber; this.ddlState.Text=viewchannel.Status; this.ddlType.Text=viewchannel.ChannelType; this.ddlVocation.Text=viewchannel.Vocation; this.ddlProvince.Text=viewchannel.Province; this.ddlCity.Text=viewchannel.City; this.txtUserName.Text=viewchannel.UserName; this.ddlArea.Text=viewchannel.Areal; this.txtCoSummary.Text=viewchannel.CoSummary; this.txtCoreOperttion.Text=viewchannel.CoreOperttion; this.GridView1.DataSource = SqlComm.GetDataByCondition("ViewCrmChannelLinkManInfo", "*", " 渠道编号="+viewchannel.ChannelID); this.GridView1.DataBind(); }
联系人渠道:
CREATE VIEW [dbo].[ViewCrmChannelLinkManInfo] AS SELECT LinkmanID AS '编号', ChannelID AS '渠道编号', LinkmanName '联系人', '性别'=CASE Sex WHEN 1 THEN '女' ELSE '男' END, Birthday '生日', '是否主联系人'=CASE IsMainLinkman WHEN 1 THEN '是' ELSE'否' END, OfficialPhone '办公电话', MobilePhone '个人手机', Email 'Email', Address '地址', QQ , Remark '备注', '是否删除'=CASE DeleteState WHEN 1 THEN '是' ELSE'否' END FROM BioErpCrmChannelLinkMan GO