/// <summary> /// 控件赋值责任人 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void popLiable_Selected(object sender, EventArgs e) { if (popLiable.Selection != null) { liableMan = popLiable.Selection.Value; btnLiableMan.Text = popLiable.Selection.Text + " > "; UserDepDto user = AutofacConfig.userService.GetUseDepByUserID(liableMan); D_ID = user.Dep_ID; lblDep.Text = user.Dep_Name; } }
/// <summary> /// 根据用户ID返回用户和部门信息 /// </summary> /// <param name="UserID">用户ID</param> public UserDepDto GetUseDepByUserID(string UserID) { UserDepDto ud = Mapper.Map <User, UserDepDto>(_userRepository.GetByID(UserID).AsNoTracking().FirstOrDefault()); if (ud != null) { if (!string.IsNullOrEmpty(ud.Dep_ID)) { DepDetailDto d = Mapper.Map <Department, DepDetailDto>(_departmentRepository.GetByID(ud.Dep_ID).AsNoTracking().FirstOrDefault()); if (d != null) { ud.Dep_Name = d.Dep_Name; } } } return(ud); }
/// <summary> /// 根据用户ID返回用户和部门信息 /// </summary> /// <param name="UserID">用户ID</param> public UserDepDto GetUseDepByUserID(string UserID) { UserDepDto ud = Mapper.Map <coreUser, UserDepDto>(_coreUserRepository.GetByID(UserID).AsNoTracking().FirstOrDefault()); if (ud != null) { if (!string.IsNullOrEmpty(ud.DEPARTMENTID)) { DepartmentDto d = Mapper.Map <Department, DepartmentDto>(_DepartmentRepository.GetByID(ud.DEPARTMENTID).AsNoTracking().FirstOrDefault()); if (d != null) { ud.DEPARTMENTNAME = d.NAME; } } } return(ud); }
/// <summary> /// 责任人赋值 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void popLeader_Selected(object sender, EventArgs e) { try { if (popLeader.Selection != null) { //查询该选中的用户是否已经是部门责任人 bool isLeader = AutofacConfig.DepartmentService.IsLeader(popLeader.Selection.Value); //如果该选中责任人已是部门责任人,则报错 if (isLeader == true) { throw new Exception(popLeader.Selection.Text + "已是部门责任人,请先解散部门!"); } // UserDepDto userdep = AutofacConfig.coreUserService.GetUseDepByUserID(popLeader.Selection.Value); //如果选中用户已是部门成员且不是部门责任人,则进行选择是否确认为部门责任人,若确认则为该部门负责人 if (userdep != null & string.IsNullOrEmpty(userdep.DEPARTMENTID) == false & isLeader == false) { //if (AutofacConfig.userService.GetAllUsers().Count > 0 & isLeader== false) //{ MessageBox.Show(popLeader.Selection.Text + "已是部门成员,是否确定为该部门责任人?", MessageBoxButtons.YesNo, (Object s1, MessageBoxHandlerArgs args) => { //此委托为异步委托事件 if (args.Result == Smobiler.Core.Controls.ShowResult.Yes) { department.MANAGER = popLeader.Selection.Value; btnLeader.Text = popLeader.Selection.Text + " > "; } }); } //} //如果选中用户不是部门责任人且不是部门成员,则为该部门负责人 if (isLeader == false & userdep != null & string.IsNullOrEmpty(userdep.DEPARTMENTID) == true) { department.MANAGER = popLeader.Selection.Value; btnLeader.Text = popLeader.Selection.Text + " > "; } } } catch (Exception ex) { Toast(ex.Message, ToastLength.SHORT); } }