customer.aspx.cs

来自「ASP.NET编写的眼镜行分销系统的程序.」· CS 代码 · 共 100 行

CS
100
字号
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 + =
减小字号Ctrl + -
显示快捷键?