/******************************************************** * 获取用户签到状态 * date:查询日期 可以为null * rate:出勤率,全勤1,非全勤0,所有null * ******************************************************/ private void GetSignStatus(HttpContext context) { //登录账号的ID string empID = UsrAuth.GetempID(context.Session); FeedBackMsg <CheckInInfo> feedBackMsg = new FeedBackMsg <CheckInInfo>(); //获取当前的考勤信息 CheckInInfo checkInInfo = CheckInInfoService.Instance.GetCurrentCheckInInfo(int.Parse(empID)); if (checkInInfo != null) { //已经签过到 feedBackMsg.Code = 1; feedBackMsg.Msg = "已经签到"; feedBackMsg.Obj = checkInInfo; } else { //还没有签到 feedBackMsg.Code = 1; feedBackMsg.Msg = "还没签到"; feedBackMsg.Obj = null; } string json = ObjToJson.ToJson(feedBackMsg); context.Response.Write(json); }
/// ******************************************************* /// <summary> /// 获取当前的工作时间设置 /// </summary> /// <param name="context"></param> /// ******************************************************* private void GetInfo(HttpContext context) { int code = 0; string msg = ""; string json = ""; #region 验证管理员权限 if (!UsrAuth.IsAdminister(context.Session)) { code = 0; msg = "没有管理员权限"; json = "{\"Code\":\"" + code + "\",\"Msg\":\"" + msg + "\"}"; context.Response.Write(json); return; } #endregion WorkDuration workDuration = WorkDurationService.Instance.GetWorkDuration(); FeedBackMsg <WorkDuration> feedBack = new FeedBackMsg <WorkDuration>(); if (WorkDurationService.Instance != null) { feedBack.Code = 1; feedBack.Msg = "当前的工作时间设置"; feedBack.Obj = workDuration; } json = ObjToJson.ToJson(feedBack); context.Response.Write(json); }
/************************************************** * 删除部门 * 功能:删除 * 页面参数:depID 部门ID * ************************************************/ public void Delete(HttpContext context) { int code = 0; string msg = ""; string json = ""; string depID = context.Request["id"]; #region 验证操作权限 if (!UsrAuth.IsAdminister(context.Session)) {//无管理员权限 code = 0; msg = "无‘管理员’权限"; json = "{\"Code\":\"" + code + "\",\"Msg\":\"" + msg + "\"}"; context.Response.Write(json); return; } #endregion //处理删除部门下的所属员工 int res = DepartmentService.Instance.DeleteDepartment(depID); if (res == 0) { code = 0; msg = "删除失败"; } else { code = 1; msg = "删除成功"; } json = "{\"Code\":\"" + code + "\",\"Msg\":\"" + msg + "\"}"; context.Response.Write(json); }
/************************************************** * 修改密码 * ************************************************/ private void UpdatePwd(HttpContext context) { int code = 0; string msg = ""; string json = ""; string empID = UsrAuth.GetempID(context.Session); string oldPwd = DataBase.StringToMD5Hash((context.Request["oldPwd"])); string newPwd = DataBase.StringToMD5Hash(context.Request["newPwd"]); int res = EmployeeService.Instance.ModifyPwd(empID, newPwd, oldPwd); if (res == 0) { msg = "修改失败"; } else { code = 1; msg = "修改成功"; //修改成功之后修改Cookie中的值 if (UsrAuth.GetLoginCookie(context.Request) != null) { EmployeeInfo emp = EmployeeService.Instance.GetEmployee(int.Parse(empID)); UsrAuth.SetLoginCookie(context.Response, emp.EmpAccount, newPwd); } } json = "{\"Code\":\"" + code + "\",\"Msg\":\"" + msg + "\"}"; context.Response.Write(json); }
private void BindData() { dtgvAuth.Rows.Clear(); if (cboxUsr.SelectedIndex == -1) { return; } string uId = cboxUsr.SelectedValue.ToString(); List <UsrAuth> authList = manager.LoadUsrAuth(uId); Dictionary <string, UsrAuth> map = new Dictionary <string, UsrAuth>(); foreach (UsrAuth auth in authList) { if (!StringUtil.isEmpty(auth.FuncID__PK)) { map.Add(auth.FuncID__PK, auth); } } foreach (string key in section.Keys) { string desc = section[key]; int index = dtgvAuth.Rows.Add(); dtgvAuth.Rows[index].Cells[colFuncID.Name].Value = key; dtgvAuth.Rows[index].Cells[colFuncNm.Name].Value = desc; if (map.ContainsKey(key)) { UsrAuth auth = map[key]; dtgvAuth.Rows[index].Cells[colckbox.Name].Value = "true"; } } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; string funC = context.Request["func"]; if (!UsrAuth.IsLogin(context.Session, context.Request, context.Response)) { context.Response.Write("{noLogin:\"1\"}"); return; } try { switch (funC) { case "Update": Update(context); break; case "GetInfo": GetInfo(context); break; default: break; } } catch (Exception e) { context.Response.ClearContent(); context.Response.Write("{data:\"参数错误!\"}"); } }
private bool IsAdminister(HttpContext context) { if (!UsrAuth.IsAdminister(context.Session)) {//无管理员权限 context.Response.Write("{\"Code\":\"0\",\"Msg\":\"无‘管理员’权限!\"}"); return(false); } return(true); }
/************************************************** * 获取员工信息列表 * MODIFY * ************************************************/ private void GetList(HttpContext context) { string currentEmpName = UsrAuth.GetempName(context.Session); string searchName = context.Request["searchName"]; string searchDepID = context.Request["searchDepID"]; string isDepList = context.Request["isDepList"]; if (string.IsNullOrEmpty(searchDepID)) { searchDepID = "0"; } FeedBackMsg <DepartmentAndEmployee> feedBack = new FeedBackMsg <DepartmentAndEmployee>(); List <EmployeeInfo> empList = new List <EmployeeInfo>(); if (UsrAuth.IsAdminister(context.Session)) { //管理员或总经理 empList = EmployeeService.Instance.GetList(searchName, int.Parse(searchDepID)); } else if (UsrAuth.IsDepManager(context.Session)) { //部门经理 string depID = UsrAuth.GetdepID(context.Session); empList = EmployeeService.Instance.GetEmployee(int.Parse(depID), searchName); } else { feedBack.Code = 0; feedBack.Msg = "没有相应的权限"; feedBack.Obj = null; } DepartmentAndEmployee depAndEmp; if (!string.IsNullOrEmpty(isDepList) && isDepList.Equals("1")) { List <Department> depList = DepartmentService.Instance.GetDepartment(); depAndEmp = new DepartmentAndEmployee() { DepList = depList, EmpList = empList }; } else { depAndEmp = new DepartmentAndEmployee() { EmpList = empList }; } feedBack.Code = 1; feedBack.Msg = "员工和部门列表"; feedBack.Obj = depAndEmp; string json = ObjToJson.ToJson(feedBack); context.Response.Write(json); }
protected void Page_Load(object sender, EventArgs e) { if (!UsrAuth.IsLogin(Session, Request, Response)) { strNoLogin = "******"; return; } strUsrRole = UsrAuth.GetUsrRoleID(Session); }
protected void Page_Load(object sender, EventArgs e) { Session["needLoginCode"] = strNeedLoginCode; string ii = Session["needLoginCode"].ToString(); if (UsrAuth.IsLogin(Session, Request, Response)) { Response.Redirect("Home.aspx"); } }
/******************************************************** * 描述:获取当前登录账户的月签到统计 * 参数:month 查询月份 * depName 部门名称 * empName 员工姓名 * rate 出勤率,全勤1,非全勤0,所有null * ******************************************************/ //月考勤记录查询 private void GetMonthAttendanceList(HttpContext context) { string empID = UsrAuth.GetempID(context.Session); string searchMonth = context.Request["searchMonth"]; string searchRate = context.Request["searchRate"]; string searchEmpName = context.Request["searchName"]; //MODIFY string isSelf = context.Request["isSelf"]; if (string.IsNullOrEmpty(searchEmpName)) { searchEmpName = null; } if (string.IsNullOrEmpty(searchRate)) { searchRate = null; } string depID = ""; List <MonthAttendance> list = new List <MonthAttendance>(); FeedBackMsg <List <MonthAttendance> > feedBack = new FeedBackMsg <List <MonthAttendance> >(); if (!string.IsNullOrEmpty(isSelf) && isSelf.Equals("1")) { list = MonthAttendanceService.Instance.GetAttendanceStatistics(empID, searchMonth, searchRate); } else { if (UsrAuth.IsTopManager(context.Session) || UsrAuth.IsAdminister(context.Session)) { depID = null; list = MonthAttendanceService.Instance.GetAttendanceStatistics(searchMonth, depID, searchEmpName, searchRate); } else if (UsrAuth.IsDepManager(context.Session)) { //部门经理 depID = UsrAuth.GetdepID(context.Session); list = MonthAttendanceService.Instance.GetAttendanceStatistics(searchMonth, depID, searchEmpName, searchRate); } } if (list != null && list.Count > 0) { feedBack.Code = 1; feedBack.Msg = "月考勤信息"; feedBack.Obj = list; } else { feedBack.Code = 1; feedBack.Msg = "沒有数据"; feedBack.Obj = null; } string json = ObjToJson.ToJson(feedBack); context.Response.Write(json); }
protected void Page_Load(object sender, EventArgs e) { if (!UsrAuth.IsLogin(Session, Request, Response)) { strNoLogin = "******"; return; } isAdmin = UsrAuth.IsAdminister(Session) ? "1" : "0"; isDepManage = UsrAuth.IsDepManager(Session) ? "1" : "0"; isTopManage = UsrAuth.IsTopManager(Session) ? "1" : "0"; }
/******************************************************** * 签到:插入一条考勤信息,初始化 * empID 员工ID * empName 员工姓名 * depID 部门ID * depName 部门名称 * signInDate 签到时间 * isLate 是否迟到 * * 签退:修改考勤数据 * checkInInfoID 考勤信息ID * empID 员工ID * empName 员工姓名 * depID 部门ID * depName 部门名称 * signOutDate 签退时间 * ******************************************************/ private void Sign(HttpContext context) { int code = 0; string msg = ""; int checkInInfoID = 0; string strCheckInInfoID = context.Request["id"]; if (!string.IsNullOrEmpty(strCheckInInfoID)) { checkInInfoID = int.Parse(strCheckInInfoID); } string empID = UsrAuth.GetempID(context.Session); string empName = UsrAuth.GetempName(context.Session); string depID = UsrAuth.GetdepID(context.Session); string depName = UsrAuth.GetdepName(context.Session); if (checkInInfoID <= 0) { //签到 string signInDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); int res = CheckInInfoService.Instance.UpdateCheckInInfo(int.Parse(empID), empName, int.Parse(depID), depName, signInDate); if (res != 1) { code = 0; msg = "签到失败"; } else { code = 1; msg = "签到成功"; } } else { //签退 string signOutDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); int res = CheckInInfoService.Instance.UpdateCheckInInfo(int.Parse(empID), empName, int.Parse(depID), depName, signOutDate, checkInInfoID); if (res != 1) { code = 0; msg = "签退失败"; } else { code = 1; msg = "签退成功"; } } string json = "{\"Code\":\"" + code + "\",\"Msg\":\"" + msg + "\"}"; context.Response.Write(json); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; //登录认证 string funC = context.Request["func"]; if (!UsrAuth.IsLogin(context.Session, context.Request, context.Response)) { context.Response.Write("{noLogin:\"1\"}"); return; } try { switch (funC) { case "GetSignStatus": GetSignStatus(context); break; case "Sign": Sign(context); break; case "GetDetailList": GetDetailList(context); break; case "UpdateSupplement": UpdateSupplement(context); break; case "GetMonthAttendanceList": GetMonthAttendanceList(context); break; case "GetInfo": GetInfo(context); break; default: break; } } catch (Exception e) { context.Response.ClearContent(); context.Response.Write("{data:\"参数错误!\"}"); } }
/************************************************** * 更新部门 * 功能:添加,修改 * 页面参数:depID 部门ID,可以为null * depName 添加或者修改后的部门名称 * ************************************************/ public void Update(HttpContext context) { int code = 0; string msg = ""; string json = ""; string depID = context.Request["id"]; string depName = context.Request["name"]; #region 验证操作权限 if (!UsrAuth.IsAdminister(context.Session)) {//无管理员权限 code = 0; msg = "无‘管理员’权限"; json = "{\"Code\":\"" + code + "\",\"Msg\":\"" + msg + "\"}"; context.Response.Write(json); return; } #endregion DepartmentService departmentService = new DepartmentService(); if (string.IsNullOrEmpty(depID)) { //添加 int res = departmentService.UpdateDepartment(depName); if (res == 0) { code = 0; msg = "添加失败"; } else { code = 1; msg = "添加成功"; } } else { //修改 int res = departmentService.UpdateDepartment(depName, int.Parse(depID)); if (res == 0) { code = 0; msg = "修改失败"; } else { code = 1; msg = "修改成功"; } } json = "{\"Code\":\"" + code + "\",\"Msg\":\"" + msg + "\"}"; context.Response.Write(json); }
private void btnSave_Click(object sender, EventArgs e) { if (cboxUsr.SelectedIndex == -1) { return; } string uId = StringUtil.Obj2Str(cboxUsr.SelectedValue); List <UsrAuth> list = new List <UsrAuth>(); foreach (DataGridViewRow row in dtgvAuth.Rows) { UsrAuth auth = new UsrAuth(); string value = StringUtil.Obj2Str(row.Cells[colckbox.Name].Value); if (value == "true") { auth.St = ST.VALID; } else { auth.St = ST.INVALID; } auth.FuncID__PK = StringUtil.Obj2Str(row.Cells[colFuncID.Name].Value); auth.UID__PK = uId; list.Add(auth); } try { int cnt = 0; if (list.Count > 0) { cnt = manager.SetAuth(list); } if (cnt > 0) { MainForm.Info("设置成功!"); } else { MainForm.Warn("设置失败!"); } } catch (Exception e1) { MainForm.Error(e1.Message); } }
/****************************************************** * 员工登录 ******************************************************/ private void EmpLogin(HttpContext context) { string strType = "0"; string strData = ""; string empAccount = context.Request["empAccount"]; string empPwd = DataBase.StringToMD5Hash(context.Request["pwd"]); //加密后的密码 string remember = context.Request["remember"]; //是否记住密码 string checkCode = context.Request["checkCode"]; if (string.IsNullOrEmpty(empAccount) || string.IsNullOrEmpty(empPwd) || string.IsNullOrEmpty(checkCode)) { strData = "登录信息不能为空"; context.Response.Write("{Code:\"" + strType + "\",Msg:\"" + strData + "\"}"); return; } //验证码校验 if (context.Session["needLoginCode"] != null && context.Session["needLoginCode"].ToString() == "1") { if (!string.Equals(context.Session["CheckCode"].ToString(), context.Request["CheckCode"], StringComparison.InvariantCultureIgnoreCase)) { strData = "验证码错误!"; context.Response.Write("{Code:\"" + strType + "\",Msg:\"" + strData + "\"}"); return; } } //登录校验 EmployeeInfo empInfo = EmployeeService.Instance.IsEmployeeExist(empAccount, empPwd); if (empInfo == null) { strData = "用户名或者密码错误"; context.Response.Write("{Code:\"" + strType + "\",Msg:\"" + strData + "\"}"); return; } UsrAuth.SetLogin(context.Session, empInfo); //记住用户,下次直接登录 if (remember == "1") { UsrAuth.SetLoginCookie(context.Response, empInfo.EmpAccount, empPwd); } strType = "1"; strData = "登录成功"; context.Response.Write("{Code:\"" + strType + "\",Msg:\"" + strData + "\"}"); }
/********************************************************** * 更新上班时间 * ********************************************************/ private void Update(HttpContext context) { int code = 0; string msg = ""; string json = ""; WorkDuration wd = new WorkDuration(); #region 参数值赋给wd对象 wd.NormalTime = context.Request["normalTime"]; wd.AbsentSignInTime = context.Request["absentTimeSignIn"]; wd.AbsentSignOutTime = context.Request["absenTimeSignOut"]; wd.LeaveEarlyTime = context.Request["leaveEarlyTime"]; wd.WDFloatTime = context.Request["floatTime"]; wd.WDMonthDuration = int.Parse(context.Request["monthWorkDuration"]); wd.WDSignInMonth = context.Request["month"]; #endregion #region 验证操作权限 if (!UsrAuth.IsAdminister(context.Session)) { code = 0; msg = "无‘管理员’权限"; json = "{\"Code\":\"" + code + "\",\"Msg\":\"" + msg + "\"}"; context.Response.Write(json); return; } #endregion int res = WorkDurationService.Instance.UpdateWorkDuration(wd); if (res == 0) { code = 0; msg = "更新失败"; json = "{\"Code\":\"" + code + "\",\"Msg\":\"" + msg + "\"}"; } else { code = 1; msg = "更新成功"; json = "{\"Code\":\"" + code + "\",\"Msg\":\"" + msg + "\"}"; } context.Response.Write(json); }
/************************************************** * 部门列表 * 可用于查询、点击部门管理时显示部门列表 * 页面参数:depName 部门名称,当为空是获取部门列表 * ***********************************************/ public void GetList(HttpContext context) { int code = 0; string msg = ""; string json = ""; string depName = context.Request["searchName"]; #region 验证操作权限 if (!UsrAuth.IsAdminister(context.Session)) {//无管理员权限 code = 0; msg = "无‘管理员’权限"; json = "{\"Code\":\"" + code + "\",\"Msg\":\"" + msg + "\"}"; context.Response.Write(json); return; } #endregion DepartmentService departmentService = new DepartmentService(); List <Department> depList = departmentService.GetDepartment(depName); FeedBackMsg <List <Department> > feedBack = new FeedBackMsg <List <Department> >(); if (depList != null && depList.Count > 0) { feedBack.Code = 1; feedBack.Msg = "部门列表"; feedBack.Obj = depList; } else { feedBack.Code = 0; feedBack.Msg = "没有数据"; feedBack.Obj = null; } json = ObjToJson.ToJson(feedBack); context.Response.Write(json); }
/******************************************************** * 获取签到信息 * date:查询日期 可以为null * rate:出勤率,全勤1,非全勤0,所有null * empName:员工姓名 * ******************************************************/ private void GetDetailList(HttpContext context) { string json = ""; //验证操作权限 string empID = UsrAuth.GetempID(context.Session); string searchStartDate = context.Request["searchStartDate"]; string searchEndDate = context.Request["searchEndDate"]; string searchRate = context.Request["searchRate"]; string searchName = context.Request["searchName"]; //MODIFY string isSelf = context.Request["isSelf"]; int searchEmpID = int.Parse(context.Request["searchEmpID"]); FeedBackMsg <List <CheckInInfo> > feedBack = new FeedBackMsg <List <CheckInInfo> >(); if (string.IsNullOrEmpty(searchStartDate)) { searchStartDate = null; } if (string.IsNullOrEmpty(searchRate)) { searchRate = null; } if (string.IsNullOrEmpty(searchName)) { searchName = null; } string depID = UsrAuth.GetdepID(context.Session); string depName = UsrAuth.GetdepName(context.Session); if (searchEmpID > 0) { List <CheckInInfo> checkInInfoList = CheckInInfoService.Instance.GetCheckInInfoList(searchEmpID.ToString(), searchStartDate, searchEndDate, searchRate); feedBack.Code = 1; feedBack.Msg = "员工签到信息";//获取某个员工记录 feedBack.Obj = checkInInfoList; } else { if (!string.IsNullOrEmpty(isSelf) && isSelf.Equals("1")) //获取登录人记录 { List <CheckInInfo> checkInInfoList = CheckInInfoService.Instance.GetCheckInInfoList(empID, searchStartDate, searchEndDate, searchRate); feedBack.Code = 1; feedBack.Msg = "我的签到信息"; feedBack.Obj = checkInInfoList; } else { if (UsrAuth.IsAdminister(context.Session) || UsrAuth.IsTopManager(context.Session)) { //总经理或者管理员 List <CheckInInfo> allCheckInInfoList = CheckInInfoService.Instance.GetCheckInInfoList(0, searchName, searchStartDate, searchEndDate, searchRate); feedBack.Code = 1; feedBack.Msg = "所有员工的签到信息"; feedBack.Obj = allCheckInInfoList; } else if (UsrAuth.IsDepManager(context.Session)) { //部门经理 List <CheckInInfo> allCheckInInfoList = CheckInInfoService.Instance.GetCheckInInfoList(int.Parse(depID), searchName, searchStartDate, searchEndDate, searchRate); feedBack.Code = 1; feedBack.Msg = "部门" + depName + "员工列表"; feedBack.Obj = allCheckInInfoList; } else { feedBack.Code = 0; feedBack.Msg = "无相应权限"; feedBack.Obj = null; } } } json = ObjToJson.ToJson(feedBack); context.Response.Write(json); }
/********************************************************** * 补签到 * 管理员权限 * ********************************************************/ private void UpdateSupplement(HttpContext context) { int code = 0; string msg = ""; string json = ""; //验证操作权限 if (!UsrAuth.IsAdminister(context.Session)) {//无管理员权限 code = 0; msg = "无‘管理员’权限"; json = "{\"Code\":\"" + code + "\",\"Msg\":\"" + msg + "\"}"; context.Response.Write(json); return; } string checkInInfoID = context.Request["id"]; string currentEmpID = UsrAuth.GetempID(context.Session); string currentEmpName = UsrAuth.GetempName(context.Session); string empID = context.Request["empID"]; string empName = context.Request["empName"]; string depID = context.Request["depID"]; string depName = context.Request["depName"]; string date = context.Request["appendSignDate"]; string signInTime = context.Request["signInTime"]; string signOutTime = context.Request["signOutTime"]; string note = context.Request["ciNote"]; string allSignInOrOut = context.Request["allSignInOrOut"]; string signInDate = DateTime.Parse(date + " " + signInTime).ToString(); string signOutDate = DateTime.Parse(date + " " + signOutTime).ToString(); if (string.IsNullOrEmpty(note)) { code = 0; msg = "补签说明不能为空"; json = "{\"Code\":\"" + code + "\",\"Msg\":\"" + msg + "\"}"; context.Response.Write(json); return; } if (!string.IsNullOrEmpty(allSignInOrOut) && allSignInOrOut.Equals("1")) //给所有人补签到补签退 { int res = CheckInInfoService.Instance.UpdateCheckInInfoBySystem(date, signInTime, signOutTime, note, int.Parse(currentEmpID), currentEmpName, int.Parse(empID)); if (res != 1) { code = 0; msg = "补签失败"; } else { code = 1; msg = "补签成功"; } } else { if (string.IsNullOrEmpty(checkInInfoID)) { //补签到 if (CheckInInfoService.Instance.hasSignIn(int.Parse(empID), date)) { code = 0; msg = "员工已经签过到"; json = "{\"Code\":\"" + code + "\",\"Msg\":\"" + msg + "\"}"; context.Response.Write(json); return; } int res = CheckInInfoService.Instance.UpdateCheckInInfoBySystem(empID, empName, int.Parse(depID), depName, signInDate, note, currentEmpID, currentEmpName); if (res != 1) { code = 0; msg = "补签到失败"; } else { code = 1; msg = "补签到成功"; } } else { //补签退 if (CheckInInfoService.Instance.hasSingOut(int.Parse(empID), date)) { code = 0; msg = "员工已经签过退"; json = "{\"Code\":\"" + code + "\",\"Msg\":\"" + msg + "\"}"; context.Response.Write(json); return; } //2. 补签到正常 int res = CheckInInfoService.Instance.UpdateCheckInInfoBySystem(empID, empName, int.Parse(depID), depName, signOutDate, note, currentEmpID, currentEmpName, int.Parse(checkInInfoID)); if (res != 1) { code = 0; msg = "补签退失败"; } else { code = 1; msg = "补签退成功"; } } } json = "{\"Code\":\"" + code + "\",\"Msg\":\"" + msg + "\"}"; context.Response.Write(json); }
/****************************************************** *退出登录 ******************************************************/ private void Logout(HttpContext context) { UsrAuth.LoginOut(context.Session); UsrAuth.RemoveLoginCookie(context.Response); context.Response.Write("{Code:\"1\"}"); }