Exemple #1
0
        /**************************************************
        * 获取员工信息列表
        * 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);
        }
        /********************************************************
        * 签到:插入一条考勤信息,初始化
        *       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);
        }
        /**********************************************************
        * 补签到
        * 管理员权限
        * ********************************************************/
        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);
        }