employee_show.aspx.cs
资源名称:web.rar [点击查看]
上传用户:xrffrp
上传日期:2022-03-25
资源大小:22155k
文件大小:17k
源码类别:
OA系统
开发平台:
ASP/ASPX
- 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;
- public partial class web_personnel_employee_show : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- LoginDAO.CheckLogin(Session, Response, "../../", 2);
- if (!IsPostBack)
- {
- if (Request.QueryString["edit"]!=null)
- {
- BtnOk.Enabled = false;
- BtnEdit.Enabled = false;
- }
- if (Request.QueryString["e_id"] != null)
- {
- this.SetValue(Request.QueryString["e_id"]);
- }
- }
- }
- protected void SetValue(string id)
- {
- this.SetBasic(id);
- this.SetFamily(id);
- this.SetBackGround(id);
- this.SetEducation(id);
- this.SetWork(id);
- this.SetSkill(id);
- }
- //員工基本信息
- protected void SetBasic(string id)
- {
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand cmd = new SqlCommand("select e.emp_no, e.emp_name, e.login_name, d.name department_name, "+
- "g.name [group], p.name position, e.nation, e.marriage, e.id_card, e.native, e.stature, e.address, "+
- "e.linkman, e.tel, e.registered_address, e.active_date, e.dimission_date, e.sex, e.birth_date, "+
- "e.id_card_expire, e.email_work, e.email_personal, e.smart_phone, e.tel_extension, e.work_card_no1, "+
- "e.link_man_tel, e.photo_save_name, e.work_place, e.work_card_no2 ,e.q_manger "+
- "from OA_EMPLOYEE e inner join OA_DEPARTMENT d on e.department_id=d.id inner join OA_USER_GROUP_MAIN g "+
- "on e.user_group=g.id inner join OA_EMPLOYEE_POSITION p on e.position=p.id where e.id="+id, conn);
- SqlDataReader dr = cmd.ExecuteReader();
- if (dr.Read())
- {
- LblNo.Text = dr["emp_no"].ToString();
- LblName.Text = dr["emp_name"].ToString();
- LblTitle.Text = LblName.Text + "員工履歷表";
- LblLoginName.Text = dr["login_name"].ToString();
- LblDepartment.Text = dr["department_name"].ToString();
- LblGroup.Text = dr["group"].ToString();
- LblPosition.Text = dr["position"].ToString();
- LblNation.Text = dr["nation"].ToString();
- string marriage = dr["marriage"].ToString();
- if (marriage.Equals("1"))
- {
- LblMarriage.Text = "未婚";
- }
- if (marriage.Equals("2"))
- {
- LblMarriage.Text = "已婚";
- }
- if (marriage.Equals("3"))
- {
- LblMarriage.Text = "離異";
- }
- LblIdCard.Text = dr["id_card"].ToString();
- LblNative.Text = dr["native"].ToString();
- LblStature.Text = dr["stature"].ToString();
- LblAddress.Text = dr["address"].ToString();
- LblLinkman.Text = dr["linkman"].ToString();
- LblTel.Text = dr["tel"].ToString();
- LblRegisteredAddress.Text = dr["registered_address"].ToString();
- LblActiveDate.Text = dr["active_date"].ToString();
- LblDimissionDate.Text = dr["dimission_date"].ToString();
- if (dr["sex"].ToString().Equals("M"))
- {
- LblSex.Text = "男";
- }
- else
- {
- LblSex.Text = "女";
- }
- if (dr["q_manger"].ToString().Equals("1"))
- {
- Lblmanger.Text = "主管";
- }
- else
- {
- Lblmanger.Text = "非主管";
- }
- LblBirthDate.Text = dr["birth_date"].ToString();
- LblIdCardExpire.Text = dr["id_card_expire"].ToString();
- LblMailWork.Text = dr["email_work"].ToString();
- LblMailPersonal.Text = dr["email_personal"].ToString();
- LblSmartPhone.Text = dr["smart_phone"].ToString();
- LblTelExtension.Text = dr["tel_extension"].ToString();
- LblWorkCardNo1.Text = dr["work_card_no1"].ToString();
- LblWorkCardNo2.Text = dr["work_card_no2"].ToString();
- LblLinkmanTel.Text = dr["link_man_tel"].ToString();
- LblWorkPlace.Text = dr["work_place"].ToString();
- if (!dr["photo_save_name"].ToString().Equals(""))
- {
- EmpPhoto.ImageUrl = "../employee_photo/" + dr["photo_save_name"].ToString();
- }
- }
- dr.Close();
- conn.Close();
- }
- //家庭情況
- protected void SetFamily(string id)
- {
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand cmd = new SqlCommand("select family_name, [relative], age, tel, company from OA_EMPLOYEE_FAMILY where emp_id="+id, conn);
- SqlDataReader dr = cmd.ExecuteReader();
- int index = 1;
- while (dr.Read())
- {
- if (index == 1)
- {
- LblFamilyName1.Text = dr["family_name"].ToString();
- LblRelative1.Text = dr["relative"].ToString();
- LblAge1.Text = dr["age"].ToString();
- LblTel1.Text = dr["tel"].ToString();
- LblCompany1.Text = dr["company"].ToString();
- }
- if (index == 2)
- {
- LblFamilyName2.Text = dr["family_name"].ToString();
- LblRelative2.Text = dr["relative"].ToString();
- LblAge2.Text = dr["age"].ToString();
- LblTel2.Text = dr["tel"].ToString();
- LblCompany2.Text = dr["company"].ToString();
- }
- if (index == 3)
- {
- LblFamilyName3.Text = dr["family_name"].ToString();
- LblRelative3.Text = dr["relative"].ToString();
- LblAge3.Text = dr["age"].ToString();
- LblTel3.Text = dr["tel"].ToString();
- LblCompany3.Text = dr["company"].ToString();
- }
- if (index == 4)
- {
- LblFamilyName4.Text = dr["family_name"].ToString();
- LblRelative4.Text = dr["relative"].ToString();
- LblAge4.Text = dr["age"].ToString();
- LblTel4.Text = dr["tel"].ToString();
- LblCompany4.Text = dr["company"].ToString();
- }
- index = index + 1;
- }
- dr.Close();
- conn.Close();
- }
- //背景
- protected void SetBackGround(string id)
- {
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand cmd = new SqlCommand("select back_name, [relative], job, tel, company from OA_EMPLOYEE_BACKGROUND where emp_id="+id, conn);
- SqlDataReader dr = cmd.ExecuteReader();
- int index = 1;
- while (dr.Read())
- {
- if (index == 1)
- {
- LblBackName1.Text = dr["back_name"].ToString();
- LblBackRelative1.Text = dr["relative"].ToString();
- LblBackJob1.Text = dr["job"].ToString();
- LblBackTel1.Text = dr["tel"].ToString();
- LblBackCompany1.Text = dr["company"].ToString();
- }
- if (index == 2)
- {
- LblBackName2.Text = dr["back_name"].ToString();
- LblBackRelative2.Text = dr["relative"].ToString();
- LblBackJob2.Text = dr["job"].ToString();
- LblBackTel2.Text = dr["tel"].ToString();
- LblBackCompany2.Text = dr["company"].ToString();
- }
- index = index + 1;
- }
- dr.Close();
- conn.Close();
- }
- //教育經歷
- protected void SetEducation(string id)
- {
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand cmd = new SqlCommand("select begin_year, begin_month, end_year, end_month, school, subject, "+
- "grade from OA_EMPLOYEE_EDUCATION where emp_id=" + id, conn);
- SqlDataReader dr = cmd.ExecuteReader();
- int index = 1;
- while (dr.Read())
- {
- if (index == 1)
- {
- LblEdBeginYear1.Text = dr["begin_year"].ToString();
- LblEdBeginMonth1.Text = dr["begin_month"].ToString();
- LblEdEndYear1.Text = dr["end_year"].ToString();
- LblEdEndMonth1.Text = dr["end_month"].ToString();
- LblSchoolName1.Text = dr["school"].ToString();
- LblSubject1.Text = dr["subject"].ToString();
- LblGrade1.Text = dr["grade"].ToString();
- }
- if (index == 2)
- {
- LblEdBeginYear2.Text = dr["begin_year"].ToString();
- LblEdBeginMonth2.Text = dr["begin_month"].ToString();
- LblEdEndYear2.Text = dr["end_year"].ToString();
- LblEdEndMonth2.Text = dr["end_month"].ToString();
- LblSchoolName2.Text = dr["school"].ToString();
- LblSubject2.Text = dr["subject"].ToString();
- LblGrade2.Text = dr["grade"].ToString();
- }
- if (index == 3)
- {
- LblEdBeginYear3.Text = dr["begin_year"].ToString();
- LblEdBeginMonth3.Text = dr["begin_month"].ToString();
- LblEdEndYear3.Text = dr["end_year"].ToString();
- LblEdEndMonth3.Text = dr["end_month"].ToString();
- LblSchoolName3.Text = dr["school"].ToString();
- LblSubject3.Text = dr["subject"].ToString();
- LblGrade3.Text = dr["grade"].ToString();
- }
- if (index == 4)
- {
- LblEdBeginYear4.Text = dr["begin_year"].ToString();
- LblEdBeginMonth4.Text = dr["begin_month"].ToString();
- LblEdEndYear4.Text = dr["end_year"].ToString();
- LblEdEndMonth4.Text = dr["end_month"].ToString();
- LblSchoolName4.Text = dr["school"].ToString();
- LblSubject4.Text = dr["subject"].ToString();
- LblGrade4.Text = dr["grade"].ToString();
- }
- index = index + 1;
- }
- dr.Close();
- conn.Close();
- }
- //工作經歷
- protected void SetWork(string id)
- {
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand cmd = new SqlCommand("select begin_year, begin_month, end_year, end_month, company, tel, "+
- "salary, dimission_reason from OA_EMPLOYEE_JOB where emp_id=" + id, conn);
- SqlDataReader dr = cmd.ExecuteReader();
- int index = 1;
- while (dr.Read())
- {
- if (index == 1)
- {
- LblWorkBeginYear1.Text = dr["begin_year"].ToString();
- LblWorkBeginMonth1.Text = dr["begin_month"].ToString();
- LblWorkEndYear1.Text = dr["end_year"].ToString();
- LblWorkEndMonth1.Text = dr["end_month"].ToString();
- LblWorkCompany1.Text = dr["company"].ToString();
- LblWorkTel1.Text = dr["tel"].ToString();
- LblWorkSalary1.Text = dr["salary"].ToString();
- LblDimissionReason1.Text = dr["dimission_reason"].ToString();
- }
- if (index == 2)
- {
- LblWorkBeginYear2.Text = dr["begin_year"].ToString();
- LblWorkBeginMonth2.Text = dr["begin_month"].ToString();
- LblWorkEndYear2.Text = dr["end_year"].ToString();
- LblWorkEndMonth2.Text = dr["end_month"].ToString();
- LblWorkCompany2.Text = dr["company"].ToString();
- LblWorkTel2.Text = dr["tel"].ToString();
- LblWorkSalary2.Text = dr["salary"].ToString();
- LblDimissionReason2.Text = dr["dimission_reason"].ToString();
- }
- if (index == 3)
- {
- LblWorkBeginYear3.Text = dr["begin_year"].ToString();
- LblWorkBeginMonth3.Text = dr["begin_month"].ToString();
- LblWorkEndYear3.Text = dr["end_year"].ToString();
- LblWorkEndMonth3.Text = dr["end_month"].ToString();
- LblWorkCompany3.Text = dr["company"].ToString();
- LblWorkTel3.Text = dr["tel"].ToString();
- LblWorkSalary3.Text = dr["salary"].ToString();
- LblDimissionReason3.Text = dr["dimission_reason"].ToString();
- }
- if (index == 4)
- {
- LblWorkBeginYear4.Text = dr["begin_year"].ToString();
- LblWorkBeginMonth4.Text = dr["begin_month"].ToString();
- LblWorkEndYear4.Text = dr["end_year"].ToString();
- LblWorkEndMonth4.Text = dr["end_month"].ToString();
- LblWorkCompany4.Text = dr["company"].ToString();
- LblWorkTel4.Text = dr["tel"].ToString();
- LblWorkSalary4.Text = dr["salary"].ToString();
- LblDimissionReason4.Text = dr["dimission_reason"].ToString();
- }
- index = index + 1;
- }
- dr.Close();
- conn.Close();
- }
- //專業技能
- protected void SetSkill(string id)
- {
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand cmd = new SqlCommand("select [language],computer_grade,certificate,other from OA_EMPLOYEE_SKILL where emp_id="+id, conn);
- SqlDataReader dr = cmd.ExecuteReader();
- if (dr.Read())
- {
- LblLanguage.Text = dr["language"].ToString();
- LblComputerGrade.Text = dr["computer_grade"].ToString();
- LblCertificate.Text = dr["certificate"].ToString();
- LblOther.Text = dr["other"].ToString();
- }
- dr.Close();
- conn.Close();
- }
- protected void BtnOk_Click(object sender, EventArgs e)
- {
- if (Request.QueryString["e_id"] != null)
- {
- Response.Redirect("employee_edit.aspx?e_id="+Request.QueryString["e_id"]);
- }
- }
- protected void BtnEdit_Click(object sender, EventArgs e)
- {
- BtnEdit.Visible = false;
- BtnUpload.Visible = true;
- FileUpload1.Visible = true;
- }
- protected void BtnUpload_Click(object sender, EventArgs e)
- {
- DateMgr mgr = new DateMgr();
- string time = mgr.getTime();
- if (this.uploadFile(time) && Request.QueryString["e_id"] != null)
- {
- string save_name = FileUpload1.FileName.Substring(0, FileUpload1.FileName.Length - 4) + time + System.IO.Path.GetExtension(FileUpload1.FileName).ToLower();
- string name = FileUpload1.FileName;
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand cmd = new SqlCommand("update OA_EMPLOYEE set photo_name='" + name +
- "', photo_save_name='" + save_name + "' where id=" + Request.QueryString["e_id"], conn);
- cmd.ExecuteNonQuery();
- conn.Close();
- Response.Write("<script language='javascript'>alert('上傳檔案成功');</script>");
- // EmpPhoto.ImageUrl = Server.MapPath("~/web/employee_photo/") + save_name;
- EmpPhoto.ImageUrl = "../employee_photo/" + save_name;
- BtnEdit.Visible = true;
- BtnUpload.Visible = false;
- FileUpload1.Visible = false;
- }
- }
- protected bool uploadFile(string time)
- {
- bool flag = false;
- string directory = Server.MapPath("../employee_photo/");
- if (FileUpload1.HasFile)
- {
- bool extenstion = false;
- string fileExtension = System.IO.Path.GetExtension(FileUpload1.FileName).ToLower();
- string[] allowedExtensions =
- { ".gif", ".jpg" };
- for (int i = 0; i < allowedExtensions.Length; i++)
- {
- if (fileExtension == allowedExtensions[i])
- {
- extenstion = true;
- break;
- }
- }
- if (!extenstion)
- {
- Response.Write("<script language='javascript'>alert('只允許上傳格式為gif, jpg的檔案!');</script>");
- return false;
- }
- else
- {
- string name = FileUpload1.FileName.Substring(0, FileUpload1.FileName.Length - 4) + time + System.IO.Path.GetExtension(FileUpload1.FileName).ToLower();
- FileUpload1.PostedFile.SaveAs(directory + name);
- ContentLength.Value = FileUpload1.PostedFile.ContentLength.ToString();
- flag = true;
- }
- }
- return flag;
- }
- protected void BtnShowWhere_Click(object sender, EventArgs e)
- {
- if (Request.QueryString["e_id"] != null)
- {
- Response.Redirect("employee_where.aspx?e_id="+Request.QueryString["e_id"]);
- }
- }
- }