📄 customer.aspx.cs
字号:
using System;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace NewGlassBook
{
/// <summary>
/// Summary description for lensPrice1.
/// </summary>
public class Customer : MyPage
{
protected NewGlassBook.MyTextBox aAddress;
protected NewGlassBook.MyTextBox aEmail;
protected NewGlassBook.MyTextBox aMobile;
protected NewGlassBook.MyTextBox aTel;
protected NewGlassBook.MyDropDownList aSex;
protected NewGlassBook.MyTextBox aName;
protected NewGlassBook.MyTextBox aPassword;
protected NewGlassBook.MyTextBox aID;
protected System.Web.UI.WebControls.Label lblWarning;
protected NewGlassBook.MyButton dbtnReset;
protected NewGlassBook.MyButton dbtnOk;
Record r=new Record();
private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
{
dbtnOk.Attributes["onClick"]="return customerValid()";//客户端验证
aID.Text=gen();//产生客户编号
aName.Text="";
}
}
string gen()
{
DataSet ds=r.GetData("customer","select top 1 id from customer order by id desc");
if(ds.Tables["customer"].Rows.Count<=0)//没有客户
{
return "00000001";
}
else//客户编号加1
{
String strID=ds.Tables["customer"].Rows[0]["id"].ToString();
String strRight=strID.Substring(0,8);
string l="";
int intTmp=Int32.Parse(strRight);
intTmp++;
for(int i=0;i<8-intTmp.ToString().Length;i++)
{
l=l+"0";
}
strID=l+intTmp.ToString();
return strID;
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.dbtnOk.Click += new System.EventHandler(this.dbtnOk_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void dbtnOk_Click(object sender, System.EventArgs e)
{
if(r.RequestInsert("customer",Request)!=1)//插入客户信息表
{
lblWarning.Text=r.ErrMsg;
}
else
{
aID.Text=gen();//产生客户编号
}
}
private void dbtnReset_Click(object sender, System.EventArgs e)
{
this.ClearTextBox();
aPassword.Text="123456";
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -