示例#1
0
 /// <summary>
 /// 员工操作完成
 /// </summary>
 /// <param name="operateType">操作类型</param>
 /// <param name="t">员工对象</param>
 /// <param name="result">操作结果</param>
 /// <param name="currUser">当前用户</param>
 /// <param name="otherParams"></param>
 public void OperateCompeletedHandle(ModelRecordOperateType operateType, OrgM_Emp t, bool result, UserInfo currUser, object[] otherParams = null)
 {
     if (result)
     {
         string errMsg   = string.Empty;
         string username = OrgMOperate.GetUserNameByEmp(t);
         if (operateType == ModelRecordOperateType.Add)
         {
             if (!string.IsNullOrEmpty(username))
             {
                 UserOperate.AddUser(out errMsg, username, string.Format("{0}_123456", username), null, t.Name);
             }
         }
         else if (operateType == ModelRecordOperateType.Edit)
         {
             if (!string.IsNullOrEmpty(username))
             {
                 UserOperate.UpdateUserAliasName(username, t.Name);
             }
         }
         else if (operateType == ModelRecordOperateType.Del)
         {
             if (!string.IsNullOrEmpty(username))
             {
                 UserOperate.DelUser(username); //删除账号
             }
         }
     }
 }
示例#2
0
 /// <summary>
 /// 员工操作完成
 /// </summary>
 /// <param name="operateType">操作类型</param>
 /// <param name="t">员工对象</param>
 /// <param name="result">操作结果</param>
 /// <param name="currUser">当前用户</param>
 /// <param name="otherParams"></param>
 public void OperateCompeletedHandle(ModelRecordOperateType operateType, OrgM_Emp t, bool result, UserInfo currUser, object[] otherParams = null)
 {
     if (result)
     {
         string errMsg      = string.Empty;
         string username    = OrgMOperate.GetUserNameByEmp(t);
         string userInitPwd = WebConfigHelper.GetAppSettingValue("UserInitPwd");
         if (string.IsNullOrEmpty(userInitPwd))
         {
             userInitPwd = "123456";
         }
         if (operateType == ModelRecordOperateType.Add)
         {
             if (!string.IsNullOrEmpty(username))
             {
                 UserOperate.AddUser(out errMsg, username, userInitPwd, null, t.Name);
             }
         }
         else if (operateType == ModelRecordOperateType.Edit)
         {
             if (!string.IsNullOrEmpty(username))
             {
                 Sys_User user = UserOperate.GetUser(username);
                 if (user != null) //用户已存在
                 {
                     UserOperate.UpdateUserAliasName(username, t.Name);
                 }
                 else //用户不存在
                 {
                     UserOperate.AddUser(out errMsg, username, userInitPwd, null, t.Name);
                 }
             }
         }
         else if (operateType == ModelRecordOperateType.Del)
         {
             if (!string.IsNullOrEmpty(username))
             {
                 UserOperate.DelUser(username); //删除账号
             }
             //删除员工同时删除员工岗位
             CommonOperate.DeleteRecordsByExpression <OrgM_EmpDeptDuty>(x => x.OrgM_EmpId == t.Id, out errMsg, t.IsDeleted);
         }
         if (operateType == ModelRecordOperateType.Add || operateType == ModelRecordOperateType.Edit)
         {
             //新增编辑时同时设置员工主职岗位
             if (t.DeptId.HasValue && t.DeptId.Value != Guid.Empty && t.DutyId.HasValue && t.DutyId.Value != Guid.Empty)
             {
                 OrgM_EmpDeptDuty empPosition = null;
                 if (operateType == ModelRecordOperateType.Edit)
                 {
                     empPosition = CommonOperate.GetEntity <OrgM_EmpDeptDuty>(x => x.OrgM_EmpId == t.Id && x.IsMainDuty == true, null, out errMsg);
                     if (empPosition != null)
                     {
                         empPosition.OrgM_DeptId    = t.DeptId.Value;
                         empPosition.OrgM_DutyId    = t.DutyId.Value;
                         empPosition.IsValid        = true;
                         empPosition.ModifyDate     = DateTime.Now;
                         empPosition.ModifyUserId   = currUser.UserId;
                         empPosition.ModifyUserName = currUser.EmpName;
                         CommonOperate.OperateRecord <OrgM_EmpDeptDuty>(empPosition, ModelRecordOperateType.Edit, out errMsg, null, false);
                         return;
                     }
                 }
                 Guid   moduleId = SystemOperate.GetModuleIdByModelType(typeof(OrgM_EmpDeptDuty));
                 string code     = SystemOperate.GetBillCode(moduleId);
                 empPosition = new OrgM_EmpDeptDuty()
                 {
                     Code           = code,
                     OrgM_DeptId    = t.DeptId.Value,
                     OrgM_DutyId    = t.DutyId.Value,
                     OrgM_EmpId     = t.Id,
                     IsMainDuty     = true,
                     IsValid        = true,
                     EffectiveDate  = DateTime.Now,
                     CreateDate     = DateTime.Now,
                     CreateUserId   = currUser.UserId,
                     CreateUserName = currUser.EmpName,
                     ModifyDate     = DateTime.Now,
                     ModifyUserId   = currUser.UserId,
                     ModifyUserName = currUser.EmpName
                 };
                 Guid rs = CommonOperate.OperateRecord <OrgM_EmpDeptDuty>(empPosition, ModelRecordOperateType.Add, out errMsg, null, false);
                 if (rs != Guid.Empty)
                 {
                     SystemOperate.UpdateBillCode(moduleId, code);
                 }
             }
         }
     }
 }
示例#3
0
 /// <summary>
 /// 员工操作完成
 /// </summary>
 /// <param name="operateType">操作类型</param>
 /// <param name="t">员工对象</param>
 /// <param name="result">操作结果</param>
 /// <param name="currUser">当前用户</param>
 /// <param name="otherParams"></param>
 public void OperateCompeletedHandle(ModelRecordOperateType operateType, OrgM_Emp t, bool result, UserInfo currUser, object[] otherParams = null)
 {
     if (result)
     {
         string errMsg   = string.Empty;
         string username = OrgMOperate.GetUserNameByEmp(t);
         if (operateType == ModelRecordOperateType.Add)
         {
             if (!string.IsNullOrEmpty(username))
             {
                 UserOperate.AddUser(out errMsg, username, string.Format("{0}_123456", username), null, t.Name);
             }
         }
         else if (operateType == ModelRecordOperateType.Edit)
         {
             if (!string.IsNullOrEmpty(username))
             {
                 UserOperate.UpdateUserAliasName(username, t.Name);
             }
         }
         else if (operateType == ModelRecordOperateType.Del)
         {
             if (!string.IsNullOrEmpty(username))
             {
                 UserOperate.DelUser(username); //删除账号
             }
             //删除员工同时删除员工岗位
             CommonOperate.DeleteRecordsByExpression <OrgM_EmpDeptDuty>(x => x.OrgM_EmpId == t.Id, out errMsg, t.IsDeleted);
         }
         if (operateType == ModelRecordOperateType.Add || operateType == ModelRecordOperateType.Edit)
         {
             //新增编辑时同时设置员工主职岗位
             if (t.DeptId.HasValue && t.DeptId.Value != Guid.Empty && t.DutyId.HasValue && t.DutyId.Value != Guid.Empty)
             {
                 OrgM_EmpDeptDuty empPosition = null;
                 if (operateType == ModelRecordOperateType.Edit)
                 {
                     empPosition = CommonOperate.GetEntity <OrgM_EmpDeptDuty>(x => x.OrgM_EmpId == t.Id && x.IsMainDuty == true, null, out errMsg);
                     if (empPosition != null)
                     {
                         empPosition.OrgM_DeptId    = t.DeptId.Value;
                         empPosition.OrgM_DutyId    = t.DutyId.Value;
                         empPosition.IsValid        = true;
                         empPosition.ModifyDate     = DateTime.Now;
                         empPosition.ModifyUserId   = currUser.UserId;
                         empPosition.ModifyUserName = currUser.EmpName;
                         CommonOperate.OperateRecord <OrgM_EmpDeptDuty>(empPosition, ModelRecordOperateType.Edit, out errMsg, null, false);
                         return;
                     }
                 }
                 empPosition = new OrgM_EmpDeptDuty()
                 {
                     OrgM_DeptId    = t.DeptId.Value,
                     OrgM_DutyId    = t.DutyId.Value,
                     OrgM_EmpId     = t.Id,
                     IsMainDuty     = true,
                     IsValid        = true,
                     EffectiveDate  = DateTime.Now,
                     CreateDate     = DateTime.Now,
                     CreateUserId   = currUser.UserId,
                     CreateUserName = currUser.EmpName,
                     ModifyDate     = DateTime.Now,
                     ModifyUserId   = currUser.UserId,
                     ModifyUserName = currUser.EmpName
                 };
                 CommonOperate.OperateRecord <OrgM_EmpDeptDuty>(empPosition, ModelRecordOperateType.Add, out errMsg, null, false);
             }
         }
     }
 }