📄 employeeallinfo.aspx.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Text;
using System.IO;
public partial class Module_ProRes_EmployeeAllInfo : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Session["UserName"] != null)
{
if (Session["Popedom"].ToString() == "0")
{
this.Panel1.Visible = true;
}
}
else
{
Response.Write("<script language=javascript>top.location.href='../../Index.aspx'</script>");
}
if (!IsPostBack)
{
string cmdtxt = "select * from tb_User where ID='" + Request["ID"].ToString() + "'";
SqlData da = new SqlData();
SqlCommand Com = new SqlCommand(cmdtxt, da.ExceCon());
SqlDataReader dr = Com.ExecuteReader();
dr.Read();
if (dr.HasRows)
{
this.txtUid.Text = dr["UserName"].ToString();
this.txtPwd.Text = dr["PassWord"].ToString();
this.txtPost.Text = dr["Post"].ToString();
this.txtPostCard.Text = dr["PostCard"].ToString();
this.txtAddress.Text = dr["Address"].ToString();
this.txtBirthday.Text = Convert.ToDateTime(dr["Birthday"]).ToString("yyyy-MM-dd");
this.txtIdenCard.Text = dr["IdenCard"].ToString();
this.txtIP.Text = dr["IP"].ToString();
this.txtJobCompanyTime.Text = Convert.ToDateTime(dr["JobCompanyTime"]).ToString("yyyy-MM-dd");
this.txtJobTime.Text = Convert.ToDateTime(dr["JobTime"]).ToString("yyyy-MM-dd");
this.txtLearn.Text = dr["Learn"].ToString();
this.txtName.Text = dr["Name"].ToString();
this.txtNaPlace.Text = dr["NativePlace"].ToString();
this.txtNation.Text = dr["Nation"].ToString();
this.txtPactEnd.Text = Convert.ToDateTime(dr["PactEndTime"]).ToString("yyyy-MM-dd");
this.txtPactStart.Text = Convert.ToDateTime(dr["PactStartTime"]).ToString("yyyy-MM-dd");
this.txtPhoneH.Text = dr["PhoneH"].ToString();
this.txtPhoneJ.Text = dr["PhoneJ"].ToString();
this.txtPhoneM.Text = dr["PhoneM"].ToString();
this.RadioButtonList1.SelectedValue = dr["Sex"].ToString();
this.RadioButtonList2.SelectedValue = dr["IsPost"].ToString();
this.RadioButtonList3.SelectedIndex = Convert.ToInt32(dr["Popedom"].ToString());
this.Image1.ImageUrl = dr["Picture"].ToString();
this.txtDepartment.Text = dr["DepName"].ToString();
}
string cmdtxt1 = "select * from tb_Department";
SqlCommand Com1 = new SqlCommand(cmdtxt1, da.ExceCon());
SqlDataReader dr1 = Com1.ExecuteReader();
while (dr1.Read())
{
this.dropDept.Items.Add(dr1["DepName"].ToString());
}
dr1.Close();
}
}
protected void btnEdit_Click(object sender, EventArgs e)
{
this.txtAddress.ReadOnly = false;
this.txtBirthday.ReadOnly = false;
this.txtIdenCard.ReadOnly = false;
this.txtJobCompanyTime.ReadOnly = false;
this.txtJobTime.ReadOnly = false;
this.txtLearn.ReadOnly = false;
this.txtName.ReadOnly = false;
this.txtNaPlace.ReadOnly = false;
this.txtNation.ReadOnly = false;
this.txtPactEnd.ReadOnly = false;
this.txtPactStart.ReadOnly = false;
this.txtPhoneH.ReadOnly = false;
this.txtPhoneJ.ReadOnly = false;
this.txtPhoneM.ReadOnly = false;
this.txtPost.ReadOnly = false;
this.txtPostCard.ReadOnly = false;
this.txtPwd.ReadOnly = false;
this.txtUid.ReadOnly = false;
this.RadioButtonList1.Enabled = true;
this.RadioButtonList2.Enabled = true;
this.RadioButtonList3.Enabled = true;
this.btnDelete.Enabled = true;
this.btnSave.Enabled = true;
this.Panel2.Visible = false;
this.Panel3.Visible = true;
}
protected void btnDelete_Click(object sender, EventArgs e)
{
string mappath=null ;
string cmdtxt1 = "select * from tb_User where ID='" + Request["ID"].ToString() + "'";
SqlData da = new SqlData();
SqlCommand Com = new SqlCommand(cmdtxt1, da.ExceCon());
SqlDataReader dr = Com.ExecuteReader();
dr.Read();
if (dr.HasRows)
{
mappath = Server.MapPath(dr["Picture"].ToString());
FileInfo file = new FileInfo(mappath);
if (file.Exists)
{
file.Delete();
}
}
string cmdtxt = "DELETE FROM tb_User where ID='" + Request["ID"].ToString() + "'";
if (da.ExceSQL(cmdtxt))
{
Response.Write("<script language=javascript>alert('操作成功!');location='EmployeeInfo.aspx'</script>");
CommonClass.WriteNote(Request["ID"].ToString(), 3, Session["UserName"].ToString());
}
else
{
Response.Write("<script language=javascript>alert('操作失败!');location='javascript:history.go(-1)'</script>");
}
}
protected void btnSave_Click(object sender, EventArgs e)
{
SqlData da = new SqlData();
string cmdtxt = "UPDATE tb_User SET UserName='"+this.txtUid.Text+"',PassWord='"+this.txtPwd.Text+"',Name='"+this.txtName.Text+"'";
cmdtxt +=",Sex='"+this.RadioButtonList1.SelectedValue+"',Birthday='"+this.txtBirthday.Text+"',Learn='"+this.txtLearn.Text+"'";
cmdtxt += ",DepName='" + this.dropDept.SelectedValue + "',Post='" + this.txtPost.Text + "',Address='" + this.txtAddress.Text + "',PhoneH='" + this.txtPhoneH.Text + "'";
cmdtxt += ",PhoneJ='"+this.txtPhoneJ.Text+"',PhoneM='"+this.txtPhoneM.Text+"',IdenCard='"+this.txtIdenCard.Text+"'";
cmdtxt +=",JobTime='"+this.txtJobTime.Text+"',JobCompanyTime='"+this.txtJobCompanyTime.Text+"',NativePlace='"+this.txtNaPlace.Text+"'";
cmdtxt +=",Nation='"+this.txtNation.Text+"',PactStartTime='"+this.txtPactStart.Text+"',PactEndTime='"+this.txtPactEnd.Text+"'";
cmdtxt +=",IsPost='"+this.RadioButtonList2.SelectedValue+"',Popedom='"+this.RadioButtonList3.SelectedIndex+"' where ID='"+Request["ID"].ToString()+"'";
if (da.ExceSQL(cmdtxt))
{
Response.Write("<script language=javascript>alert('操作成功!');location='EmployeeInfo.aspx'</script>");
}
else
{
Response.Write("<script language=javascript>alert('操作失败!');location='javascript:history.go(-1)'</script>");
}
}
protected void btnBack_Click(object sender, EventArgs e)
{
Response.Write("<script>this.parent.rightFrame.location='EmployeeInfo.aspx'</script>");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -