employee_form.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_curricula_vitae_employee_form : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- LoginDAO.CheckLogin(Session, Response, "../../", 2);
- if (!IsPostBack)
- {
- if (Session["p_department_id"] != null)
- {
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand cmd = new SqlCommand("select id, name from OA_DEPARTMENT where id=" + Session["p_department_id"].ToString(), conn);
- SqlDataReader dr = cmd.ExecuteReader();
- if (dr.Read())
- {
- DepartmentId.Value = dr["id"].ToString();
- TxtDepartment.Text = dr["name"].ToString();
- }
- dr.Close();
- conn.Close();
- }
- TxtNo.Attributes.Add("onchange", "changeEmpNo()");
- }
- }
- protected bool CheckValidate()
- {
- int flag = 0;
- if (DepartmentId.Value.Equals(""))
- {
- flag = 1;
- Response.Write("<script language='javascript'>alert('部門不能為空!')</script>");
- TxtDepartment.Focus();
- }
- if (TxtName.Text.Trim().Equals(""))
- {
- flag = 1;
- Response.Write("<script language='javascript'>alert('姓名不能為空!')</script>");
- TxtName.Focus();
- }
- if (TxtNo.Text.Trim().Equals(""))
- {
- flag = 1;
- Response.Write("<script language='javascript'>alert('工號不能為空!')</script>");
- TxtNo.Focus();
- }
- if (TxtLoginName.Text.Trim().Equals(""))
- {
- flag = 1;
- Response.Write("<script language='javascript'>alert('登錄名不能為空!')</script>");
- TxtLoginName.Focus();
- }
- if (TxtPwd.Text.Trim().Equals(""))
- {
- flag = 1;
- Response.Write("<script language='javascript'>alert('密碼不能為空!')</script>");
- TxtPwd.Focus();
- }
- if (TxtMailWork.Text.Trim().Equals(""))
- {
- flag = 1;
- Response.Write("<script language='javascript'>alert('工作郵箱不能為空!')</script>");
- TxtMailWork.Focus();
- }
- if (flag == 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- protected void BtnOk_Click(object sender, EventArgs e)
- {
- if (this.CheckValidate())
- {
- int flag = 0;
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand cmd = new SqlCommand("select count(id) from OA_EMPLOYEE where login_name='" +
- TxtLoginName.Text.Trim() + "'", conn);
- int count = Convert.ToInt32(cmd.ExecuteScalar());
- if (count == 1)
- {
- flag = 1;
- }
- if (flag == 0)
- {
- //添加员工基本资料
- int emp_id = 1;
- cmd = new SqlCommand("select max(id) from OA_EMPLOYEE", conn);
- try
- {
- emp_id = Convert.ToInt32(cmd.ExecuteScalar().ToString()) + 1;
- }
- catch { }
- cmd = new SqlCommand("insert into OA_EMPLOYEE(id, department_id, emp_no, emp_name, login_name, " +
- "pwd, user_group, position, dimission_date, active_date, sex, birth_date, nation, " +
- "marriage, id_card, native, stature, address, linkman, tel, registered_address,"+
- "smart_phone, tel_extension, id_card_expire, email_work, email_personal,work_card_no1, "+
- "work_card_no2, link_man_tel, work_place,is_del) values (" +
- emp_id + ", '" + DepartmentId.Value + "','" + TxtNo.Text + "','" + TxtName.Text + "','" + TxtLoginName.Text +
- "','" + TxtPwd.Text + "','" + DdlGroup.SelectedValue + "','" + DdlPosition.SelectedValue + "','" +
- TxtDimissionDate.Text + "','" + TxtActiveDate.Text + "','" + DdlSex.SelectedValue + "','" +
- TxtBirthDate.Text + "','" + TxtNation.Text + "','" + DdlMarriage.SelectedValue + "','" +
- TxtIdCard.Text + "','" + TxtNative.Text + "','" + TxtStature.Text + "','" + TxtAddress.Text + "','" +
- TxtLinkman.Text + "','" + TxtTel.Text + "','" + TxtRegisteredAdress.Text + "','"+
- TxtSmartPhone.Text+"','"+TxtTelExtension.Text+"','"+TxtIdCardExpire.Text+"','"+
- TxtMailWork.Text+"','"+TxtMailPersonal.Text+"','"+TxtWorkCardNo1.Text+"','"+
- TxtWorkCardNo2.Text+"','"+TxtLinkmanTel.Text+"','"+TxtWorkPlace.Text+"','N')", conn);
- cmd.ExecuteNonQuery();
- //添加家庭情况
- #region
- if (!TxtFamilyName1.Text.Trim().Equals(""))
- {
- cmd = new SqlCommand("insert into OA_EMPLOYEE_FAMILY (emp_id, family_name, [relative], age, " +
- "tel, company) values (" + emp_id + ", '" + TxtFamilyName1.Text + "', '" + TxtRelative1.Text + "','" +
- TxtAge1.Text + "','" + TxtTel1.Text + "','" + TxtCompany1.Text + "')", conn);
- cmd.ExecuteNonQuery();
- }
- if (!TxtFamilyName2.Text.Trim().Equals(""))
- {
- cmd = new SqlCommand("insert into OA_EMPLOYEE_FAMILY (emp_id, family_name, [relative], age, " +
- "tel, company) values (" + emp_id + ", '" + TxtFamilyName2.Text + "', '" + TxtRelative2.Text + "','" +
- TxtAge2.Text + "','" + TxtTel2.Text + "','" + TxtCompany2.Text + "')", conn);
- cmd.ExecuteNonQuery();
- }
- if (!TxtFamilyName3.Text.Trim().Equals(""))
- {
- cmd = new SqlCommand("insert into OA_EMPLOYEE_FAMILY (emp_id, family_name, [relative], age, " +
- "tel, company) values (" + emp_id + ", '" + TxtFamilyName3.Text + "', '" + TxtRelative3.Text + "','" +
- TxtAge3.Text + "','" + TxtTel3.Text + "','" + TxtCompany3.Text + "')", conn);
- cmd.ExecuteNonQuery();
- }
- if (!TxtFamilyName4.Text.Trim().Equals(""))
- {
- cmd = new SqlCommand("insert into OA_EMPLOYEE_FAMILY (emp_id, family_name, [relative], age, " +
- "tel, company) values (" + emp_id + ", '" + TxtFamilyName4.Text + "', '" + TxtRelative4.Text + "','" +
- TxtAge4.Text + "','" + TxtTel4.Text + "','" + TxtCompany4.Text + "')", conn);
- cmd.ExecuteNonQuery();
- }
- #endregion
- //添加背景
- #region
- if (!TxtBackName1.Text.Trim().Equals(""))
- {
- cmd = new SqlCommand("insert into OA_EMPLOYEE_BACKGROUND(emp_id, back_name, [relative], job, " +
- "tel, company)values(" + emp_id + ",'" + TxtBackName1.Text + "','" + TxtBackRelative1.Text + "','" +
- TxtBackJob1.Text + "','" + TxtBackTel1.Text + "','" + TxtBackCompany1.Text + "')", conn);
- cmd.ExecuteNonQuery();
- }
- if (!TxtBackName2.Text.Trim().Equals(""))
- {
- cmd = new SqlCommand("insert into OA_EMPLOYEE_BACKGROUND(emp_id, back_name, [relative], job, " +
- "tel, company)values(" + emp_id + ",'" + TxtBackName2.Text + "','" + TxtBackRelative2.Text + "','" +
- TxtBackJob2.Text + "','" + TxtBackTel2.Text + "','" + TxtBackCompany2.Text + "')", conn);
- cmd.ExecuteNonQuery();
- }
- #endregion
- //添加教育經歷
- #region
- if (!TxtSchoolName1.Text.Trim().Equals(""))
- {
- cmd = new SqlCommand("insert into OA_EMPLOYEE_EDUCATION(emp_id, begin_year, begin_month, " +
- "end_year, end_month, school, subject, grade)values(" + emp_id + ",'" + TxtEdBeginYear1.Text +
- "','" + TxtEdBeginMonth1.Text + "','" + TxtEdEndYear1.Text + "','" + TxtEdEndMonth1.Text + "','" +
- TxtSchoolName1.Text + "','" + TxtSubject1.Text + "','" + TxtGrade1.Text + "')", conn);
- cmd.ExecuteNonQuery();
- }
- if (!TxtSchoolName2.Text.Trim().Equals(""))
- {
- cmd = new SqlCommand("insert into OA_EMPLOYEE_EDUCATION(emp_id, begin_year, begin_month, " +
- "end_year, end_month, school, subject, grade)values(" + emp_id + ",'" + TxtEdBeginYear2.Text +
- "','" + TxtEdBeginMonth2.Text + "','" + TxtEdEndYear2.Text + "','" + TxtEdEndMonth2.Text + "','" +
- TxtSchoolName2.Text + "','" + TxtSubject2.Text + "','" + TxtGrade2.Text + "')", conn);
- cmd.ExecuteNonQuery();
- }
- if (!TxtSchoolName3.Text.Trim().Equals(""))
- {
- cmd = new SqlCommand("insert into OA_EMPLOYEE_EDUCATION(emp_id, begin_year, begin_month, " +
- "end_year, end_month, school, subject, grade)values(" + emp_id + ",'" + TxtEdBeginYear3.Text +
- "','" + TxtEdBeginMonth3.Text + "','" + TxtEdEndYear3.Text + "','" + TxtEdEndMonth3.Text + "','" +
- TxtSchoolName3.Text + "','" + TxtSubject3.Text + "','" + TxtGrade3.Text + "')", conn);
- cmd.ExecuteNonQuery();
- }
- if (!TxtSchoolName4.Text.Trim().Equals(""))
- {
- cmd = new SqlCommand("insert into OA_EMPLOYEE_EDUCATION(emp_id, begin_year, begin_month, " +
- "end_year, end_month, school, subject, grade)values(" + emp_id + ",'" + TxtEdBeginYear4.Text +
- "','" + TxtEdBeginMonth4.Text + "','" + TxtEdEndYear4.Text + "','" + TxtEdEndMonth4.Text + "','" +
- TxtSchoolName4.Text + "','" + TxtSubject4.Text + "','" + TxtGrade4.Text + "')", conn);
- cmd.ExecuteNonQuery();
- }
- #endregion
- //添加工作經歷
- #region
- if (!TxtWorkCompany1.Text.Trim().Equals(""))
- {
- cmd = new SqlCommand("insert into OA_EMPLOYEE_JOB(emp_id, begin_year, begin_month, end_year, " +
- "end_month, company, tel, salary, dimission_reason)values(" + emp_id + ",'" + TxtWorkBeginYear1.Text +
- "','" + TxtWorkBeginMonth1.Text + "','" + TxtWorkEndYear1.Text + "','" + TxtWorkEndMonth1.Text + "','" +
- TxtWorkCompany1.Text + "','" + TxtWorkTel1.Text + "','" + TxtWorkSalary1.Text + "','" +
- TxtDimissionReason1.Text + "')", conn);
- cmd.ExecuteNonQuery();
- }
- if (!TxtWorkCompany2.Text.Trim().Equals(""))
- {
- cmd = new SqlCommand("insert into OA_EMPLOYEE_JOB(emp_id, begin_year, begin_month, end_year, " +
- "end_month, company, tel, salary, dimission_reason)values(" + emp_id + ",'" + TxtWorkBeginYear2.Text +
- "','" + TxtWorkBeginMonth2.Text + "','" + TxtWorkEndYear2.Text + "','" + TxtWorkEndMonth2.Text + "','" +
- TxtWorkCompany2.Text + "','" + TxtWorkTel2.Text + "','" + TxtWorkSalary2.Text + "','" +
- TxtDimissionReason2.Text + "')", conn);
- cmd.ExecuteNonQuery();
- }
- if (!TxtWorkCompany3.Text.Trim().Equals(""))
- {
- cmd = new SqlCommand("insert into OA_EMPLOYEE_JOB(emp_id, begin_year, begin_month, end_year, " +
- "end_month, company, tel, salary, dimission_reason)values(" + emp_id + ",'" + TxtWorkBeginYear3.Text +
- "','" + TxtWorkBeginMonth3.Text + "','" + TxtWorkEndYear3.Text + "','" + TxtWorkEndMonth3.Text + "','" +
- TxtWorkCompany3.Text + "','" + TxtWorkTel3.Text + "','" + TxtWorkSalary3.Text + "','" +
- TxtDimissionReason3.Text + "')", conn);
- cmd.ExecuteNonQuery();
- }
- if (!TxtWorkCompany4.Text.Trim().Equals(""))
- {
- cmd = new SqlCommand("insert into OA_EMPLOYEE_JOB(emp_id, begin_year, begin_month, end_year, " +
- "end_month, company, tel, salary, dimission_reason)values(" + emp_id + ",'" + TxtWorkBeginYear4.Text +
- "','" + TxtWorkBeginMonth4.Text + "','" + TxtWorkEndYear4.Text + "','" + TxtWorkEndMonth4.Text + "','" +
- TxtWorkCompany4.Text + "','" + TxtWorkTel4.Text + "','" + TxtWorkSalary4.Text + "','" +
- TxtDimissionReason4.Text + "')", conn);
- cmd.ExecuteNonQuery();
- }
- #endregion
- //添加專業技能
- #region
- if (!TxtLanguage.Text.Trim().Equals("") || !TxtComputerGrade.Text.Trim().Equals("")
- || !TxtCertificate.Text.Trim().Equals("") || !TxtOther.Text.Trim().Equals(""))
- {
- int skill_id = 1;
- cmd = new SqlCommand("select max(id) from OA_EMPLOYEE_SKILL", conn);
- try
- {
- skill_id = Convert.ToInt32(cmd.ExecuteScalar().ToString()) + 1;
- }
- catch { }
- cmd = new SqlCommand("insert into OA_EMPLOYEE_SKILL(id, emp_id, language, computer_grade, " +
- "certificate, other) values(" + skill_id + "," + emp_id + ",'" + TxtLanguage.Text + "','" +
- TxtComputerGrade.Text + "','" + TxtCertificate.Text + "','" + TxtOther.Text + "')", conn);
- cmd.ExecuteNonQuery();
- }
- #endregion
- Session["p_department_id"] = DepartmentId.Value;
- // Response.Redirect("employee_list_index.aspx");
- Response.Redirect("upload_photo.aspx?e_id="+emp_id);
- }
- else
- {
- Response.Write("<script language='javascript'>alert('已存在相同登錄名的員工');</script>");
- TxtLoginName.Focus();
- }
- conn.Close();
- }
- }
- protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
- {
- if (Calendar1.Visible == true)
- {
- Calendar1.Visible = false;
- }
- else
- {
- Calendar1.Visible = true;
- }
- }
- protected void Calendar1_SelectionChanged(object sender, EventArgs e)
- {
- string year = Calendar1.SelectedDate.Year.ToString();
- string month = Calendar1.SelectedDate.Month.ToString();
- if (month.Length == 1)
- {
- month = "0" + month;
- }
- string day = Calendar1.SelectedDate.Day.ToString();
- if (day.Length == 1)
- {
- day = "0" + day;
- }
- TxtActiveDate.Text = year + "-" + month + "-" + day;
- Calendar1.Visible = false;
- }
- protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
- {
- if (Calendar2.Visible == true)
- {
- Calendar2.Visible = false;
- }
- else
- {
- Calendar2.Visible = true;
- }
- }
- protected void Calendar2_SelectionChanged(object sender, EventArgs e)
- {
- string year = Calendar2.SelectedDate.Year.ToString();
- string month = Calendar2.SelectedDate.Month.ToString();
- if (month.Length == 1)
- {
- month = "0" + month;
- }
- string day = Calendar2.SelectedDate.Day.ToString();
- if (day.Length == 1)
- {
- day = "0" + day;
- }
- TxtDimissionDate.Text = year + "-" + month + "-" + day; ;
- Calendar2.Visible = false;
- }
- }