/// <summary> /// 登录 /// </summary> /// <param name="context"></param> /// <returns></returns> private string Login(HttpContext context) { string WorkNum = context.Request["name"] ?? ""; string pwd = context.Request["pwd"] ?? ""; var str = new StringBuilder(); try { var employeeBll = new EmployerBll(); if (employeeBll.Login(WorkNum, pwd)) { context.Session[Constant.LoginUser] = employeeBll.GetEntity(new Employer() { WorkNum = WorkNum, Password = pwd }); str.Append("1"); return(str.ToString()); } else { str.Append("0"); return(str.ToString()); } } catch (Exception ex) { Log.Error(ex); str.Append("0"); return(str.ToString()); } }
public string QueryEmp(HttpContext context) { var employeeBll = new EmployerBll(); string str; var jss = new JavaScriptSerializer(); var id = context.Request.Params["empid"]; var employee = new Employer() { Id = id }; try { var dt = employeeBll.Query(employee); var list = ConvertHelper <Employer> .ConvertToList(dt); str = jss.Serialize(list); str += "|"; } catch (Exception e) { Log.Error(e); str = "0|false"; return(str); } return(str); }
/// <summary> /// 修改密码 /// </summary> /// <param name="context"></param> /// <returns></returns> public string ModifyPassword(HttpContext context) { var employeeBll = new EmployerBll(); var str = new StringBuilder(); var worknum = context.Request.Params["worknum"]; var pass = context.Request.Params["pass"]; var newpass = context.Request.Params["newpass"]; var employee = new Employer { WorkNum = worknum, Password = newpass }; try { var value = employeeBll.Login(worknum, pass); if (value) { employeeBll.Modify(employee); str.Append("true"); } else { str.Append("falsepwd"); } } catch (Exception e) { Log.Error(e); str.Append("false"); } return(str.ToString()); }
/// <summary> /// 删除员工数据 /// </summary> /// <param name="context"></param> /// <returns></returns> public string DelEmployee(HttpContext context) { var employeeBll = new EmployerBll(); var id = context.Request.Params["id"]; try { employeeBll.DelEmployee(id); } catch (Exception e) { Log.Error(e); return(e.Message); } //操作日志 if (null == context.Session[Constant.LoginUser]) { return("2"); } var oprlog = new OprLog { Operator = ((Employer)(context.Session[Constant.LoginUser])).Name, OperResult = "成功", OprSrc = "删除人员", LogDate = DateTime.Now }; _oprLogBll.Add(oprlog); return("true"); }
/// <summary> /// /// </summary> /// <param name="context"></param> /// <returns></returns> public string GetEmp(HttpContext context) { var employeeBll = new EmployerBll(); var depid = context.Request.Params["id"]; var employee = new Employer() { DeptId = depid }; string str; var jss = new JavaScriptSerializer(); var count = 0; try { var dt = employeeBll.QueryEmp(employee); var list = ConvertHelper <Employer> .ConvertToList(dt); str = jss.Serialize(list); str = str.Substring(1, str.Length - 2); str = "{\"total\":\"" + count + "\",\"rows\":[" + str + "]}"; } catch (Exception e) { Log.Error(e); return("false"); } return(str); }
/// <summary> /// 删除部门 /// </summary> /// <param name="context"></param> /// <returns></returns> public string DelDepartment(HttpContext context) { var departmentBll = new DepartmentBLL(); var employeeBll = new EmployerBll(); var id = context.Request.Params["id"]; var name = context.Request.Params["name"]; var employee = new Employer { DeptId = id, Name = name }; try { var bdata = employeeBll.Exist(employee); switch (bdata) { case "1": return("exist"); case "0": var bdata2 = departmentBll.Exist3(id); switch (bdata2) { case "1": return("exist2"); } departmentBll.DelDepartment(id); break; } } catch (Exception e) { Log.Error(e); return("false"); } //操作日志 if (null == context.Session[Constant.LoginUser]) { return("2"); } var oprlog = new OprLog { Operator = ((Employer)(context.Session[Constant.LoginUser])).Name, OperResult = "成功", OprSrc = "删除部门", LogDate = DateTime.Now }; _oprLogBll.Add(oprlog); return("true"); }
/// <summary> /// 登录 /// </summary> /// <param name="context"></param> /// <returns></returns> private string Login1(HttpContext context) { string id = context.Request["id"] ?? ""; try { var employeeBll = new EmployerBll(); context.Session[Constant.LoginUser] = employeeBll.GetEntity(new Employer() { Id = id }); } catch (Exception ex) { Log.Error(ex); } return(""); }
/// <summary> /// 编辑员工数据 /// </summary> /// <param name="context"></param> /// <returns></returns> public string EditEmployee(HttpContext context) { var employeeBll = new EmployerBll(); var useRolesBll = new UseRolesBll(); var id = context.Request.Params["empid"]; var worknum = context.Request.Params["worknum"]; var empname = context.Request.Params["empname"]; var phonenum = context.Request.Params["phonenum"]; var parid = context.Request.Params["parid"]; var empmail = context.Request.Params["empmail"]; var roleid = context.Request.Params["roleid"].Split('—'); var employee = new Employer { Id = id, DeptId = parid, WorkNum = worknum, Name = empname, PhoneNum = phonenum, Email = empmail }; try { var userolesdel = new UseRoles { LoginName = id }; useRolesBll.Del(userolesdel); foreach (var s in roleid) { var useroles = new UseRoles { RoleId = s, LoginName = id }; useRolesBll.Add(useroles); } var bdata = employeeBll.Exist5(employee); switch (bdata) { case "1": return("exist"); case "0": employeeBll.UpdateEmployee(employee); break; } } catch (Exception e) { Log.Error(e); return("false"); } //操作日志 if (null == context.Session[Constant.LoginUser]) { return("2"); } var oprlog = new OprLog { Operator = ((Employer)(context.Session[Constant.LoginUser])).Name, OperResult = "成功", OprSrc = "编辑人员", LogDate = DateTime.Now }; _oprLogBll.Add(oprlog); return("true"); }