protected void btnSave_Click(object sender, EventArgs e) { SystemUserBLL systemUserBll = new SystemUserBLL(); SystemUser systemUser = systemUserBll.GetUserByEmployeeID(PrjPub.CurrentLoginUser.EmployeeID); string strOldPassword = systemUser.Password; if (strOldPassword != txtOldPassword.Text) { SessionSet.PageMessage = "原始密码错误!"; return; } if (PrjPub.IsServerCenter) { systemUser.Password = txtNewPassword.Text; systemUser.Flag = false; systemUserBll.UpdateUser(systemUser); } else { systemUserBll.UpdateUserPsw(lblUserID.Text, txtNewPassword.Text); } Response.Write("<script>alert('修改密码成功!');</script>"); }
private void FrmLogIn_Load(object sender, EventArgs e) { SystemUserBLL userBLL = new SystemUserBLL(); int userCount = userBLL.GetUserCount(); if (userCount == 0) { SystemUser examinee = new SystemUser { LastName = "Admin", FirstName = "Admin", Username = "******", UserLevel = "Administrator", Pword = "admin001", AccountStatus = true }; userBLL.InsertUser(examinee); MessageBox.Show("There is no user account in this software.\n\nThe software created an Administrator account.\nUsername: admin001\nPassword: admin001\n\nPlease change its information after this log in.\nThank you", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); txtUsername.Text = "admin001"; txtPassword.Text = "admin001"; DoLogIn(); } }
private void GetRoleInfo(int employeeID) { SystemUserBLL objSystemBll = new SystemUserBLL(); RailExam.Model.SystemUser objSystem = objSystemBll.GetUserByEmployeeID(employeeID); ddlRoleNameEdit.SelectedValue = objSystem.RoleID.ToString(); }
public UCtrlUser() { InitializeComponent(); _userBLL = new SystemUserBLL(); // create UserBLL object dgvUser.AutoGenerateColumns = false; // set to false because I'm using view model with more columns that are not needed PopulateUserDatagridView(); // populate user datagridview }
public Frm_MainForm() { InitializeComponent(); userBll = new SystemUserBLL(); ((ToolStripMenuItem)menuStrip1.Items[0]).DropDownItems.CopyTo(t1, 0); ((ToolStripMenuItem)menuStrip1.Items[1]).DropDownItems.CopyTo(t2, 0); ((ToolStripMenuItem)menuStrip1.Items[2]).DropDownItems.CopyTo(t3, 0); ((ToolStripMenuItem)menuStrip1.Items[3]).DropDownItems.CopyTo(t4, 0); //加载窗体皮肤 skinEngine = new SkinEngine(); }
/// <summary> /// 记时 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Callback1_Callback(object sender, CallBackEventArgs e) { if (PrjPub.IsWuhan()) { return; } if (string.IsNullOrEmpty(e.Parameters[0].ToString()) || string.IsNullOrEmpty(e.Parameters[1].ToString())) { return; } DateTime starttime; DateTime endtime; try { starttime = Convert.ToDateTime(e.Parameters[0]); endtime = Convert.ToDateTime(e.Parameters[1]); } catch { return; } TimeSpan ts = endtime.Subtract(starttime); int spanLoginTime = ts.Hours * 3600 + ts.Minutes * 60 + ts.Seconds; EmployeeBLL employeeBLL = new EmployeeBLL(); Employee employyee = employeeBLL.GetEmployee(Convert.ToInt32(e.Parameters[2])); int oldLogintime = employyee.LoginTime; employyee.LoginTime = oldLogintime + spanLoginTime; SystemUserBLL systemUserBLL = new SystemUserBLL(); SystemUser loginUser = systemUserBLL.GetUserByEmployeeID(Convert.ToInt32(e.Parameters[2])); SessionSet.UserID = loginUser.UserID; SessionSet.EmployeeID = loginUser.EmployeeID; SessionSet.EmployeeName = employyee.EmployeeName; SessionSet.OrganizationID = employyee.OrgID; SessionSet.OrganizationName = employyee.OrgName; if (PrjPub.IsServerCenter) { employeeBLL.UpdateEmployee(employyee); } else { employeeBLL.UpdateEmployeeInStation(employyee); } }
private void DeleteData(int nRoleID) { SystemUserBLL objBll = new SystemUserBLL(); IList <SystemUser> objList = objBll.GetUsersByRoleID(nRoleID); if (objList.Count > 0) { SessionSet.PageMessage = "该角色已被引用,不能删除!"; return; } SystemRoleBLL systemRoleBLL = new SystemRoleBLL(); systemRoleBLL.DeleteRole(nRoleID); }
private void deleteEmployee() { string templateFileName = Server.MapPath("/RailExamBao/RandomExam/ProgressBar.htm"); StreamReader reader = new StreamReader(@templateFileName, System.Text.Encoding.GetEncoding("gb2312")); string html = reader.ReadToEnd(); reader.Close(); Response.Write(html); Response.Flush(); System.Threading.Thread.Sleep(200); SystemUserBLL systemUserBll = new SystemUserBLL(); EmployeeBLL objBll = new EmployeeBLL(); IList <Employee> objList = objBll.GetEmployeeByWhereClause("GetStationOrgID(Org_ID)=" + Request.QueryString.Get("OrgID")); string jsBlock; int NowCount = 0; foreach (Employee employee in objList) { IList <SystemUser> systemUser = systemUserBll.GetUsersByEmployeeID(employee.EmployeeID); if (systemUser.Count > 0) { if (systemUser[0].RoleID != 123 && systemUser[0].RoleID != 1 && systemUser[0].RoleID != 2) { systemUserBll.DeleteUser(systemUserBll.GetUserByEmployeeID(employee.EmployeeID)); objBll.DeleteEmployee(employee.EmployeeID); } } else { objBll.DeleteEmployee(employee.EmployeeID); } NowCount = NowCount + 1; System.Threading.Thread.Sleep(10); jsBlock = "<script>SetPorgressBar('删除员工','" + ((double)(NowCount * 100) / ((double)objList.Count)).ToString("0.00") + "'); </script>"; Response.Write(jsBlock); Response.Flush(); } jsBlock = "<script>SetCompleted('处理完成。'); </script>"; Response.Write(jsBlock); Response.Flush(); Response.Write("<script>top.returnValue='true';window.close();</script>"); }
CheckBox[] c4 = new CheckBox[2]; //用户管理权限控件数组 public Frm_SystemUser() { InitializeComponent(); userBLL = new SystemUserBLL(); encrypt = new Encrypt(); //绑定获取所有的用户ID(方法:1 2 3 4 ) //方法 2 3 4 定义一个泛型集合 List <SystemUser> userIDList = userBLL.GetList(); List <string> idList = new List <string>(); //方法1.写GetAllUserID只获取用户ID的存储过程 //BindlistBox(); //方法2.用Foreach循环 foreach (SystemUser u in userIDList) { if (u.UserID != "admin") { idList.Add(u.UserID); } } lbUserList.DataSource = idList; lbUserList.SelectedIndex = -1; //方法3.用Lingq表达式 //方法4.用Linbada表达式 //给相应的数组赋值(值为控件名) c1[0] = cbCategoryManagement; c1[1] = cbProductInfoManagement; c1[2] = cbSupplierInfoManagement; c1[3] = cbCustomerInfoManagement; c1[4] = cbEmployeesInfoManagement; c2[0] = cbFillPurchaseBill; c2[1] = cbExamPurchaseBill; c2[2] = cbInStockCheck; c3[0] = cbSalesManagement; c3[1] = cbSalesReturn; c4[0] = cbChangeThePassword; c4[1] = cbUserManagement; }
public Frm_SystemUser() { InitializeComponent(); sBLL = new SystemUserBLL(); c1[0] = cbProduct; c1[1] = cbProductInfo; c1[2] = cbSupplier; c1[3] = cbCustomer; c1[4] = cbEmployee; c2[0] = cbFillPurchaseBill; c2[1] = cbExamPurchaseBill; c2[2] = cbInStockCheck; c3[0] = cbSaleInfo; c3[1] = cbSaleReturn; c4[0] = cbChangPWD; c4[1] = cbSystemUser; }
protected void Page_Load(object sender, EventArgs e) { if (PrjPub.CurrentLoginUser == null) { Response.Redirect("../Common/Error.aspx?error=Session过期请重新登录本系统!"); return; } if (!IsPostBack) { hfLoginID.Value = PrjPub.CurrentLoginUser.EmployeeID.ToString(); if (PrjPub.HasEditRight("职员管理") && PrjPub.IsServerCenter) { HfUpdateRight.Value = "True"; } else { HfUpdateRight.Value = "False"; } if (PrjPub.HasDeleteRight("职员管理") && PrjPub.IsServerCenter) { HfDeleteRight.Value = "True"; } else { HfDeleteRight.Value = "False"; } string strQuery = Request.QueryString.Get("strQuery"); if (!string.IsNullOrEmpty(strQuery)) { string[] str = strQuery.Split('|'); txtName.Text = str[0]; ddlSex.SelectedValue = str[1]; ddlStatus.SelectedValue = str[2]; txtPinYin.Text = str[3]; txtTechnicalCode.Text = str[4]; hfPostID.Value = str[5]; } gridBind(); } string strRefresh = Request.Form.Get("Refresh"); if (!string.IsNullOrEmpty(strRefresh)) { gridBind(); } string strUpdate = Request.Form.Get("UpdatePsw"); if (!string.IsNullOrEmpty(strUpdate)) { SystemUserBLL objBll = new SystemUserBLL(); SystemUser obj = objBll.GetUserByEmployeeID(Convert.ToInt32(strUpdate)); if (obj != null) { obj.Password = "******"; if (PrjPub.IsServerCenter) { objBll.UpdateUser(obj); } else { objBll.UpdateUserPsw(obj.UserID, "111111"); } SessionSet.PageMessage = "初始化密码成功!"; } else { SessionSet.PageMessage = "该员工登录帐户不存在,初始化密码失败!"; } gridBind(); } string strDelete = Request.Form.Get("Delete"); if (!string.IsNullOrEmpty(strDelete)) { try { OracleAccess db = new OracleAccess(); if (PrjPub.CurrentLoginUser.EmployeeID != 0) { //判断该员工是否参加过考试 string strIsArrange = string.Format( "select count(1) from random_exam_arrange where ','||user_ids||',' like '%,{0},%'", strDelete); if (Convert.ToInt32(db.RunSqlDataSet(strIsArrange).Tables[0].Rows[0][0]) > 0) { ClientScript.RegisterStartupScript(GetType(), "NO", "alert('该员工已参加考试,不能删除!');", true); return; } string strSql = "delete from Employee where Employee_ID=" + strDelete; db.ExecuteNonQuery(strSql); } else { string strSql = "select * from Employee where Employee_ID=" + strDelete; DataRow dr = db.RunSqlDataSet(strSql).Tables[0].Rows[0]; EmployeeBLL employeebll = new EmployeeBLL(); employeebll.DeleteEmployee(Convert.ToInt32(strDelete)); SystemLogBLL systemLogBLL = new SystemLogBLL(); systemLogBLL.WriteLog("删除员工:" + dr["Employee_Name"] + "(" + dr["Work_No"] + ")基本信息"); } gridBind(); } catch { SessionSet.PageMessage = "该员工已被引用,不能删除!"; } } if (!string.IsNullOrEmpty(hfPostID.Value)) { PostBLL post = new PostBLL(); txtPost.Text = post.GetPost(Convert.ToInt32(hfPostID.Value)).PostName; } }
public Frm_Main() { InitializeComponent(); sBLL = new SystemUserBLL(); }
private void Import(int type, string strID) { EmployeeErrorBLL objBll = new EmployeeErrorBLL(); EmployeeError objError = new EmployeeError(); objError = objBll.GetEmployeeError(Convert.ToInt32(strID)); #region 检测员工信息 Hashtable htOrg = GetOrgInfo(); Hashtable htPost = GetPostInfo(); Hashtable htEducationLevel = GetEducationLevel(); Hashtable htPoliticalStatus = GetPoliticalStatus(); Hashtable htEmployeeType = GetEmployeeType(); Hashtable htWorkGroupLeaderType = GetWorkGroupLeaderType(); Hashtable htEducationEmployeeType = GetEducationEmployeeType(); Hashtable htCommitteeHeadship = GetCommitteeHeadship(); Hashtable htEmployeeTransportType = GetEmployeeTransportType(); Hashtable htTechnicalTitle = GetTechnicalTitle(); Hashtable htSkillLevel = GetSkillLevel(); Hashtable htEmployeeLevel = GetEmployeeLevel(); Hashtable htTeacherType = GetTeacherType(); Hashtable htShopNeedAdd = new Hashtable(); Hashtable htPostNo = new Hashtable(); //为检测Excel中员工编码是否重复 Hashtable htPostNeedAdd = new Hashtable(); Hashtable htSalaryNo = new Hashtable(); PostBLL objPostBll = new PostBLL(); EmployeeBLL objEmployeeBll = new EmployeeBLL(); EmployeeDetailBLL objDetailBll = new EmployeeDetailBLL(); RailExam.Model.EmployeeDetail objEmployee = new RailExam.Model.EmployeeDetail(); if (type == 2) { objEmployee = objDetailBll.GetEmployee(objError.EmployeeID); } //单位名称 if (objError.OrgName != txtOrg.Text) { SessionSet.PageMessage = "单位名称填写错误"; return; } if (objError.OrgPath == "") { SessionSet.PageMessage = "部门名称不能为空"; return; } //组织机构 string strOrg; if (string.IsNullOrEmpty(objError.GroupName)) { strOrg = objError.OrgName + "-" + objError.OrgPath; } else { strOrg = objError.OrgName + "-" + objError.OrgPath + "-" + objError.GroupName; } if (!htOrg.ContainsKey(strOrg)) { if (string.IsNullOrEmpty(objError.GroupName)) { if (!htShopNeedAdd.ContainsKey(objError.OrgPath)) { htShopNeedAdd.Add(objError.OrgPath, new Hashtable()); } //如果组织机构需要新增 objEmployee.Memo = strOrg; } else { if (!htShopNeedAdd.ContainsKey(objError.OrgPath)) { htShopNeedAdd.Add(objError.OrgPath, new Hashtable()); } Hashtable htGroupNeedAdd = (Hashtable)htShopNeedAdd[objError.OrgPath]; if (!htGroupNeedAdd.ContainsKey(objError.GroupName)) { htGroupNeedAdd.Add(objError.GroupName, objError.GroupName); htShopNeedAdd[objError.OrgPath] = htGroupNeedAdd; } //如果组织机构需要新增 objEmployee.Memo = strOrg; } } else { objEmployee.OrgID = Convert.ToInt32(htOrg[strOrg]); objEmployee.Memo = string.Empty; } //姓名不能为空 if (string.IsNullOrEmpty(objError.EmployeeName)) { SessionSet.PageMessage = "员工姓名不能为空"; return; } else { if (objError.EmployeeName.Length > 20) { SessionSet.PageMessage = "员工姓名不能超过20位"; return; } objEmployee.EmployeeName = objError.EmployeeName; objEmployee.PinYinCode = Pub.GetChineseSpell(objError.EmployeeName); } //身份证号不能为空 if (string.IsNullOrEmpty(objError.IdentifyCode)) { SessionSet.PageMessage = "身份证号不能为空"; return; } else { if (objError.IdentifyCode.Length > 18) { SessionSet.PageMessage = "身份证号不能超过18位"; return; } objEmployee.IdentifyCode = objError.IdentifyCode; } //工作证号 if (!string.IsNullOrEmpty(objError.PostNo)) { if (objError.PostNo.Length > 14) { SessionSet.PageMessage = "工作证号不能超过14位"; return; } objEmployee.PostNo = objError.PostNo; } else { objEmployee.PostNo = ""; } //性别 if (objError.Sex != "男" && objError.Sex != "女") { SessionSet.PageMessage = "性别必须为男或女"; return; } else { objEmployee.Sex = objError.Sex; } //籍贯 if (!string.IsNullOrEmpty(objError.NativePlace)) { if (objError.NativePlace.Length > 20) { SessionSet.PageMessage = "籍贯不能超过20位"; return; } else { objEmployee.NativePlace = objError.NativePlace; } } else { objEmployee.NativePlace = string.Empty; } //民族 if (!string.IsNullOrEmpty(objError.Folk)) { if (objError.Folk.Length > 10) { SessionSet.PageMessage = "民族不能超过10位"; return; } else { objEmployee.Folk = objError.Folk; } } else { objEmployee.Folk = string.Empty; } //婚姻状况 if (objError.Wedding == "未婚") { objEmployee.Wedding = 0; } else { objEmployee.Wedding = 1; } //现文化程度 if (string.IsNullOrEmpty(objError.EducationLevel)) { SessionSet.PageMessage = "现文化程度不能为空"; return; } else { if (!htEducationLevel.ContainsKey(objError.EducationLevel)) { SessionSet.PageMessage = "现文化程度在系统中不存在"; return; } else { objEmployee.EducationLevelID = Convert.ToInt32(htEducationLevel[objError.EducationLevel]); } } //政治面貌 if (!string.IsNullOrEmpty(objError.PoliticalStatus)) { if (!htPoliticalStatus.ContainsKey(objError.PoliticalStatus)) { SessionSet.PageMessage = "政治面貌在系统中不存在"; return; } else { objEmployee.PoliticalStatusID = Convert.ToInt32(htPoliticalStatus[objError.PoliticalStatus]); } } //毕(肄)业学校(单位) if (!string.IsNullOrEmpty(objError.GraduateUniversity)) { if (objError.GraduateUniversity.Length > 50) { SessionSet.PageMessage = "毕(肄)业学校(单位)不能超过50位"; return; } else { objEmployee.GraduateUniversity = objError.GraduateUniversity; } } else { objError.GraduateUniversity = string.Empty; } //所学专业 if (!string.IsNullOrEmpty(objEmployee.StudyMajor)) { if (objEmployee.StudyMajor.Length > 50) { SessionSet.PageMessage = "所学专业不能超过50位"; return; } else { objEmployee.StudyMajor = objEmployee.StudyMajor; } } else { objEmployee.StudyMajor = string.Empty; } //工作地址 if (!string.IsNullOrEmpty(objError.Address)) { if (objError.Address.Length > 100) { SessionSet.PageMessage = "工作地址不能超过100位"; return; } else { objEmployee.Address = objError.Address; } } else { objEmployee.Address = string.Empty; } //邮政编码 if (!string.IsNullOrEmpty(objEmployee.PostCode)) { if (objError.PostCode.Length > 6) { SessionSet.PageMessage = "邮政编码不能超过6位"; return; } else { objEmployee.PostCode = objError.PostCode; } } else { objEmployee.PostCode = string.Empty; } //职务级别 if (!string.IsNullOrEmpty(objError.EmployeeLevel)) { if (!htEmployeeLevel.ContainsKey(objError.EmployeeLevel)) { SessionSet.PageMessage = "职务级别在系统中不存在"; return; } else { objEmployee.EmployeeLevelID = Convert.ToInt32(htEmployeeLevel[objError.EmployeeLevel]); } } //出生日期 try { string strBirth = objError.Birthday; if (strBirth.IndexOf("-") >= 0) { objEmployee.Birthday = Convert.ToDateTime(strBirth); } else { if (strBirth.Length != 8) { SessionSet.PageMessage = "出生日期填写错误"; return; } else { strBirth = strBirth.Insert(4, "-"); strBirth = strBirth.Insert(7, "-"); objEmployee.Birthday = Convert.ToDateTime(strBirth); } } if (Convert.ToDateTime(strBirth) < Convert.ToDateTime("1775-1-1") || Convert.ToDateTime(strBirth) > Convert.ToDateTime("1993-12-31")) { SessionSet.PageMessage = "出生日期填写错误"; return; } } catch { SessionSet.PageMessage = "出生日期填写错误"; return; } //入路工作日期 try { string strJoin = objError.WorkDate; if (strJoin.IndexOf("-") >= 0) { objEmployee.WorkDate = Convert.ToDateTime(strJoin); } else { if (strJoin.Length != 8) { SessionSet.PageMessage = "入路工作日期填写错误"; return; } else { strJoin = strJoin.Insert(4, "-"); strJoin = strJoin.Insert(7, "-"); objEmployee.WorkDate = Convert.ToDateTime(strJoin); } } if (Convert.ToDateTime(strJoin) < Convert.ToDateTime("1775-1-1")) { SessionSet.PageMessage = "入路工作日期填写错误"; return; } } catch { SessionSet.PageMessage = "入路工作日期填写错误"; return; } //参加工作日期 try { string strJoin = objError.BeginDate; if (strJoin.IndexOf("-") >= 0) { objEmployee.BeginDate = Convert.ToDateTime(strJoin); } else { if (strJoin.Length != 8) { SessionSet.PageMessage = "参加工作日期填写错误"; return; } else { strJoin = strJoin.Insert(4, "-"); strJoin = strJoin.Insert(7, "-"); objEmployee.BeginDate = Convert.ToDateTime(strJoin); } } if (Convert.ToDateTime(strJoin) < Convert.ToDateTime("1775-1-1")) { SessionSet.PageMessage = "参加工作日期填写错误"; return; } } catch { SessionSet.PageMessage = "参加工作日期填写错误"; return; } //干部工人标识 if (string.IsNullOrEmpty(objError.EmployeeType)) { SessionSet.PageMessage = "干部工人标识不能为空!"; return; } else { if (!htEmployeeType.ContainsKey(objError.EmployeeType)) { SessionSet.PageMessage = "干部工人标识在系统中不存在!"; return; } else { objEmployee.EmployeeTypeID = Convert.ToInt32(htEmployeeType[objError.EmployeeType]); } } if (objEmployee.EmployeeTypeID == 1) { //岗位 if (string.IsNullOrEmpty(objError.PostPath)) { SessionSet.PageMessage = "岗位不能为空!"; return; } else { IList <RailExam.Model.Post> objPost = objPostBll.GetPostsByWhereClause("Post_Level=3 and Post_Name='" + objError.PostPath + "'"); if (objPost.Count == 0) { SessionSet.PageMessage = "岗位在系统中不存在!"; return; } objEmployee.PostID = Convert.ToInt32(htPost[objError.PostPath]); } } else { //岗位 if (string.IsNullOrEmpty(objError.PostPath)) { SessionSet.PageMessage = "职务不能为空!"; return; } else { IList <RailExam.Model.Post> objPost = objPostBll.GetPostsByWhereClause("Post_Level=3 and Post_Name='" + objError.PostPath + "'"); if (objPost.Count == 0) { htPostNeedAdd.Add(objError.PostPath, objError.PostPath); } else { objEmployee.PostID = objPost[0].PostId; } } } //班组长类型 if (string.IsNullOrEmpty(objError.WorkGroupLeader)) { objEmployee.IsGroupLeader = 0; } else { if (!htWorkGroupLeaderType.ContainsKey(objError.WorkGroupLeader)) { SessionSet.PageMessage = "班组长类型在系统中不存在!"; return; } objEmployee.WorkGroupLeaderTypeID = Convert.ToInt32(htWorkGroupLeaderType[objError.WorkGroupLeader]); objEmployee.IsGroupLeader = 1; } if (!string.IsNullOrEmpty(objError.EducationEmployee)) { if (!htEducationEmployeeType.ContainsKey(objError.EducationEmployee)) { SessionSet.PageMessage = "职教干部类型在系统中不存在!"; return; } else { objEmployee.EducationEmployeeTypeID = Convert.ToInt32(htEducationEmployeeType[objError.EducationEmployee]); } } //职教委员会职务 if (!string.IsNullOrEmpty(objError.CommitteeHeadShip)) { if (!htCommitteeHeadship.ContainsKey(objError.CommitteeHeadShip)) { SessionSet.PageMessage = "职教委员会职务在系统中不存在!"; return; } else { objEmployee.CommitteeHeadShipID = Convert.ToInt32(htCommitteeHeadship[objError.CommitteeHeadShip]); } } //教师类别 if (!string.IsNullOrEmpty(objError.TeacherType)) { if (!htTeacherType.ContainsKey(objError.TeacherType)) { SessionSet.PageMessage = "教师类别在系统中不存在"; return; } else { objEmployee.TeacherTypeID = Convert.ToInt32(htTeacherType[objError.TeacherType]); } } //人员岗位状态 if (objError.OnPost != "在岗工作") { objEmployee.Dimission = true; } else { objEmployee.Dimission = false; } //在岗职工按岗位分组 if (string.IsNullOrEmpty(objError.EmployeeTransportType)) { //SessionSet.PageMessage = "当单位名称为“运输业”时,在岗职工按岗位分组不能为空!"; //return; } else { if (!htEmployeeTransportType.ContainsKey(objError.EmployeeTransportType)) { SessionSet.PageMessage = "在岗职工按岗位分组在系统中不存在!"; return; } else { objEmployee.EmployeeTransportTypeID = Convert.ToInt32(htEmployeeTransportType[objError.EmployeeTransportType]); } } //现技术职务名称 if (objEmployee.EmployeeTypeID == 1) { if (!string.IsNullOrEmpty(objError.TechnicalTitle)) { SessionSet.PageMessage = "当干部工人标识为“工人”时,现技术职务名称必须为空!"; return; } } else { if (!string.IsNullOrEmpty(objError.TechnicalTitle)) { if (!htTechnicalTitle.ContainsKey(objError.TechnicalTitle)) { SessionSet.PageMessage = "现技术职务名称在系统中不存在!"; return; } else { objEmployee.TechnicalTitleID = Convert.ToInt32(htTechnicalTitle[objError.TechnicalTitle]); } } } //技术等级 if (objEmployee.EmployeeTypeID == 1) { if (!string.IsNullOrEmpty(objError.TechnicalSkill)) { if (!htSkillLevel.ContainsKey(objError.TechnicalSkill)) { SessionSet.PageMessage = "技术等级在系统中不存在!"; return; } else { objEmployee.TechnicianTypeID = Convert.ToInt32(htSkillLevel[objError.TechnicalSkill]); } } else { objEmployee.TechnicianTypeID = 1; } } else { objEmployee.TechnicianTypeID = 1; } //岗位培训合格证编号 if (!string.IsNullOrEmpty(objError.SalaryNo)) { if (objError.SalaryNo.Length > 20) { SessionSet.PageMessage = "岗位培训合格证编号不能超过20位"; return; } //工作证号在Excel中不能重复 if (htPostNo.ContainsKey(objError.SalaryNo)) { SessionSet.PageMessage = "岗位培训合格证编号在Excel中与序号为" + htPostNo[objError.SalaryNo] + "的岗位培训合格证编号重复"; return; } else { htPostNo.Add(objError.SalaryNo, objError.ExcelNo); } IList <RailExam.Model.Employee> objView = new List <RailExam.Model.Employee>(); if (type == 1) { objView = objEmployeeBll.GetEmployeeByWhereClause("Home_Phone='" + objError.SalaryNo + "'"); } else if (type == 2) { objView = objEmployeeBll.GetEmployeeByWhereClause("a.Employee_ID != " + objEmployee.EmployeeID + " and Home_Phone='" + objError.SalaryNo + "'"); } if (objView.Count > 0) { SessionSet.PageMessage = "岗位培训合格证编号已在系统中存在"; return; } objEmployee.HomePhone = objError.SalaryNo; } else { objEmployee.HomePhone = string.Empty; } if (!string.IsNullOrEmpty(objError.WorkNo)) { if (objError.WorkNo.Length > 20) { SessionSet.PageMessage = "工资编号不能超过20位"; return; } //工作证号在Excel中不能重复 if (htSalaryNo.ContainsKey(objError.WorkNo)) { SessionSet.PageMessage = "工资编号在Excel中与序号为" + htSalaryNo[objError.WorkNo] + "的工资编号重复"; return; } else { htSalaryNo.Add(objError.WorkNo, objError.ExcelNo); } IList <RailExam.Model.EmployeeDetail> objView = new List <RailExam.Model.EmployeeDetail>(); if (type == 1) { objView = objDetailBll.GetEmployeeByWhereClause("GetStationOrgID(a.Org_ID)=" + hfOrg.Value + " and Work_No='" + objError.WorkNo + "'"); } else if (type == 2) { objView = objDetailBll.GetEmployeeByWhereClause("a.Employee_ID != " + objEmployee.EmployeeID + " and GetStationOrgID(a.Org_ID)=" + hfOrg.Value + " and Work_No='" + objError.WorkNo + "'"); } if (objView.Count > 0) { SessionSet.PageMessage = "工资编号已在系统中存在"; return; } objEmployee.WorkNo = objError.WorkNo; } else { SessionSet.PageMessage = "工资编号不能为空!"; return; } #endregion if (type == 1) { #region 新增 Database db = DatabaseFactory.CreateDatabase(); DbConnection connection = db.CreateConnection(); connection.Open(); DbTransaction transaction = connection.BeginTransaction(); OrganizationBLL orgBll = new OrganizationBLL(); try { Hashtable htWorkshop = GetWorkShop(db, transaction); foreach (System.Collections.DictionaryEntry obj in htShopNeedAdd) { int nWorkShopID; if (!htWorkshop.ContainsKey(obj.Key.ToString())) { RailExam.Model.Organization objshop = new RailExam.Model.Organization(); objshop.FullName = obj.Key.ToString(); objshop.ShortName = obj.Key.ToString(); objshop.ParentId = Convert.ToInt32(hfOrg.Value); objshop.Memo = ""; nWorkShopID = orgBll.AddOrganization(db, transaction, objshop); } else { nWorkShopID = Convert.ToInt32(htWorkshop[obj.Key.ToString()]); } Hashtable htGroup = (Hashtable)obj.Value; if (htGroup.Count != 0) { foreach (System.Collections.DictionaryEntry objGroupNeedAdd in htGroup) { RailExam.Model.Organization objGroup = new RailExam.Model.Organization(); objGroup.FullName = objGroupNeedAdd.Key.ToString(); objGroup.ShortName = objGroupNeedAdd.Key.ToString(); objGroup.ParentId = nWorkShopID; objGroup.Memo = ""; orgBll.AddOrganization(db, transaction, objGroup); } } } htWorkshop = GetWorkShop(db, transaction); Hashtable htNowOrg = GetOrgInfo(db, transaction); if (!string.IsNullOrEmpty(objEmployee.Memo)) { if (objEmployee.Memo.Split('-').Length == 2) { objEmployee.OrgID = Convert.ToInt32(htWorkshop[objEmployee.Memo.Split('-')[1]]); } else { objEmployee.OrgID = Convert.ToInt32(htNowOrg[objEmployee.Memo.ToString()].ToString().Split('-')[0]); } } if (objEmployee.OrgID == 0) { throw new Exception("aaaa"); } objEmployee.Memo = ""; foreach (System.Collections.DictionaryEntry objPostNeed in htPostNeedAdd) { RailExam.Model.Post objPost = new RailExam.Model.Post(); objPost.ParentId = 373; objPost.PostName = objPostNeed.Key.ToString(); objPost.Technician = 0; objPost.Promotion = 0; objPost.Description = string.Empty; objPost.Memo = string.Empty; int postID = objPostBll.AddPost(db, transaction, objPost); objEmployee.PostID = postID; } objDetailBll.AddEmployee(db, transaction, objEmployee); transaction.Commit(); } catch { transaction.Rollback(); SessionSet.PageMessage = "新增失败!"; return; } finally { connection.Close(); } #endregion } else { #region 修改 Database db = DatabaseFactory.CreateDatabase(); DbConnection connection = db.CreateConnection(); connection.Open(); DbTransaction transaction = connection.BeginTransaction(); OrganizationBLL orgBll = new OrganizationBLL(); try { Hashtable htWorkshop = GetWorkShop(db, transaction); foreach (System.Collections.DictionaryEntry obj in htShopNeedAdd) { int nWorkShopID; if (!htWorkshop.ContainsKey(obj.Key.ToString())) { RailExam.Model.Organization objshop = new RailExam.Model.Organization(); objshop.FullName = obj.Key.ToString(); objshop.ShortName = obj.Key.ToString(); objshop.ParentId = Convert.ToInt32(hfOrg.Value); objshop.Memo = ""; nWorkShopID = orgBll.AddOrganization(db, transaction, objshop); } else { nWorkShopID = Convert.ToInt32(htWorkshop[obj.Key.ToString()]); } Hashtable htGroup = (Hashtable)obj.Value; if (htGroup.Count != 0) { foreach (System.Collections.DictionaryEntry objGroupNeedAdd in htGroup) { RailExam.Model.Organization objGroup = new RailExam.Model.Organization(); objGroup.FullName = objGroupNeedAdd.Key.ToString(); objGroup.ShortName = objGroupNeedAdd.Key.ToString(); objGroup.ParentId = nWorkShopID; objGroup.Memo = ""; orgBll.AddOrganization(db, transaction, objGroup); } } } htWorkshop = GetWorkShop(db, transaction); Hashtable htNowOrg = GetOrgInfo(db, transaction); if (!string.IsNullOrEmpty(objEmployee.Memo)) { if (objEmployee.Memo.Split('-').Length == 2) { objEmployee.OrgID = Convert.ToInt32(htWorkshop[objEmployee.Memo.Split('-')[1]]); } else { objEmployee.OrgID = Convert.ToInt32(htNowOrg[objEmployee.Memo.ToString()].ToString().Split('-')[0]); } } if (objEmployee.OrgID == 0) { throw new Exception("aaaa"); } objEmployee.Memo = ""; foreach (System.Collections.DictionaryEntry objPostNeed in htPostNeedAdd) { RailExam.Model.Post objPost = new RailExam.Model.Post(); objPost.ParentId = 373; objPost.PostName = objPostNeed.Key.ToString(); objPost.Technician = 0; objPost.Promotion = 0; objPost.Description = string.Empty; objPost.Memo = string.Empty; int postID = objPostBll.AddPost(db, transaction, objPost); objEmployee.PostID = postID; } objDetailBll.UpdateEmployee(db, transaction, objEmployee); transaction.Commit(); } catch { transaction.Rollback(); SessionSet.PageMessage = "修改失败!"; return; } finally { connection.Close(); } #endregion SystemUserBLL objUserBll = new SystemUserBLL(); SystemUser objUser = objUserBll.GetUserByEmployeeID(objEmployee.EmployeeID); objUser.UserID = objEmployee.WorkNo; objUserBll.UpdateUser(objUser); } objBll.DeleteEmployeeError(Convert.ToInt32(strID)); }
/// <summary> /// SON OF A BITCH!!! /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (PrjPub.CurrentLoginUser == null) { Response.Redirect("/RailExamBao/Common/Error.aspx?error=Session过期请重新登录本系统!"); return; } if (PrjPub.HasEditRight("职员管理") && PrjPub.IsServerCenter) { HfUpdateRight.Value = "True"; } else { HfUpdateRight.Value = "False"; } string selectStation = "select org_id, short_name from org where level_num = 2 order by parent_id,order_index"; string selectPolitical = "select political_status_id, political_status_name from POLITICAL_STATUS order by order_index"; string selectBZZ = "select workgroupleader_level_id, level_name from WORKGROUPLEADER_LEVEL t order by order_index"; string selectTechicianTitleType = "select technician_title_type_id, type_name from TECHNICIAN_TITLE_TYPE t where order_index < 23 order by order_index"; string selectTechicianType = "select technician_type_id, type_name from TECHNICIAN_TYPE t order by technician_type_id"; string selectEduBg = "select education_level_id, education_level_name from EDUCATION_LEVEL t order by order_index"; DropBindSource(this.dropStation, selectStation); DropBindSource(this.dropPolitical, selectPolitical); ChkListBindSource(this.chkListBZZ, selectBZZ); ChkListBindSource(this.chkListJSZC, selectTechicianTitleType); ChkListBindSource(this.chkListJNDJ, selectTechicianType); ChkListBindSource(this.chkListEduBg, selectEduBg); this.dropStation.SelectedValue = PrjPub.CurrentLoginUser.StationOrgID.ToString(); dropStation_SelectedIndexChanged(null, null); if (PrjPub.CurrentLoginUser.SuitRange == 0) { dropStation.Enabled = false; } OracleAccess access = new OracleAccess(); DataSet ds = access.RunSqlDataSet(" select * from zj_certificate order by order_index"); ListItem item = new ListItem(); item.Value = "0"; item.Text = "--请选择--"; drop_certificate.Items.Add(item); foreach (DataRow dr in ds.Tables[0].Rows) { item = new ListItem(); item.Value = dr["certificate_id"].ToString(); item.Text = dr["certificate_name"].ToString(); drop_certificate.Items.Add(item); } item = new ListItem(); item.Value = "0"; item.Text = "--请选择--"; drop_certificate_Level.Items.Add(item); gridBind(); } string strRefresh = Request.Form.Get("Refresh"); if (!string.IsNullOrEmpty(strRefresh)) { gridBind(); } string strUpdate = Request.Form.Get("UpdatePsw"); if (!string.IsNullOrEmpty(strUpdate)) { SystemUserBLL objBll = new SystemUserBLL(); SystemUser obj = objBll.GetUserByEmployeeID(Convert.ToInt32(strUpdate)); if (obj != null) { obj.Password = "******"; if (PrjPub.IsServerCenter) { objBll.UpdateUser(obj); } else { objBll.UpdateUserPsw(obj.UserID, "111111"); } SessionSet.PageMessage = "初始化密码成功!"; } else { SessionSet.PageMessage = "该员工登录帐户不存在,初始化密码失败!"; } gridBind(); } }
protected void btnImport_Click(object sender, EventArgs e) { if (File1.FileName == "") { SessionSet.PageMessage = "请浏览选择Excel文件!"; return; } string strFileName = Path.GetFileName(File1.PostedFile.FileName); string strPath = Server.MapPath("/RailExamBao/Excel/" + strFileName); if (File.Exists(strPath)) { File.Delete(strPath); } ((HttpPostedFile)File1.PostedFile).SaveAs(strPath); string strSql; string strODConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strPath + "; Extended Properties=Excel 8.0;"; strSql = "select 顺号,站段名称,车间,班组,姓名,系统,工种,职名,性别,工作证号,是否班组长,技能等级 from [Sheet1$]"; OleDbConnection ODcon = new OleDbConnection(strODConn); DataSet ds = new DataSet(); try { ODcon.Open(); OleDbCommand OCom = new OleDbCommand(strSql, ODcon); OleDbDataAdapter ODA = new OleDbDataAdapter(OCom); ODA.Fill(ds); } catch { SessionSet.PageMessage = "请核对Excel文件的格式!"; return; } finally { ODcon.Close(); } IList <RailExam.Model.Employee> objEmployeeList = new List <RailExam.Model.Employee>(); try { DataTable dt = new DataTable(); DataColumn dcnew1 = dt.Columns.Add("ExcelNo"); DataColumn dcnew2 = dt.Columns.Add("WorkNo"); DataColumn dcnew3 = dt.Columns.Add("EmployeeName"); DataColumn dcnew4 = dt.Columns.Add("Sex"); DataColumn dcnew5 = dt.Columns.Add("OrgPath"); DataColumn dcnew6 = dt.Columns.Add("PostPath"); DataColumn dcnew7 = dt.Columns.Add("IsGroup"); DataColumn dcnew8 = dt.Columns.Add("Tech"); OrganizationBLL objOrgBll = new OrganizationBLL(); PostBLL objPostBll = new PostBLL(); EmployeeBLL objBll = new EmployeeBLL(); SystemUserBLL objSystemBll = new SystemUserBLL(); if (ds.Tables[0].Rows.Count == 0) { SessionSet.PageMessage = "Excel中没有任何记录,请核对!"; return; } if (ds.Tables[0].Rows[0]["站段名称"].ToString() != txtOrg.Text.Substring(txtOrg.Text.IndexOf('/') + 1)) { SessionSet.PageMessage = "站段选择错误,请核对!"; return; } //objBll.DeleteEmployeeByOrgID(Convert.ToInt32(hfOrg.Value)); Hashtable htOrg = GetOrgHash(Convert.ToInt32(hfOrg.Value)); Hashtable htPost = GetPostHash(); DataColumn dc1 = ds.Tables[0].Columns.Add("OrgPath"); DataColumn dc2 = ds.Tables[0].Columns.Add("PostPath"); DataColumn dc3 = ds.Tables[0].Columns.Add("OrgID"); DataColumn dc4 = ds.Tables[0].Columns.Add("PostID"); DataColumn dc5 = ds.Tables[0].Columns.Add("IsGroup"); DataColumn dc6 = ds.Tables[0].Columns.Add("TechID"); foreach (DataRow dr in ds.Tables[0].Rows) { if (dr["班组"].ToString() != "") { dr["OrgPath"] = dr["站段名称"].ToString().Trim() + "-" + dr["车间"].ToString().Trim() + "-" + dr["班组"].ToString().Trim(); } else { dr["OrgPath"] = dr["站段名称"].ToString().Trim() + "-" + dr["车间"].ToString().Trim(); } dr["PostPath"] = dr["系统"].ToString().Trim() + "-" + dr["工种"].ToString().Trim() + "-" + dr["职名"].ToString().Trim(); //dr["OrgID"] = objOrgBll.GetOrgIDByOrgNamePath(dr["OrgPath"].ToString()).ToString(); //dr["PostID"] = objPostBll.GetPostIDByPostNamePath(dr["PostPath"].ToString()).ToString(); if (dr["是否班组长"].ToString() == "是") { dr["IsGroup"] = "1"; } else { dr["IsGroup"] = "0"; } if (dr["技能等级"].ToString() == "高级技师") { dr["TechID"] = "3"; } else if (dr["技能等级"].ToString() == "技师") { dr["TechID"] = "2"; } else { dr["TechID"] = "1"; } if (!htOrg.ContainsKey(dr["OrgPath"].ToString()) || !htPost.ContainsKey(dr["PostPath"].ToString()) || dr["工作证号"].ToString() == "") { DataRow drnew = dt.NewRow(); drnew["ExcelNo"] = dr["顺号"].ToString(); drnew["WorkNo"] = dr["工作证号"].ToString(); drnew["EmployeeName"] = dr["姓名"].ToString(); drnew["Sex"] = dr["性别"].ToString(); drnew["OrgPath"] = dr["OrgPath"].ToString(); drnew["PostPath"] = dr["PostPath"].ToString(); drnew["IsGroup"] = dr["是否班组长"].ToString(); drnew["Tech"] = dr["技能等级"].ToString(); dt.Rows.Add(drnew); } else { dr["OrgID"] = htOrg[dr["OrgPath"].ToString()].ToString(); dr["PostID"] = htPost[dr["PostPath"].ToString()].ToString(); RailExam.Model.Employee obj = new RailExam.Model.Employee(); obj.EmployeeName = dr["姓名"].ToString().Trim(); obj.OrgID = Convert.ToInt32(dr["OrgID"].ToString()); obj.PostID = Convert.ToInt32(dr["PostID"].ToString()); obj.Sex = dr["性别"].ToString().Trim(); obj.WorkNo = dr["工作证号"].ToString().Trim(); obj.IsGroupLeader = Convert.ToInt32(dr["IsGroup"].ToString()); obj.TechnicianTypeID = Convert.ToInt32(dr["TechID"].ToString()); obj.PinYinCode = Pub.GetChineseSpell(obj.EmployeeName); obj.IsOnPost = true; objEmployeeList.Add(obj); } } Grid1.DataSource = dt; Grid1.DataBind(); lbltitle.Visible = true; Grid1.Visible = true; btnExcel.Visible = false; objBll.AddEmployeeImport(objEmployeeList); } catch { SessionSet.PageMessage = "导入失败!"; return; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (PrjPub.CurrentLoginUser == null) { Response.Redirect("/RailExamBao/Common/Error.aspx?error=Session过期请重新登录本系统!"); return; } if (PrjPub.HasEditRight("角色权限") && PrjPub.IsServerCenter) { HfUpdateRight.Value = "True"; } else { HfUpdateRight.Value = "False"; } if (PrjPub.HasDeleteRight("角色权限") && PrjPub.IsServerCenter) { HfDeleteRight.Value = "True"; } else { HfDeleteRight.Value = "False"; } if (PrjPub.HasEditRight("职员管理") && PrjPub.IsServerCenter) { HfUpdateRight.Value = "True"; } else { HfUpdateRight.Value = "False"; } if (PrjPub.HasDeleteRight("职员管理") && PrjPub.IsServerCenter) { HfDeleteRight.Value = "True"; } else { HfDeleteRight.Value = "False"; } if (PrjPub.IsWuhan()) { Grid1.Levels[0].Columns[1].HeadingText = "员工编码"; lblTitle.Text = "员工编码"; } else { Grid1.Levels[0].Columns[1].HeadingText = "工资编号"; lblTitle.Text = "工资编号"; } BindGrid(); IsWuhan.Value = PrjPub.IsWuhan().ToString(); IsWuhanOnly.Value = PrjPub.IsWuhanOnly().ToString(); hfAdmin.Value = PrjPub.CurrentLoginUser.IsAdmin.ToString(); NowEmployeeID.Value = PrjPub.CurrentLoginUser.EmployeeID.ToString(); } else { string strDeleteID = Request.Form.Get("DeleteID"); if (!string.IsNullOrEmpty(strDeleteID)) { if (strDeleteID == "1" || strDeleteID == "2") { SessionSet.PageMessage = "该员工为最高权限用户,不能被删除!"; BindGrid(); return; } DeleteData(int.Parse(strDeleteID)); BindGrid(); } string strRefresh = Request.Form.Get("Refresh"); if (strRefresh == "true") { BindGrid(); } string strUpdate = Request.Form.Get("UpdatePsw"); if (!string.IsNullOrEmpty(strUpdate)) { SystemUserBLL objBll = new SystemUserBLL(); SystemUser obj = objBll.GetUserByEmployeeID(Convert.ToInt32(strUpdate)); if (obj != null) { obj.Password = "******"; if (PrjPub.IsServerCenter) { objBll.UpdateUser(obj); } else { objBll.UpdateUserPsw(obj.UserID, "111111"); } SessionSet.PageMessage = "初始化密码成功!"; } else { SessionSet.PageMessage = "该员工登录帐户不存在,初始化密码失败!"; } BindGrid(); } } }
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); } }
//保存数据 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); } } }
public Frm_ChangePassword() { InitializeComponent(); userBll = new SystemUserBLL(); }