public static void LoadFunctionInfo() { if (CurrentUser == null) throw new Exception("请先获取用户信息!"); CurrentUserFunction = WcfServiceHelper.Client.GetRoleFunctionList(CurrentUser.RoleCode).ToList(); CurrentFunction = WcfServiceHelper.Client.GetFunctionByRole(CurrentUser.RoleCode).ToList(); if (CurrentUser.EmployeeID.HasValue) CurrentEmployee = WcfServiceHelper.Client.GetEmployee(CurrentUser.EmployeeID.Value); }
//保存 private void btnSave_Click(object sender, EventArgs e) { try { this.Cursor = Cursors.WaitCursor; if (validationProvider.Validate()) { if (Type == DBOperateType.Insert) { Employee = new CoEmployee(); Employee.Code = txtEmployeeCode.Text.Trim(); Employee.Valid = true; } Employee.Name = txtEmployeeName.Text.Trim(); if (lookUpEmployeeType.EditValue == null) Employee.Type = null; else Employee.Type = lookUpEmployeeType.EditValue.ToString(); Employee.DeptID = (btneditDepartment.Tag as CoDepartment).ID; Employee.SiteID = (btneditSite.Tag as CoSite).ID; if (lookUpSuperior.EditValue == null) Employee.Superior = null; else Employee.Superior = lookUpSuperior.EditValue.ToString(); Employee.Phone = txtPhone.Text.Trim(); Employee.BarPassword = txtBarPassword.Text.Trim(); Employee.QueryWord = txtQueryWord.Text.Trim(); Employee.Address = txtAddress.Text.Trim(); Employee.Remark = txtRemark.Text.Trim(); Employee.ModifyUser = Identity.CurrentUser.UserName; Employee.ModifyDate = DateTime.Now; if (Type == DBOperateType.Insert) WcfServiceHelper.Client.InsertEmployee(Employee); else WcfServiceHelper.Client.UpdateEmployee(Employee); this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); } } catch (Exception ex) { ControlsHelper.ShowErrorMessage("保存失败", ex.Message); } finally { this.Cursor = Cursors.Default; } }
/// <summary> /// 按部门获取员工 /// </summary> public static List<CoEmployee> GetEmployeeByDepartment(AppendType appendType, int deptID, bool isRefreshData) { string key = "Employee_" + deptID; if (!dictData.ContainsKey(key) || isRefreshData) { List<CoEmployee> _lstObjects = WcfServiceHelper.Client.GetEmployeeByDepartment(deptID).ToList(); dictData[key] = _lstObjects; } List<CoEmployee> lstObjects = new List<CoEmployee>((List<CoEmployee>)dictData[key]); if (appendType != AppendType.None) { CoEmployee employee = new CoEmployee(); employee.Name = appendType == AppendType.All ? "全部" : ""; lstObjects.Insert(0, employee); } return lstObjects.Clone(); }
public FrmEmployeeEdit(DBOperateType type, CoEmployee employee) { InitializeComponent(); Type = type; Employee = employee; }