private void cmdSubmit_Click(object sender, System.EventArgs e) { if(rb_male.Checked==true) sex =1; else sex =0; if(EditStatus ==0) { UDS.Components.Database db = new UDS.Components.Database(); SqlDataReader dr=null; try { if (myposition.Visible == true) PositionID = cboPosition.Items[cboPosition.SelectedIndex].Value.ToString(); SqlParameter[] prams = { db.MakeInParam("@StaffName",SqlDbType.VarChar,300,txtStaffName.Text), db.MakeInParam("@Password",SqlDbType.VarChar,300,txtPassword.Text ), db.MakeInParam("@RealName",SqlDbType.VarChar,300,txtRealName.Text), db.MakeInParam("@Sex",SqlDbType.Int,4,sex), db.MakeInParam("@Status",SqlDbType.Int,4,0), db.MakeInParam("@Email",SqlDbType.VarChar,300,txtEmail.Text), db.MakeInParam("@RegistedDate",SqlDbType.DateTime,8,DateTime.Now.ToString()), db.MakeInParam("@PositionID",SqlDbType.Int,4,Int32.Parse(PositionID)), db.MakeInParam("@Phone",SqlDbType.VarChar,50,txtPhone.Text), db.MakeInParam("@Mobile",SqlDbType.VarChar,50,txtMobile.Text), db.MakeInParam("@Birthday",SqlDbType.DateTime,8,(Request.Form["txtBirthday"].ToString()=="")?"1900-1-1":Request.Form["txtBirthday"].ToString()), db.MakeInParam("@Caste",SqlDbType.Int,4,Int32.Parse(txtCaste.Text)), db.MakeInParam("@ContractDate",SqlDbType.DateTime,8,(Request.Form["txtContractDate"].ToString()=="")?"1900-1-1":Request.Form["txtContractDate"].ToString()), db.MakeInParam("@InsuranceStatus",SqlDbType.VarChar,300,txtInsuranceStatus.Text), db.MakeInParam("@AccumulationStatus",SqlDbType.VarChar,300,txtAccumulationStatus.Text), db.MakeInParam("@IDNumber",SqlDbType.VarChar,300,txtIDNumber.Text), db.MakeInParam("@Marriage",SqlDbType.VarChar,300,txtMarriage.Text), db.MakeInParam("@Address",SqlDbType.VarChar,300,txtAddress.Text), db.MakeInParam("@BirthPlace",SqlDbType.VarChar,300,txtBirthPlace.Text), db.MakeInParam("@Education ",SqlDbType.VarChar,300,txtEducation .Text), db.MakeInParam("@Features",SqlDbType.VarChar,300,txtFeatures.Text), db.MakeInParam("@Remark",SqlDbType.VarChar,300,txtRemark.Text), db.MakeInParam("@InsuranceBase",SqlDbType.Money,21, decimal.Parse( txtInsuranceBase.Text == "" ? "0" : txtInsuranceBase.Text)), db.MakeInParam("@EndowmentCompany",SqlDbType.Money,21, decimal.Parse(txtEndowmentCompany.Text==""?"0":txtEndowmentCompany.Text)), db.MakeInParam("@EndowmentPersonal ",SqlDbType.Money,21, decimal.Parse(txtEndowmentPersonal.Text==""?"0":txtEndowmentPersonal.Text)), db.MakeInParam("@UnemploymentCompany ",SqlDbType.Money,21, decimal.Parse(txtUnemploymentCompany.Text==""?"0":txtUnemploymentCompany.Text)), db.MakeInParam("@UnemploymentPersonal",SqlDbType.Money,21, decimal.Parse(txtUnemploymentPersonal.Text==""?"0":txtUnemploymentPersonal.Text)), db.MakeInParam("@Injury",SqlDbType.Money,21, decimal.Parse(txtInjury.Text==""?"0":txtInjury.Text)), db.MakeInParam("@Maternity ",SqlDbType.Money,21, decimal.Parse(txtMaternity.Text==""?"0":txtMaternity.Text)), db.MakeInParam("@MedicalCompany ",SqlDbType.Money,21, decimal.Parse(txtMedicalCompany.Text==""?"0":txtMedicalCompany.Text)), db.MakeInParam("@MedicalPersonal",SqlDbType.Money,21, decimal.Parse(txtMedicalPersonal.Text==""?"0":txtMedicalPersonal.Text)), db.MakeInParam("@InsuranceCompanyTotal ",SqlDbType.Money,21, decimal.Parse( txtInsuranceCompanyTotal.Text==""?"0":txtInsuranceCompanyTotal.Text)), db.MakeInParam("@InsurancePersonalTotal",SqlDbType.Money,21, decimal.Parse(txtInsurancePersonalTotal.Text==""?"0":txtInsurancePersonalTotal.Text)), db.MakeInParam("@AccumulationBase",SqlDbType.Money,21, decimal.Parse(txtAccumulationBase.Text==""?"0":txtAccumulationBase.Text)), db.MakeInParam("@AccumulationCompany ",SqlDbType.Money,21, decimal.Parse(txtAccumulationCompany.Text==""?"0":txtAccumulationCompany.Text)), db.MakeInParam("@AccumulationPersonal",SqlDbType.Money,21, decimal.Parse(txtAccumulationPersonal.Text == "" ? "0" : txtAccumulationPersonal.Text)), db.MakeInParam("@staff_dept",SqlDbType.VarChar,200,dplDept.Items[dplDept.SelectedIndex].Value.ToString()) }; db.RunProc("sp_AddStaff", prams, out dr); if (dr.Read()) { SqlDataReader dr_isok;//������ְ��Ա UDS.Components.Staff sta = new UDS.Components.Staff(); dr_isok = sta.GetAllStaffs(); //����������� if (this.cbRemind.Checked == true) { try { while (dr_isok.Read()) { SMS sm = new SMS(); sm.SendMsg(Username, dr_isok["Staff_name"].ToString(), cboPosition.SelectedItem.Text + "���µ�Ա�� " + txtRealName.Text + ",�ش�֪ͨ.", 1, DateTime.Now, "", 0, 0); //sm.SendMsg(Username,mailbody.MailReceiverStr+mailbody.MailCcToAddr+mailbody.MailBccToAddr,"����"+Username+"���յ���һ���µ��ʼ�",1,DateTime.Now,"",0,0); sm = null; } } finally { dr_isok.Close(); dr_isok = null; } } if (ReturnPage == 0) Response.Redirect("ListView.aspx?Position_ID=" + PositionID); else Response.Redirect("../Staff/ManageStaff.aspx"); dr = null; } else message.Text = "<font color=red>���û��Ѿ����ڣ�</font>"; } finally { if (db != null) { db.Close(); } if (dr != null) { dr.Close(); } } } else { UDS.Components.Staff person = new UDS.Components.Staff(); txtContractDate.Text=(Request.Form["txtContractDate"].ToString()=="-")?"1900-1-1":Request.Form["txtContractDate"].ToString(); txtBirthday.Text = (Request.Form["txtBirthday"].ToString() == "-") ? "1900-1-1" : Request.Form["txtBirthday"].ToString(); switch (person.UpdateInfo(StaffID, txtRealName.Text, sex, txtBirthday.Text, txtPassword.Text, txtEmail.Text, txtPhone.Text, txtMobile.Text, Int32.Parse(cboPosition.Items[cboPosition.SelectedIndex].Value), Int32.Parse(txtCaste.Text), txtContractDate.Text , txtInsuranceStatus.Text , txtAccumulationStatus.Text , txtIDNumber.Text , txtMarriage.Text , txtAddress.Text , txtBirthPlace.Text , txtEducation.Text , txtFeatures.Text , txtRemark.Text , txtInsuranceBase.Text == "" ? "0" : txtInsuranceBase.Text , txtEndowmentCompany.Text==""?"0":txtEndowmentCompany.Text , txtEndowmentPersonal.Text==""?"0":txtEndowmentPersonal.Text , txtUnemploymentCompany.Text==""?"0":txtUnemploymentCompany.Text , txtUnemploymentPersonal.Text==""?"0":txtUnemploymentPersonal.Text , txtInjury.Text==""?"0":txtInjury.Text , txtMaternity.Text==""?"0":txtMaternity.Text , txtMedicalCompany.Text==""?"0":txtMedicalCompany.Text , txtMedicalPersonal.Text==""?"0":txtMedicalPersonal.Text , txtInsuranceCompanyTotal.Text==""?"0":txtInsuranceCompanyTotal.Text , txtInsurancePersonalTotal.Text==""?"0":txtInsurancePersonalTotal.Text , txtAccumulationBase.Text==""?"0":txtAccumulationBase.Text , txtAccumulationCompany.Text==""?"0":txtAccumulationCompany.Text , txtAccumulationPersonal.Text == "" ? "0" : txtAccumulationPersonal.Text , dplDept.Items[dplDept.SelectedIndex].Value.ToString() )) { case 0: PositionID = Int32.Parse(cboPosition.Items[cboPosition.SelectedIndex].Value ).ToString(); if(ReturnPage==0) Response.Redirect("ListView.aspx?Position_ID="+PositionID); else Response.Redirect("../Staff/ManageStaff.aspx"); message.Text = "�ijɹ���"; break; case -1: message.Text = "��֤���벻�ԣ�"; break; default: break; } } }
private void cmdSubmit_Click(object sender, System.EventArgs e) { if (rb_male.Checked == true) { sex = 1; } else { sex = 0; } if (EditStatus == 0) { UDS.Components.Database db = new UDS.Components.Database(); SqlDataReader dr; if (myposition.Visible == true) { PositionID = cboPosition.Items[cboPosition.SelectedIndex].Value.ToString(); } SqlParameter[] prams = { db.MakeInParam("@StaffName", SqlDbType.VarChar, 300, txtStaffName.Text), db.MakeInParam("@Password", SqlDbType.VarChar, 300, txtPassword.Text), db.MakeInParam("@RealName", SqlDbType.VarChar, 300, txtRealName.Text), db.MakeInParam("@Sex", SqlDbType.Int, 4, sex), db.MakeInParam("@Status", SqlDbType.Int, 4, 0), db.MakeInParam("@Email", SqlDbType.VarChar, 300, txtEmail.Text), db.MakeInParam("@RegistedDate", SqlDbType.DateTime, 8, DateTime.Now.ToString()), db.MakeInParam("@PositionID", SqlDbType.Int, 4, Int32.Parse(PositionID)), db.MakeInParam("@Phone", SqlDbType.VarChar, 50, txtPhone.Text), db.MakeInParam("@Mobile", SqlDbType.VarChar, 50, txtMobile.Text), db.MakeInParam("@Birthday", SqlDbType.DateTime, 8, (txtBirthday.Text.Trim() == "")?"1900-1-1":txtBirthday.Text), db.MakeInParam("@Caste", SqlDbType.Int, 4, Int32.Parse(txtCaste.Text)) }; db.RunProc("sp_AddStaff", prams, out dr); if (dr.Read()) { SqlDataReader dr_isok; //所有在职人员 UDS.Components.Staff sta = new UDS.Components.Staff(); dr_isok = sta.GetAllStaffs(); //处理短信提醒 if (this.cbRemind.Checked == true) { while (dr_isok.Read()) { SMS sm = new SMS(); sm.SendMsg(Username, dr_isok["Staff_name"].ToString(), cboPosition.SelectedItem.Text + "处新到员工 " + txtRealName.Text + ",特此通知.", 1, DateTime.Now, "", 0, 0); //sm.SendMsg(Username,mailbody.MailReceiverStr+mailbody.MailCcToAddr+mailbody.MailBccToAddr,"您从"+Username+"处收到了一封新的邮件",1,DateTime.Now,"",0,0); sm = null; } dr_isok = null; } if (ReturnPage == 0) { Response.Redirect("ListView.aspx?Position_ID=" + PositionID); } else { Response.Redirect("../Staff/ManageStaff.aspx"); } dr = null; } else { message.Text = "<font color=red>该用户已经存在!</font>"; } } else { UDS.Components.Staff person = new UDS.Components.Staff(); switch (person.UpdateInfo(StaffID, txtRealName.Text, sex, txtBirthday.Text == "-"?"1900-01-01":txtBirthday.Text, txtPassword.Text, txtEmail.Text, txtPhone.Text, txtMobile.Text, Int32.Parse(cboPosition.Items[cboPosition.SelectedIndex].Value), Int32.Parse(txtCaste.Text))) { case 0: PositionID = Int32.Parse(cboPosition.Items[cboPosition.SelectedIndex].Value).ToString(); if (ReturnPage == 0) { Response.Redirect("ListView.aspx?Position_ID=" + PositionID); } else { Response.Redirect("../Staff/ManageStaff.aspx"); } message.Text = "修改成功!"; break; case -1: message.Text = "验证密码不对!"; break; default: break; } } }
private void cmdSubmit_Click(object sender, System.EventArgs e) { if(rb_male.Checked==true) sex =1; else sex =0; if(EditStatus ==0) { UDS.Components.Database db = new UDS.Components.Database(); SqlDataReader dr; if(myposition.Visible==true) PositionID = cboPosition.Items[cboPosition.SelectedIndex].Value.ToString(); SqlParameter[] prams = { db.MakeInParam("@StaffName",SqlDbType.VarChar,300,txtStaffName.Text), db.MakeInParam("@Password",SqlDbType.VarChar,300,txtPassword.Text ), db.MakeInParam("@RealName",SqlDbType.VarChar,300,txtRealName.Text), db.MakeInParam("@Sex",SqlDbType.Int,4,sex), db.MakeInParam("@Status",SqlDbType.Int,4,0), db.MakeInParam("@Email",SqlDbType.VarChar,300,txtEmail.Text), db.MakeInParam("@RegistedDate",SqlDbType.DateTime,8,DateTime.Now.ToString()), db.MakeInParam("@PositionID",SqlDbType.Int,4,Int32.Parse(PositionID)), db.MakeInParam("@Phone",SqlDbType.VarChar,50,txtPhone.Text), db.MakeInParam("@Mobile",SqlDbType.VarChar,50,txtMobile.Text), db.MakeInParam("@Birthday",SqlDbType.DateTime,8,(txtBirthday.Text.Trim()=="")?"1900-1-1":txtBirthday.Text), db.MakeInParam("@Caste",SqlDbType.Int,4,Int32.Parse(txtCaste.Text)) }; db.RunProc("sp_AddStaff",prams,out dr); if(dr.Read()) { SqlDataReader dr_isok;//������ְ��Ա UDS.Components.Staff sta=new UDS.Components.Staff(); dr_isok=sta.GetAllStaffs(); //����������� if(this.cbRemind.Checked ==true) { while(dr_isok.Read()) { SMS sm = new SMS(); sm.SendMsg(Username,dr_isok["Staff_name"].ToString(),cboPosition.SelectedItem.Text+"���µ�Ա�� "+txtRealName.Text+",�ش�֪ͨ.",1,DateTime.Now,"",0,0); //sm.SendMsg(Username,mailbody.MailReceiverStr+mailbody.MailCcToAddr+mailbody.MailBccToAddr,"����"+Username+"���յ���һ���µ��ʼ�",1,DateTime.Now,"",0,0); sm = null; } dr_isok=null; } if(ReturnPage==0) Response.Redirect("ListView.aspx?Position_ID="+PositionID); else Response.Redirect("../Staff/ManageStaff.aspx"); dr=null; } else message.Text = "<font color=red>���û��Ѿ����ڣ�</font>"; } else { UDS.Components.Staff person = new UDS.Components.Staff(); switch(person.UpdateInfo(StaffID,txtRealName.Text,sex,txtBirthday.Text=="-"?"1900-01-01":txtBirthday.Text,txtPassword.Text,txtEmail.Text,txtPhone.Text,txtMobile.Text,Int32.Parse(cboPosition.Items[cboPosition.SelectedIndex].Value ),Int32.Parse(txtCaste.Text))) { case 0: PositionID = Int32.Parse(cboPosition.Items[cboPosition.SelectedIndex].Value ).ToString(); if(ReturnPage==0) Response.Redirect("ListView.aspx?Position_ID="+PositionID); else Response.Redirect("../Staff/ManageStaff.aspx"); message.Text = "�ijɹ���"; break; case -1: message.Text = "��֤���벻�ԣ�"; break; default: break; } } }