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

📄 empdetail.cs

📁 这是该书上的所有源代码,不错
💻 CS
字号:
namespace Employee_Directory
{

    using System;
    using System.Collections;
    using System.ComponentModel;
    using System.Data;
    using System.Data.OleDb;
    using System.Drawing;
    using System.Web;
    using System.Web.SessionState;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls;

	public class EmpDetail : System.Web.UI.Page
	
    { 



//职工信息窗口定义控件的声名
		protected CCUtility Utility;
		
		//职工记录表单、变量等的声名
		protected System.Web.UI.WebControls.Label Record_ValidationSummary;
		protected System.Web.UI.HtmlControls.HtmlInputButton Record_cancel;
		protected System.Web.UI.WebControls.Label Record_emp_id;
		protected System.Web.UI.WebControls.Label Record_name;
		protected System.Web.UI.WebControls.Label Record_title;
		protected System.Web.UI.WebControls.Label Record_dep_id;
		protected System.Web.UI.WebControls.Label Record_email;
		protected System.Web.UI.WebControls.Label Record_work_phone;
		protected System.Web.UI.WebControls.Label Record_cell_phone;
		protected System.Web.UI.WebControls.Label Record_home_phone;
		protected System.Web.UI.WebControls.Label Record_address;
		protected System.Web.UI.WebControls.Label Record_picture;
		
		//定义各表单事件保护字符串
		protected string Record_FormAction="Default.aspx?";
		protected System.Web.UI.HtmlControls.HtmlInputHidden p_Record_emp_id;

//初始化事件	
	public EmpDetail()
	{
	this.Init += new System.EventHandler(Page_Init);
	}
//AdminMenu中的自定义包含控件结束

	public void ValidateNumeric(object source, ServerValidateEventArgs args) {
			try{
				Decimal temp=Decimal.Parse(args.Value);
				args.IsValid=true;
		        }catch{
				args.IsValid=false;	}
		}

//定义登录窗口显示控件过程
//初始化页面过程,创建一个Utility实例,并调用其相应的各方法
        protected void Page_Load(object sender, EventArgs e)
        {	
		Utility=new CCUtility(this);

		if (!IsPostBack){
			
			p_Record_emp_id.Value = Utility.GetParam("emp_id");Page_Show(sender, e);
		}
	}

//页面关闭过程
	protected void Page_Unload(object sender, EventArgs e)
	{
		if(Utility!=null) Utility.DBClose();
	}

//窗口中控件定义事件处理过程
	protected void Page_Init(object sender, EventArgs e)
	{
		InitializeComponent();
	}
        private void InitializeComponent()
        {
		this.Load += new System.EventHandler(this.Page_Load);
		this.Unload += new System.EventHandler(this.Page_Unload);
Record_cancel.ServerClick += new System.EventHandler (this.Record_Action);
		
        }

//定义整体显示页面过程
        protected void Page_Show(object sender, EventArgs e)
        {
		Record_Show();
		
        }



// EmpDetail Show end
//完成表单初始化


//职工信息显示过程
void Record_Show() {
	
	bool ActionInsert=true;
	
	if (p_Record_emp_id.Value.Length > 0 ) {
		string sWhere = "";
		
		sWhere += "emp_id=" + CCUtility.ToSQL(p_Record_emp_id.Value, CCUtility.FIELD_TYPE_Number);
		string sSQL = "select * from emps where " + sWhere;
		OleDbDataAdapter dsCommand = new OleDbDataAdapter(sSQL, Utility.Connection);
		DataSet ds = new DataSet();
		DataRow row;

		if (dsCommand.Fill(ds, 0, 1, "Record") > 0) {
		row = ds.Tables[0].Rows[0];
	//显示数据				
	Record_emp_id.Text =Server.HtmlEncode(CCUtility.GetValue(row, "emp_id").ToString());
	Record_name.Text =Server.HtmlEncode(CCUtility.GetValue(row, "name").ToString());
	Record_title.Text =Server.HtmlEncode(CCUtility.GetValue(row, "title").ToString());
	Record_dep_id.Text =Server.HtmlEncode(	Utility.Dlookup("deps", "name", "dep_id=" + CCUtility.ToSQL(CCUtility.GetValue(row, "dep_id"), CCUtility.FIELD_TYPE_Number)).ToString());
	Record_email.Text =CCUtility.GetValue(row, "email");
	Record_work_phone.Text =Server.HtmlEncode(CCUtility.GetValue(row, "work_phone").ToString());
	Record_cell_phone.Text =Server.HtmlEncode(CCUtility.GetValue(row, "cell_phone").ToString());
	Record_home_phone.Text =Server.HtmlEncode(CCUtility.GetValue(row, "home_phone").ToString());
	Record_address.Text =Server.HtmlEncode(CCUtility.GetValue(row, "address").ToString());
	Record_picture.Text =CCUtility.GetValue(row, "picture");
		ActionInsert=false;
		
	}}

		if(ActionInsert){

		String pValue;

		pValue = Utility.GetParam("name");Record_name.Text = pValue;
		pValue = Utility.GetParam("dep_id");if (pValue.Length>0){Record_dep_id.Text = Utility.Dlookup("deps", "name", "dep_id=" + pValue);}
		pValue = Utility.GetParam("email");Record_email.Text = pValue;
}

//Email的超链接
Record_email.Text="<a href=\"mailto:" + Record_email.Text + "\">" + Record_email.Text + "</a>";
Record_picture.Text="<img border=0 src=\"images/emps/" + Record_picture.Text + "\">";
	}
	

//单击返回按钮事件
void Record_Action(Object Src, EventArgs E) {
bool bResult=true;
if(((HtmlInputButton)Src).ID.IndexOf("cancel")>0) bResult=true;
					

if(bResult)Response.Redirect(Record_FormAction+"dep_id=" + Server.UrlEncode(Utility.GetParam("dep_id")) + "&email=" + Server.UrlEncode(Utility.GetParam("email")) + "&name=" + Server.UrlEncode(Utility.GetParam("name")) + "&");
}
//事件结束



    }
}

⌨️ 快捷键说明

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