public AjaxMessage CreateEmployeeJob(string JobName) { AjaxMessage ajax = new AjaxMessage(); ajax.IsSuccess = false; ajax.Message = ""; try { Sys_EmployeeJob empJob = new Sys_EmployeeJob(); empJob.Jobname = JobName; empJob.createTime = DateTime.Now; empJob.EmployeeId = LoginInfo.UserInfo.EmployeeId; empJob.Status = (byte)SysStatus.Enable; int result = _empJobService.Insert(empJob); if (result > 0) { ajax.IsSuccess = true; ajax.Message = "添加成功"; } } catch (Exception e) { ajax.Message = e.Message; } return(ajax); }
public AjaxMessage CheckModifyPwd(string pwd, string newPwd, string confirmPwd) { AjaxMessage ajax = new AjaxMessage(); ajax.IsSuccess = false; try { int Id = LoginInfo.UserInfo.EmployeeId; Sys_Employee employee = _empService.GetByID(Id); if (employee.PassWord == pwd.MD5Hash() || employee.PassWord == pwd) //原密码输入正确 { if (!string.IsNullOrEmpty(newPwd) && newPwd == confirmPwd) { employee.PassWord = newPwd; int result = _empService.Update(employee); if (result > 0) { ajax.Message = "修改成功"; } else { ajax.Message = "修改失败,请稍候再试..."; } } //修改密码 ajax.IsSuccess = true; } } catch (Exception e) { ajax.Message = e.Message.ToString(); } return(ajax); }
public AjaxMessage GetEmployeeInfo() { AjaxMessage ajax = new AjaxMessage(); ajax.IsSuccess = false; try { int EmployeeId = LoginInfo.UserInfo.EmployeeId; Sys_Employee m_emp = _empService.GetByID(EmployeeId); if (m_emp != null) { ajax.Data = new EmployeeInfo() { EmployeeID = m_emp.EmployeeID, LoginName = m_emp.LoginName, EmployeeName = m_emp.EmployeeName, Sex = m_emp.Sex == true ? "女" : "男", Phone = m_emp.TelPhone, TypeName = _empTypeService.GetByID(m_emp.EmployeeTypeID).TypeName, JobName = _empJobService.GetByID(m_emp.JobID).Jobname, CreateDate = m_emp.CreateDate, BornDate = m_emp.BornDate }; ajax.IsSuccess = true; } } catch (Exception e) { ajax.Message = e.Message; } return(ajax); }
public AjaxMessage UpdateEmployeeJob(Sys_EmployeeJob _empJob) { AjaxMessage ajax = new AjaxMessage(); ajax.IsSuccess = false; ajax.Message = ""; try { Sys_EmployeeJob empJob = _empJobService.GetByID(_empJob.JobID);; empJob.Jobname = _empJob.Jobname; empJob.EmployeeId = LoginInfo.UserInfo.EmployeeId; int result = _empJobService.Update(empJob); if (result > 0) { ajax.IsSuccess = true; ajax.Message = "修改成功"; } } catch (Exception e) { ajax.Message = e.Message; } return(ajax); }
public AjaxMessage GetEmployeeName(string employeeId) { AjaxMessage ajax = new AjaxMessage(); ajax.IsSuccess = false; try { if (!string.IsNullOrEmpty(employeeId)) { var emplist = _empService.GetEmployees(employeeId); if (emplist != null) { //放入另一个list 否则会陷入循环引用 List <Sys_Employee> list = new List <Sys_Employee>(); list = emplist.Select(c => new Sys_Employee { EmployeeName = c.EmployeeName, EmployeeID = c.EmployeeID }).ToList(); ajax.IsSuccess = true; ajax.Data = list; } else { ajax.IsSuccess = true; ajax.Message = "没有选择客户"; } } } catch (Exception e) { ajax.Message = e.Message.ToString(); } return(ajax); }
public AjaxMessage GetLastLoginTime() { AjaxMessage ajax = new AjaxMessage(); ajax.IsSuccess = false; try { int EmployeeId = LoginInfo.UserInfo.EmployeeId; Sys_Employee m_emp = _empService.GetByID(EmployeeId); if (m_emp != null) { //条件 List <Expression <Func <sys_LoginLog, bool> > > parmList = new List <Expression <Func <sys_LoginLog, bool> > >(); parmList.Add(c => c.LoginEmployee == EmployeeId); BaseService <sys_LoginLog> _logService = new BaseService <sys_LoginLog>(); ajax.Value = m_emp.LastLoginTime == null ? null : m_emp.LastLoginTime.ToString().ToDateTime().ToString("yyyy-MM-dd HH:mm:ss"); ajax.Index = _logService.GetListBy(parmList).Count; ajax.IsSuccess = true; } } catch (Exception e) { ajax.Message = e.Message; } return(ajax); }
public AjaxMessage SetPartStatus(string ChannelId, int type) { AjaxMessage ajax = new AjaxMessage(); ajax.IsSuccess = false; ajax.Message = ""; try { if (!string.IsNullOrEmpty(ChannelId.ToString())) { int result = _channelService.UpdatePartStatus(ChannelId, type); if (result > 0) { ajax.IsSuccess = true; if (type == 1) { ajax.Message = "启用成功"; } else { ajax.Message = "禁用成功"; } } } } catch (Exception e) { ajax.Message = e.Message; } return(ajax); }
public AjaxMessage GetLoginName(int employeeId) { AjaxMessage ajax = new AjaxMessage(); ajax.IsSuccess = false; ajax.Message = ""; try { Sys_Employee employee = _empService.GetByID(employeeId); HHL_Employee m_employee = new HHL_Employee { EmployeeId = employee.EmployeeID, EmployeeName = employee.EmployeeName, JobId = employee.JobID, TypeId = employee.EmployeeTypeID, LoginName = employee.LoginName, }; Sys_EmployeeJob m_job = _empJobService.GetByID(m_employee.JobId); Sys_EmployeeType m_type = _empTypeService.GetByID(m_employee.TypeId); m_employee.TypeName = m_type.TypeName; m_employee.JobName = m_job.Jobname; ajax.IsSuccess = true; ajax.Data = m_employee; } catch { ajax.IsSuccess = false; ajax.Message = "系统异常,请稍候再试..."; } return(ajax); }
public AjaxMessage UpdateEmployeeType(Sys_EmployeeType _empType) { AjaxMessage ajax = new AjaxMessage(); ajax.IsSuccess = false; ajax.Message = ""; try { Sys_EmployeeType empType = _empTypeService.GetByID(_empType.EmployeeTypeID); empType.TypeName = _empType.TypeName; empType.EmployeeId = LoginInfo.UserInfo.EmployeeId; int result = _empTypeService.Update(empType); if (result > 0) { ajax.IsSuccess = true; ajax.Message = "修改成功"; } } catch (Exception e) { ajax.Message = e.Message; } return(ajax); }
public AjaxMessage GetMaxSort(int parent) { AjaxMessage ajax = new AjaxMessage(); ajax.IsSuccess = false; try { if (!string.IsNullOrEmpty(parent.ToString())) { int maxSort = _channelService.GetMaxSort(parent); string theme = _channelService.GetTheme(parent); ajax.Value = maxSort.ToString(); ajax.type = theme; ajax.IsSuccess = true; } } catch (Exception e) { ajax.Message = e.Message; } return(ajax); }
public AjaxMessage CreateEmployeeType(string TypeName) { AjaxMessage ajax = new AjaxMessage(); ajax.IsSuccess = false; ajax.Message = ""; try { Sys_EmployeeType empType = new Sys_EmployeeType(); empType.TypeName = TypeName; empType.CreateTime = DateTime.Now; empType.EmployeeId = LoginInfo.UserInfo.EmployeeId; empType.Status = (byte)SysStatus.Enable; int result = _empTypeService.Insert(empType); if (result > 0) { ajax.IsSuccess = true; ajax.Message = "添加成功"; } } catch (Exception e) { ajax.Message = e.Message; } return(ajax); }
public AjaxMessage ModifyEmpInfo(string empName, string sex, string phone) { AjaxMessage ajax = new AjaxMessage(); ajax.IsSuccess = false; try { Sys_Employee m_emp = _empService.GetByID(LoginInfo.UserInfo.EmployeeId); m_emp.EmployeeName = empName; m_emp.Sex = sex == "1" ? true : false; m_emp.TelPhone = phone; int result = _empService.Update(m_emp); if (result > 0) { ajax.IsSuccess = true; ajax.Message = "修改成功"; } } catch (Exception e) { ajax.Message = e.Message; } return(ajax); }
public AjaxMessage ModifyChannel(Sys_Channel channel, int ChannelId) { AjaxMessage ajax = new AjaxMessage(); ajax.IsSuccess = false; ajax.Message = ""; try { Sys_Channel m_channel = _channelService.GetByName(channel.ChannelName);; Sys_Channel n_channel = _channelService.GetByID(ChannelId); if (m_channel != null) { if (channel.ChannelName != m_channel.ChannelName) { ajax.Message = "该频道名称已经存在"; } } if (n_channel != null && ajax.Message == "") { n_channel.ChannelName = channel.ChannelName; n_channel.ChannelAddress = channel.ChannelAddress; if (n_channel.Parent != channel.Parent) //父级发生改变 { n_channel.IndexCode = CommonService.getCode(channel.Parent.ToString() == "0" ? "" : _channelService.GetByID(channel.Parent).IndexCode.ToString(), 3, channel.Parent == 0 ? 0 : 1); } n_channel.Parent = channel.Parent; n_channel.StyleSheethem = channel.StyleSheethem; n_channel.ChannelGetType = channel.ChannelGetType; n_channel.Remark = channel.Remark; n_channel.SortInt = channel.SortInt ?? 10; n_channel.ItemLevel = channel.Parent == 0 ? 1 : 2; int result = _channelService.Update(n_channel); if (result >= 1) { ajax.IsSuccess = true; ajax.Message = "修改成功"; } } //修改权限表中的url _powerService.UpdateChannel(ChannelId, channel); } catch (Exception e) { ajax.Message = e.Message; } return(ajax); }
public AjaxMessage GetEmployeeCount() { AjaxMessage ajax = new AjaxMessage(); ajax.IsSuccess = false; var DataList = _empService.GetByAll(); if (DataList != null && DataList.Count > 0) { int count = DataList.Count(); ajax.IsSuccess = true; ajax.Value = count.ToString(); } return(ajax); }
public AjaxMessage GetEmpTypeById(int TypeId) { AjaxMessage ajax = new AjaxMessage(); ajax.IsSuccess = false; Sys_EmployeeType empType = _empTypeService.GetByID(TypeId); if (empType != null) { ajax.IsSuccess = true; ajax.Value = empType.TypeName; ajax.Id = empType.EmployeeTypeID; } return(ajax); }
public AjaxMessage GetEmpJobById(int JobId) { AjaxMessage ajax = new AjaxMessage(); ajax.IsSuccess = false; Sys_EmployeeJob empJob = _empJobService.GetByID(JobId); if (empJob != null) { ajax.IsSuccess = true; ajax.Value = empJob.Jobname; ajax.Id = empJob.JobID; } return(ajax); }
public AjaxMessage SetSingleStatus(int ChannelId, int index) { AjaxMessage ajax = new AjaxMessage(); ajax.IsSuccess = false; ajax.Message = ""; try { if (!string.IsNullOrEmpty(ChannelId.ToString()) && ChannelId != 0) { Sys_Channel m_channel = _channelService.GetByID(ChannelId); if (m_channel.Status == (byte)SysStatus.Enable) { m_channel.Status = (byte)SysStatus.Disable; } else { m_channel.Status = (byte)SysStatus.Enable; } int result = _channelService.Update(m_channel); if (result > 0) { ajax.IsSuccess = true; ajax.Id = ChannelId; ajax.Index = index; if (m_channel.Status == (byte)SysStatus.Disable) { ajax.Message = "禁用成功"; } else { ajax.Message = "启用成功"; } } } } catch (Exception e) { ajax.Message = e.Message; } return(ajax); }
public AjaxMessage SetEmployeeSingleStatus(int EmployeeId, int index) { AjaxMessage ajax = new AjaxMessage(); ajax.IsSuccess = false; ajax.Message = ""; try { if (!string.IsNullOrEmpty(EmployeeId.ToString()) && EmployeeId != 0) { Sys_Employee m_employee = _empService.GetByID(EmployeeId); if (m_employee.Status == (byte)SysStatus.Enable) { m_employee.Status = (byte)SysStatus.Disable; } else { m_employee.Status = (byte)SysStatus.Enable; } int result = _empService.Update(m_employee); if (result > 0) { ajax.IsSuccess = true; ajax.Id = EmployeeId; ajax.Index = index; if (m_employee.Status == (byte)SysStatus.Disable) { ajax.Message = "禁用成功"; } else { ajax.Message = "启用成功"; } } } } catch (Exception e) { ajax.Message = e.Message; } return(ajax); }
public AjaxMessage GetMyEmpKey() { AjaxMessage ajax = new AjaxMessage(); ajax.IsSuccess = false; try { int employeeId = LoginInfo.UserInfo.EmployeeId; List <EmployeeInfo> empList = _empService.GetMyMnanagerInfo(employeeId); ajax.IsSuccess = true; ajax.data = empList; } catch (Exception e) { ajax.Message = e.Message; } return(ajax); }
public AjaxMessage GetChannelByUrl(string url) { AjaxMessage ajax = new AjaxMessage(); ajax.IsSuccess = false; try { if (!string.IsNullOrEmpty(url)) { var channel = _channelService.GetChannelByUrl(url); ajax.data = channel; ajax.IsSuccess = true; } } catch (Exception e) { ajax.Message = e.Message; } return(ajax); }
public AjaxMessage CheckLoginName(string loginName) { AjaxMessage ajax = new AjaxMessage(); ajax.IsSuccess = false; ajax.Message = ""; try { bool IsExists = _empService.CheckLoginName(loginName); if (IsExists == true) //用户名已经存在 { ajax.IsSuccess = IsExists; ajax.Message = "用户名已经存在"; } } catch (Exception e) { ajax.Message = e.Message; } return(ajax); }
public AjaxMessage CreateChannel(Sys_Channel channel) { AjaxMessage ajax = new AjaxMessage(); ajax.IsSuccess = false; ajax.Message = ""; try { Sys_Channel m_channel = _channelService.GetByName(channel.ChannelName); if (m_channel != null) { ajax.Message = "该频道名称已经存在"; } else { channel.SortInt = channel.SortInt ?? 10; channel.CreateDate = DateTime.Now; channel.Status = (byte)SysStatus.Enable; channel.ItemLevel = channel.Parent == 0 ? 1 : 2; channel.IndexCode = CommonService.getCode(channel.Parent.ToString() == "0" ? "" : _channelService.GetByID(channel.Parent).IndexCode.ToString(), 3, channel.Parent == 0 ? 0 : 1); int result = _channelService.Insert(channel); if (result >= 1) { ajax.IsSuccess = true; ajax.Message = "添加成功"; } } } catch (Exception e) { ajax.Message = e.Message; } return(ajax); }
public AjaxMessage GetCheckPower(int EmployeeId) { AjaxMessage ajax = new AjaxMessage(); ajax.IsSuccess = false; try { //获取该员工启用的权限 List <Sys_EmployeePower> powerList = _empPowerService.GetAllByStatus(EmployeeId, 1); if (powerList.Count > 0) { ajax.Data = powerList; ajax.IsSuccess = true; ajax.Message = "页面加载成功"; } } catch (Exception e) { ajax.Message = e.Message; } return(ajax); }
public AjaxMessage CreateLoadEmp() { AjaxMessage ajax = new AjaxMessage(); ajax.IsSuccess = false; ajax.Message = ""; try { bool isExists = _empService.CheckLoginName("wupeng"); if (isExists == false) { Sys_Employee emp = new Sys_Employee(); emp.JobID = -1; emp.DepartmentID = -1; emp.EmployeeTypeID = -1; emp.EmployeeName = "吴鹏"; emp.LoginName = "wupeng"; emp.PassWord = "******"; emp.CreateDate = DateTime.Now; emp.ComeInDate = DateTime.Now; emp.Sex = false; emp.BornDate = DateTime.Now.AddYears(-10); emp.TelPhone = ""; emp.Status = (byte)SysStatus.Enable; //建立帐号 int final = _empService.Insert(emp); if (final > 0) { //给予权限 string channel = "1,2,3,4,5,6"; //逗号隔开获取菜单ID string[] power = channel.Split(','); int result = 0; for (int i = 0; i < power.Length; i++) { int ChannelId = power[i].ToInt32(); Sys_Channel m_channel = _channelService.GetByID(ChannelId); Sys_EmployeePower m_empPower = null; m_empPower = new Sys_EmployeePower(); m_empPower.Powername = m_channel.ChannelName; m_empPower.EmployeeID = emp.EmployeeID; m_empPower.DepartmentID = emp.DepartmentID; m_empPower.ChannelID = ChannelId; m_empPower.UrlAddress = m_channel.ChannelAddress; m_empPower.CreateDate = DateTime.Now; m_empPower.Status = (byte)SysStatus.Enable; m_empPower.Parent = m_channel.Parent; m_empPower.Sort = m_channel.SortInt; //区别 1级菜单和2级菜单 if (m_channel.Parent == 0) { m_empPower.ItemLevel = 1; } else { m_empPower.ItemLevel = 2; } //添加到数据库 result = _empPowerService.Insert(m_empPower); if (result > 0) { ajax.IsSuccess = true; ajax.Message = "建立初始账户成功"; } } } } } catch (Exception e) { ajax.Message = e.Message; } return(ajax); }
public AjaxMessage EmployeePowerCreate(int employeeId, string channel) { AjaxMessage ajax = new AjaxMessage(); ajax.IsSuccess = false; try { //逗号隔开获取菜单ID string[] power = channel.Split(','); Sys_Employee employee = _empService.GetByID(employeeId); List <Sys_EmployeePower> powerList = _empPowerService.GetAllByEmployeeId(employeeId); foreach (var item in powerList) { item.Status = (byte)SysStatus.Disable; _empPowerService.Update(item); } int result = 0; for (int i = 0; i < power.Length; i++) { int ChannelId = power[i].ToInt32(); bool IsExists = _empPowerService.CheckPower(employeeId, ChannelId); Sys_Channel m_channel = _channelService.GetByID(ChannelId); Sys_EmployeePower m_empPower = null; if (IsExists == false) //不存在 就添加 { m_empPower = new Sys_EmployeePower(); m_empPower.Powername = m_channel.ChannelName; m_empPower.EmployeeID = employeeId; m_empPower.DepartmentID = employee.DepartmentID; m_empPower.ChannelID = ChannelId; m_empPower.UrlAddress = m_channel.ChannelAddress; m_empPower.CreateDate = DateTime.Now; m_empPower.Status = (byte)SysStatus.Enable; m_empPower.Parent = m_channel.Parent; m_empPower.Sort = m_channel.SortInt; //区别 1级菜单和2级菜单 if (m_channel.Parent == 0) { m_empPower.ItemLevel = 1; } else { m_empPower.ItemLevel = 2; } result = _empPowerService.Insert(m_empPower); } else { m_empPower = _empPowerService.GetEmpPower(employeeId, ChannelId); m_empPower.Powername = m_channel.ChannelName; m_empPower.UrlAddress = m_channel.ChannelAddress; m_empPower.Status = (byte)SysStatus.Enable; m_empPower.Parent = m_channel.Parent; m_empPower.Sort = m_channel.SortInt; result = _empPowerService.Update(m_empPower); } } if (result > 0) { ajax.IsSuccess = true; ajax.Message = "保存权限成功"; } } catch (Exception e) { ajax.Message = e.Message; } return(ajax); }