?? empdetail.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_emp_No;
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;
//定義各表單事件保護(hù)字符串
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中的自定義包含控件結(jié)束
public void ValidateNumeric(object source, ServerValidateEventArgs args) {
try{
Decimal temp=Decimal.Parse(args.Value);
args.IsValid=true;
}catch{
args.IsValid=false; }
}
//定義登錄窗口顯示控件過程
//初始化頁面過程,創(chuàng)建一個Utility實例,并調(diào)用其相應(yīng)的各方法
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);
}
}
//頁面關(guān)閉過程
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];
//顯示數(shù)據(jù)
Record_emp_id.Text =Server.HtmlEncode(CCUtility.GetValue(row, "emp_id").ToString());
Record_name.Text =Server.HtmlEncode(CCUtility.GetValue(row, "name").ToString());
Record_emp_No.Text =Server.HtmlEncode(CCUtility.GetValue(row, "emp_No").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")) + "&");
}
//事件結(jié)束
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -