private void GetRoleInfo(int employeeID) { SystemUserBLL objSystemBll = new SystemUserBLL(); RailExam.Model.SystemUser objSystem = objSystemBll.GetUserByEmployeeID(employeeID); ddlRoleNameEdit.SelectedValue = objSystem.RoleID.ToString(); }
//保存数据 private void saveData() { string type = Request.QueryString["Type"];//1为修改 2为新增 string id = Request.QueryString["ID"]; OracleAccess db = new OracleAccess(); string strSql = ""; if (!string.IsNullOrEmpty(txtIDENTITY_CARDNO.Text.Trim())) { if (type == "1") { strSql = "select a.*,GetOrgName(GetStationOrgID(a.Org_ID)) OrgName from Employee a where Identity_CardNo='" + txtIDENTITY_CARDNO.Text.Trim() + "' and Employee_ID<>" + id; } else { strSql = "select a.*,GetOrgName(GetStationOrgID(a.Org_ID)) OrgName from Employee a where Identity_CardNo='" + txtIDENTITY_CARDNO.Text.Trim() + "'"; } DataSet ds = db.RunSqlDataSet(strSql); if (ds.Tables[0].Rows.Count > 0) { string strName = ds.Tables[0].Rows[0]["Employee_Name"].ToString(); string orgName = ds.Tables[0].Rows[0]["OrgName"].ToString(); SessionSet.PageMessage = "该身份证号码在系统中已存在,与【" + orgName + "】的【" + strName + "】身份证号相同!"; return; } } if (!string.IsNullOrEmpty(txtWORK_NO.Text.Trim())) { if (type == "1") { strSql = "select a.*,GetOrgName(GetStationOrgID(a.Org_ID)) OrgName from Employee a where Work_No='" + txtWORK_NO.Text.Trim() + "' and Employee_ID<>" + id; } else { strSql = "select a.*,GetOrgName(GetStationOrgID(a.Org_ID)) OrgName from Employee a where Work_No='" + txtWORK_NO.Text.Trim() + "'"; } DataSet ds = db.RunSqlDataSet(strSql); if (ds.Tables[0].Rows.Count > 0) { string strName = ds.Tables[0].Rows[0]["Employee_Name"].ToString(); string orgName = ds.Tables[0].Rows[0]["OrgName"].ToString(); SessionSet.PageMessage = "该岗位培训合格证书编号在系统中已存在,与【" + orgName + "】的【" + strName + "】岗位培训合格证书编号相同!"; //ClientScript.RegisterStartupScript(GetType(), "OK", "alert('该岗位培训合格证书编号在系统中已存在,\r\n与【" + orgName + "】的【" + strName + "】岗位培训合格证书编号相同!');", true); return; } } string sqlStr = string.Empty; DateTime isnulldate = new DateTime(0001, 01, 01); DateTime birthday, begin_date, join_rail_date, workgroupleader_order_date, award_date; DateTime postDate, //任现职名时间 technicalTitleDate, //技术职称聘任时间 technicalDate, //技能等级取得时间 graduateDate; //毕业时间 string graduateUniversity, //毕业院校 studyMajor, //所学专业 universityType; //学校类别 if (!DateTime.TryParse(this.dateBIRTHDAY.DateValue.ToString(), out birthday)) { birthday = isnulldate; } if (!DateTime.TryParse(this.dateBEGIN_DATE.DateValue.ToString(), out begin_date)) { begin_date = isnulldate; } if (!DateTime.TryParse(this.dateJOIN_RAIL_DATE.DateValue.ToString(), out join_rail_date)) { join_rail_date = isnulldate; } if (ddlWORKGROUPLEADER_TYPE_ID.SelectedValue != "-1") { if (!DateTime.TryParse(this.dateWORKGROUPLEADER_ORDER_DATE.DateValue.ToString(), out workgroupleader_order_date)) { workgroupleader_order_date = isnulldate; } } else { workgroupleader_order_date = isnulldate; } if (!DateTime.TryParse(this.dateAWARD_DATE.DateValue.ToString(), out award_date)) { award_date = isnulldate; } if (!DateTime.TryParse(this.datePost.DateValue.ToString(), out postDate)) { postDate = isnulldate; } if (!DateTime.TryParse(this.dateTechnicalDate.DateValue.ToString(), out technicalDate)) { technicalDate = isnulldate; } if (!DateTime.TryParse(this.dateTechnicalTitle.DateValue.ToString(), out technicalTitleDate)) { technicalTitleDate = isnulldate; } if (!DateTime.TryParse(this.dateGraduate.DateValue.ToString(), out graduateDate)) { graduateDate = isnulldate; } if (this.txtMEMO.Text.ToString().Length > 50) { ClientScript.RegisterStartupScript(GetType(), "OK", "alert('备注不能超过50个字符!');", true); return; } OracleAccess ora = new OracleAccess(); int ISONPOST = this.cbISONPOST.Checked == true ? 1 : 0; if (!string.IsNullOrEmpty(type)) { int typeBool = int.Parse(type); if (typeBool == 1) { sqlStr = "update employee set org_id= '" + Convert.ToInt32(hfOrgID.Value) + "',"; sqlStr += "post_no= '" + this.txtPOST_NO.Text.Trim() + "',"; sqlStr += "employee_name= '" + this.txtEMPLOYEE_NAME.Text.Trim() + "',"; sqlStr += "pinyin_code= '" + this.txtPinYin.Text.Trim() + "',"; sqlStr += "post_id= '" + Convert.ToInt32(this.hfPostID.Value) + "',"; sqlStr += "now_post_id= " + (hfNowPostID.Value == "" ? "null" : "'" + hfNowPostID.Value + "'") + ","; sqlStr += "sex= '" + this.ddlSex.SelectedValue + "',"; sqlStr += "birthday=to_date('" + birthday + "','yyyy-mm-dd hh24:mi:ss'),"; sqlStr += "native_place= '" + this.txtNATIVE_PLACE.Text.Trim() + "',"; sqlStr += "folk= '" + this.txtFOLK.Text.Trim() + "',"; sqlStr += "wedding= '" + Convert.ToInt32(this.rblWEDDING.SelectedValue) + "',"; sqlStr += "begin_date= to_date('" + begin_date + "','yyyy-mm-dd hh24:mi:ss'),"; sqlStr += "IsOnPost= '" + ISONPOST + "',"; sqlStr += "memo= '" + this.txtMEMO.Text.Trim() + "',"; sqlStr += "is_group_leader= '" + Convert.ToInt32(this.ddlIsGroup.SelectedValue) + "',"; sqlStr += "technician_type_id = '" + int.Parse(this.ddlTECHNICIAN_TYPE_ID.SelectedValue) + "',"; sqlStr += "technical_title_id='" + int.Parse(this.ddlTECHNICAL_TITLE_ID.SelectedValue) + "',"; sqlStr += "work_no='" + this.txtWORK_NO.Text.Trim() + "',"; sqlStr += "identity_cardno='" + this.txtIDENTITY_CARDNO.Text.Trim() + "',"; sqlStr += "political_status_id='" + int.Parse(this.ddlPOLITICAL_STATUS.SelectedValue) + "',"; sqlStr += "join_rail_date=to_date('" + join_rail_date + "','yyyy-mm-dd hh24:mi:ss'),"; sqlStr += "education_level_id='" + int.Parse(this.DDLeducation_level_id.SelectedValue) + "',"; sqlStr += "employee_type_id='" + int.Parse(this.ddlEMPLOYEE_TYPE_ID.SelectedValue) + "',"; sqlStr += "second_post_id=" + (this.hfSECOND_POST_ID.Value == "" ? "NULL" : hfSECOND_POST_ID.Value) + ","; sqlStr += "third_post_id=" + (this.hfTHIRD_POST_ID.Value == "" ? "NULL" : hfTHIRD_POST_ID.Value) + ","; sqlStr += "workgroupleader_type_id='" + int.Parse(this.ddlWORKGROUPLEADER_TYPE_ID.SelectedValue) + "'," + "workgroupleader_order_date=to_date('" + workgroupleader_order_date + "','yyyy-mm-dd hh24:mi:ss')," + "education_employee_type_id='" + int.Parse(this.ddlEDUCATION_EMPLOYEE_TYPE_ID.SelectedValue) + "'," + "committee_head_ship_id='" + int.Parse(this.ddlCOMMITTEE_HEAD_SHIP_ID.SelectedValue) + "'," + "isregistered='" + int.Parse(this.ddlISREGISTERED.SelectedValue) + "'," + "employee_transport_type_id='" + int.Parse(this.ddlEMPLOYEE_TRANSPORT_TYPE_ID.SelectedValue) + "'," + "award_date=to_date('" + award_date + "','yyyy-mm-dd hh24:mi:ss')," + "could_post_id='" + this.hfCOULD_POST_ID.Value.Trim().ToString() + "'," + "TECHNICAL_DATE = to_date('" + technicalDate + "','yyyy-mm-dd hh24:mi:ss')," + "TECHNICAL_TITLE_DATE = to_date('" + technicalTitleDate + "','yyyy-mm-dd hh24:mi:ss')," + "POST_DATE = to_date('" + postDate + "','yyyy-mm-dd hh24:mi:ss')," + "GRADUATE_DATE = to_date('" + graduateDate + "','yyyy-mm-dd hh24:mi:ss')," + "GRADUATE_UNIVERSITY = '" + this.txtFinishSchool.Text + "'," + "STUDY_MAJOR = '" + this.txtMajor.Text + "'," + "UNIVERSITY_TYPE = '" + this.dropSchoolCategory.SelectedValue + "'," + "TECHNICAL_CODE = '" + this.txtTechnicalCode.Text + "'," + "Safe_Level_ID=" + (ddlSafe.SelectedValue == "" ? "NULL" : ddlSafe.SelectedValue) + " where employee_id = " + id; } else if (typeBool == 2) { sqlStr = "select EMPLOYEE_SEQ.NEXTVAL from dual"; id = ora.RunSqlDataSet(sqlStr).Tables[0].Rows[0][0].ToString(); sqlStr = "insert into employee (employee_id," + "org_id," + "post_no," + "employee_name," + "pinyin_code," + "post_id," + "sex," + "birthday," + "native_place," + "folk," + "wedding," + "begin_date," + "IsOnPost," + "memo," + "is_group_leader," + "technician_type_id," + "technical_title_id," + "work_no," + //"photo," + "identity_cardno," + "political_status_id," + "join_rail_date," + "education_level_id," + "employee_type_id," + "second_post_id," + "third_post_id," + "workgroupleader_type_id," + "workgroupleader_order_date," + "education_employee_type_id," + "committee_head_ship_id," + "isregistered," + "employee_transport_type_id," + "award_date," + "could_post_id," + "TECHNICAL_DATE," + "TECHNICAL_TITLE_DATE," + "POST_DATE," + "GRADUATE_UNIVERSITY," + "GRADUATE_DATE," + "STUDY_MAJOR," + "UNIVERSITY_TYPE," + "TECHNICAL_CODE,Safe_Level_ID,Now_Post_ID)" + " values(" + id + "," + Convert.ToInt32(this.hfOrgID.Value) + ",'" + this.txtPOST_NO.Text.Trim().ToString() + "','" + this.txtEMPLOYEE_NAME.Text.Trim().ToString() + "','" + Pub.GetChineseSpell(this.txtEMPLOYEE_NAME.Text.Trim().ToString()) + "'," + Convert.ToInt32(this.hfPostID.Value) + ",'" + this.ddlSex.SelectedValue + "'," + "to_date('" + birthday + "','yyyy-mm-dd hh24:mi:ss'),'" + this.txtNATIVE_PLACE.Text.Trim().ToString() + "','" + this.txtFOLK.Text.Trim().ToString() + "'," + Convert.ToInt32(this.rblWEDDING.SelectedValue) + "," + "to_date('" + begin_date + "','yyyy-mm-dd hh24:mi:ss')," + ISONPOST + ",'" + this.txtMEMO.Text.Trim().ToString() + "'," + Convert.ToInt32(this.ddlIsGroup.SelectedValue) + "," + int.Parse(this.ddlTECHNICIAN_TYPE_ID.SelectedValue) + "," + int.Parse(this.ddlTECHNICAL_TITLE_ID.SelectedValue) + ",'" + this.txtWORK_NO.Text.Trim().ToString() + "','" + this.txtIDENTITY_CARDNO.Text.Trim().ToString() + "'," + int.Parse(this.ddlPOLITICAL_STATUS.SelectedValue) + "," + "to_date('" + join_rail_date + "','yyyy-mm-dd hh24:mi:ss')," + int.Parse(this.DDLeducation_level_id.SelectedValue) + "," + int.Parse(this.ddlEMPLOYEE_TYPE_ID.SelectedValue) + "," + (this.hfSECOND_POST_ID.Value == "" ? "NULL" : hfSECOND_POST_ID.Value) + "," + (this.hfTHIRD_POST_ID.Value == "" ? "NULL" : hfSECOND_POST_ID.Value) + "," + int.Parse(this.ddlWORKGROUPLEADER_TYPE_ID.SelectedValue) + "," + "to_date('" + workgroupleader_order_date + "','yyyy-mm-dd hh24:mi:ss')," + int.Parse(this.ddlEDUCATION_EMPLOYEE_TYPE_ID.SelectedValue) + "," + int.Parse(this.ddlCOMMITTEE_HEAD_SHIP_ID.SelectedValue) + "," + int.Parse(this.ddlISREGISTERED.SelectedValue) + "," + int.Parse(this.ddlEMPLOYEE_TRANSPORT_TYPE_ID.SelectedValue) + "," + "to_date('" + award_date + "','yyyy-mm-dd hh24:mi:ss'),'" + this.hfCOULD_POST_ID.Value.Trim().ToString() + "'," + "to_date('" + technicalDate + "','yyyy-mm-dd hh24:mi:ss')," + "to_date('" + technicalTitleDate + "','yyyy-mm-dd hh24:mi:ss')," + "to_date('" + postDate + "','yyyy-mm-dd hh24:mi:ss')," + "'" + this.txtFinishSchool.Text + "'," + "to_date('" + graduateDate + "','yyyy-mm-dd hh24:mi:ss')," + "'" + this.txtMajor.Text + "'," + "'" + this.dropSchoolCategory.SelectedValue + "'," + "'" + this.txtTechnicalCode.Text + "'," + (ddlSafe.SelectedValue == "" ? "NULL" : ddlSafe.SelectedValue) + "," + (hfNowPostID.Value == "" ? "null" : "'" + hfNowPostID.Value + "'") + ")"; } try { ora.ExecuteNonQuery(sqlStr); if (typeBool == 2) { sqlStr = "insert into Employee_Photo values(" + id + ",null)"; ora.ExecuteNonQuery(sqlStr); } SystemUserBLL objSystemBll = new SystemUserBLL(); if (type == "1") { RailExam.Model.SystemUser objSystem = objSystemBll.GetUserByEmployeeID(Convert.ToInt32(id)); if (objSystem != null) { objSystem.UserID = txtWORK_NO.Text.Trim() == string.Empty ? txtIDENTITY_CARDNO.Text.Trim() : txtWORK_NO.Text.Trim(); objSystemBll.UpdateUser(objSystem); } else { objSystem = new SystemUser(); objSystem.EmployeeID = Convert.ToInt32(id); objSystem.Memo = ""; objSystem.Password = "******"; objSystem.RoleID = 0; objSystem.UserID = txtWORK_NO.Text.Trim() == string.Empty ? txtIDENTITY_CARDNO.Text.Trim() : txtWORK_NO.Text.Trim(); objSystemBll.AddUser(objSystem); } } else { RailExam.Model.SystemUser objSystem = new SystemUser(); objSystem.EmployeeID = Convert.ToInt32(id); objSystem.Memo = ""; objSystem.Password = "******"; objSystem.RoleID = 0; objSystem.UserID = txtWORK_NO.Text.Trim() == string.Empty ? txtIDENTITY_CARDNO.Text.Trim() : txtWORK_NO.Text.Trim(); objSystemBll.AddUser(objSystem); } if (!string.IsNullOrEmpty(fileUpload1.PostedFile.FileName)) { string str = Server.MapPath("/RailExamBao/Excel/image"); if (!Directory.Exists(str)) { Directory.CreateDirectory(str); } string strFileName = Path.GetFileName(fileUpload1.PostedFile.FileName); string strPath = Server.MapPath("/RailExamBao/Excel/image/" + strFileName); if (File.Exists(strPath)) { File.Delete(strPath); } FileInfo fi = new FileInfo(fileUpload1.PostedFile.FileName); string extensions = ".jpg,.jpeg,.gif"; if (!extensions.Contains(fi.Extension.ToLower())) { this.ClientScript.RegisterStartupScript(this.GetType(), "OK", "alert('只能上传GIF, JPEG(JPG)格式的图片!');", true); return; } ((HttpPostedFile)fileUpload1.PostedFile).SaveAs(strPath); this.myImagePhoto.ImageUrl = strPath; AddImage(Int32.Parse(id), strPath); } SystemLogBLL objLogBll = new SystemLogBLL(); objLogBll.WriteLog("保存职工:" + txtEMPLOYEE_NAME.Text + "的档案信息!"); } catch (Exception ex) { this.ClientScript.RegisterStartupScript(this.GetType(), "OK", "alert('" + ex.Message + "');", true); return; } string OrgID = this.hfOrgID.Value; OrganizationBLL objBll = new OrganizationBLL(); string idpath = Request.QueryString.Get("idpath"); if (string.IsNullOrEmpty(Request.QueryString.Get("style"))) { string strQuery = Request.QueryString.Get("strQuery"); this.ClientScript.RegisterStartupScript(this.GetType(), "OK", "this.location.href='EmployeeInfo.aspx?ID=" + OrgID + "&idpath=" + idpath + "&type=Org&strQuery=" + strQuery + "';", true); } else { this.ClientScript.RegisterStartupScript(this.GetType(), "OK", "top.returnValue='true';top.close();", true); } } }
private void SaveEmployeeInfo() { EmployeeBLL objBll =new EmployeeBLL(); RailExam.Model.Employee obj = new RailExam.Model.Employee(); obj.EmployeeName = txtEmployeeNameEdit.Text; obj.WorkNo = txtWorkNoEdit.Text; obj.Address = txtAddress.Text; obj.BeginDate = DateTime.Parse(dateBeginDate.DateValue.ToString()); obj.Birthday = DateTime.Parse(dateBirthday.DateValue.ToString()); obj.Folk = txtFolk.Text; obj.PostID = Convert.ToInt32(hfPostID.Value); obj.OrgID = Convert.ToInt32(hfOrgID.Value); obj.Sex = ddlSex.SelectedValue; obj.NativePlace = txtNativePlace.Text; obj.Wedding = Convert.ToInt32(rblWedding.SelectedValue); obj.WorkPhone = txtWorkPhoneEdit.Text; obj.HomePhone = txtHomePhone.Text; obj.MobilePhone = txtMobilePhone.Text; obj.PostCode = txtPostCode.Text; obj.IsOnPost = !chDimission.Checked; obj.Memo = txtMemoEdit.Text; obj.IsGroupLeader = Convert.ToInt32(ddlIsGroup.SelectedValue); obj.TechnicianTypeID = Convert.ToInt32(ddlTech.SelectedValue); obj.PostNo = txtPostNo.Text; obj.PinYinCode = Pub.GetChineseSpell(obj.EmployeeName); SystemUserBLL objSystemBll = new SystemUserBLL(); if (hfType.Value == "Edit") { obj.EmployeeID = Convert.ToInt32(Request.QueryString.Get("id")); objBll.UpdateEmployee(obj); RailExam.Model.SystemUser objSystem = objSystemBll.GetUserByEmployeeID(obj.EmployeeID); if(objSystem != null) { objSystem.RoleID = Convert.ToInt32(ddlRoleNameEdit.SelectedValue); objSystem.UserID = obj.WorkNo; objSystemBll.UpdateUser(objSystem); } else { objSystem = new SystemUser(); objSystem.EmployeeID = obj.EmployeeID; objSystem.Memo = ""; objSystem.Password = "******"; objSystem.RoleID = Convert.ToInt32(ddlRoleNameEdit.SelectedValue); objSystem.UserID = obj.WorkNo; objSystemBll.AddUser(objSystem); } } else { obj.LoginTime = 0; obj.LoginCount = 0; int id = objBll.AddEmployee(obj); RailExam.Model.SystemUser objSystem = new SystemUser(); objSystem.EmployeeID = id; objSystem.Memo = ""; objSystem.Password = "******"; objSystem.RoleID = Convert.ToInt32(ddlRoleNameEdit.SelectedValue); objSystem.UserID = obj.WorkNo; objSystemBll.AddUser(objSystem); } }
private void SaveEmployeeInfo() { EmployeeDetailBLL objBll = new EmployeeDetailBLL(); RailExam.Model.EmployeeDetail obj = new RailExam.Model.EmployeeDetail(); obj.EmployeeName = txtEmployeeNameEdit.Text; obj.WorkNo = txtWorkNoEdit.Text; obj.Address = txtAddress.Text; obj.BeginDate = DateTime.Parse(dateBeginDate.DateValue.ToString()); obj.Birthday = DateTime.Parse(dateBirthday.DateValue.ToString()); obj.PostID = Convert.ToInt32(hfPostID.Value); obj.OrgID = Convert.ToInt32(hfOrgID.Value); obj.Sex = ddlSex.SelectedValue; obj.Dimission = chDimission.Checked; obj.HomePhone = txtHomePhone.Text; obj.Memo = txtMemoEdit.Text; obj.IsGroupLeader = Convert.ToInt32(ddlIsGroup.SelectedValue); obj.TechnicianTypeID = Convert.ToInt32(ddlTech.SelectedValue); obj.PostNo = txtPostNo.Text; obj.PinYinCode = Pub.GetChineseSpell(obj.EmployeeName); obj.Folk = txtFolk.Text; obj.NativePlace = txtNativePlace.Text; obj.Wedding = Convert.ToInt32(rblWedding.SelectedValue); obj.WorkPhone = txtWorkPhoneEdit.Text; obj.PostCode = txtPostCode.Text; obj.MobilePhone = txtMobilePhone.Text; obj.WorkDate = DateTime.Parse(workDate.DateValue.ToString()); obj.EducationLevelID = Convert.ToInt32(ddlEducationLevel.SelectedValue); obj.PoliticalStatusID = Convert.ToInt32(ddlPolictical.SelectedValue); obj.GraduateUniversity = txtUniversity.Text; obj.StudyMajor = txtStudy.Text; obj.IdentifyCode = txtIdentifyCode.Text; obj.EmployeeTypeID = Convert.ToInt32(ddlEmployeeTypeID.SelectedValue); obj.TechnicalTitleID = Convert.ToInt32(ddlTechTitle.SelectedValue); obj.EmployeeLevelID = Convert.ToInt32(ddlEmployeeLevel.SelectedValue); obj.WorkGroupLeaderTypeID = Convert.ToInt32(ddlWorkGroup.SelectedValue); obj.EducationEmployeeTypeID = Convert.ToInt32(ddlEducationEmployeeType.SelectedValue); obj.CommitteeHeadShipID = Convert.ToInt32(ddlHeadship.SelectedValue); obj.EmployeeTransportTypeID = Convert.ToInt32(ddlEmployeeTransportType.SelectedValue); obj.TeacherTypeID = Convert.ToInt32(ddlTeacherType.SelectedValue); chkApprove.Checked = (obj.ApprovePost == 1); SystemUserBLL objSystemBll = new SystemUserBLL(); if (hfType.Value == "Edit") { obj.EmployeeID = Convert.ToInt32(Request.QueryString.Get("id")); objBll.UpdateEmployee(obj); RailExam.Model.SystemUser objSystem = objSystemBll.GetUserByEmployeeID(obj.EmployeeID); objSystem.RoleID = Convert.ToInt32(ddlRoleNameEdit.SelectedValue); objSystem.UserID = obj.WorkNo; objSystemBll.UpdateUser(objSystem); } else { obj.LoginTime = 0; obj.LoginCount = 0; int id = objBll.AddEmployee(obj); RailExam.Model.SystemUser objSystem = objSystemBll.GetUserByEmployeeID(id); objSystem.RoleID = Convert.ToInt32(ddlRoleNameEdit.SelectedValue); objSystemBll.UpdateUser(objSystem); } }