⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 employee.aspx.cs

📁 ASP.NET编写的眼镜行分销系统的程序.
💻 CS
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.IO;
namespace NewGlassBook
{
	/// <summary>
	/// Summary description for employee.
	/// </summary>
	public class Employee : MyPage
	{
		protected System.Web.UI.WebControls.Label lblWarning;
		protected NewGlassBook.MyButton dbtnReset;
		protected NewGlassBook.MyButton dbtnOk;		
		protected NewGlassBook.MyTextBox aTel;
		protected NewGlassBook.MyTextBox aMobile;
		protected NewGlassBook.MyTextBox aAddress;
		protected NewGlassBook.MyTextBox aName;
		protected NewGlassBook.MyTextBox aPassword;
		protected NewGlassBook.MyTextBox aid;
		protected NewGlassBook.MyDropDownList aCompanyID;		
		protected Record r=new Record();//增加Record对象用来访问数据库
		#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 Page_Load(object sender, System.EventArgs e)
		{
			if(!Page.IsPostBack)
			{
				bSubcompanyIDBind();//绑定公司到dropdownlist
				GenID();//生成员工的编号
				dbtnOk.Attributes["onClick"]="return employeeValid();";
			}
		}
		private void GenID()
		{
			DataSet ds=r.GetData("employee","select top 1 id from employee order by id desc");
			string strID=ds.Tables["employee"].Rows[0]["id"].ToString();
			int tempID=Int32.Parse(strID)+1;
			strID=tempID.ToString();
			if(strID.Length==1)
			{
				strID="00"+strID;
			}
			else if(strID.Length==2)
			{
				strID="0"+strID;
			}
			aid.Text=strID;
		}
		private void bSubcompanyIDBind()
		{
			string strSql;
			strSql="select id,id+' | '+companyname as companyname from company where id not like 'f%'";
			DataSet ds=r.GetData("company",strSql);
			aCompanyID.DataValueField="id";
			aCompanyID.DataTextField="companyName";
			aCompanyID.DataSource=ds;
			aCompanyID.DataBind();
			ListItem newitem=new ListItem("请选择公司","0");
			aCompanyID.Items.Insert(0,newitem);
		}
		private void dbtnOk_Click(object sender, System.EventArgs e)
		{
			string strUsername;
			strUsername=aid.Text;
				if(r.RequestInsert("employee",Request)==1)//插入员工信息
				{
					lblWarning.Text=aid.Text+"的信息添加成功!";						
					ClearTextBox();//调用Page类中的方法清空当前页面上的TextBox
					aPassword.Text="123456";
					GenID();
				}
				else
				{
					lblWarning.Text=r.ErrMsg;	
				}			
		}
		private void dbtnReset_Click(object sender, System.EventArgs e)
		{
			ClearTextBox();
			aPassword.Text="123456";
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -