Exemple #1
0
        public ApiBaseResult LeaveSpecial([FromBody] LeaveSpecialModel data)
        {
            ApiBaseResult result;

            if (data != null)
            {
                if (data.Check())
                {
                    result = Check(data.access_token);
                    if (result == null)
                    {
                        return(leaveSpecial(data));
                    }
                    else
                    {
                        return(result);
                    }
                }
                else
                {
                    result          = new ApiBaseResult();
                    result.result   = "error";
                    result.messages = "参数格式错误或缺少参数!";
                    return(result);
                }
            }
            else
            {
                result          = new ApiBaseResult();
                result.result   = "error";
                result.messages = "参数错误!";
                return(result);
            }
        }
Exemple #2
0
        private ApiBaseResult leaveSpecial(LeaveSpecialModel data)
        {
            ApiBaseResult result = new ApiBaseResult();

            try
            {
                #region 请假操作
                string access_token = data.access_token;
                string ST_Num       = access_token.Substring(0, access_token.IndexOf("_"));
                string LL_Type      = data.leave_type + data.leave_child_type;
                string leaveDate    = data.leave_date;
                string leaveTime    = data.leave_time;
                string backDate     = data.back_date;
                string backTime     = data.leave_time;
                string leaveReason  = data.leave_reason;
                string leaveWay     = null;
                string backWay      = null;
                string address      = null;
                string holidayType  = null;


                if (data.leave_type == "晚点名请假")
                {
                    string   LV_NUM       = DateTime.Now.ToString("yyMMdd");//流水号生成
                    string   studytime_sp = leaveDate + " " + leaveTime;
                    DateTime time_go      = Convert.ToDateTime(studytime_sp);
                    DateTime time_back    = time_go;
                    var      exist        = from T_LeaveList in db.T_LeaveList where ((T_LeaveList.StudentID == ST_Num) && (T_LeaveList.TimeLeave == time_go) && (T_LeaveList.TypeID == 2)) select T_LeaveList;

                    if (exist.Any())
                    {
                        bool flag = true;
                        foreach (qingjia_MVC.Models.T_LeaveList leaveList in exist.ToList())
                        {
                            if (leaveList.StateBack == "0")
                            {
                                flag = false;
                                break;
                            }
                        }
                        if (flag)
                        {
                            //插入数据库操作
                            if (Insert_LeaveList(LV_NUM, ST_Num, LL_Type, time_go, time_back, leaveReason, leaveWay, backWay, address, holidayType, null, null, null) == 1)
                            {
                                result.result   = "success";
                                result.messages = "请假申请成功!";
                            }
                            else
                            {
                                result.result   = "error";
                                result.messages = "数据库提交失败,请重新尝试!";
                            }
                        }
                        else
                        {
                            result.result   = "error";
                            result.messages = "您已提交过此时间段的请假申请,请不要重复提交!";
                        }
                    }
                    else
                    {
                        //插入数据库操作
                        if (Insert_LeaveList(LV_NUM, ST_Num, LL_Type, time_go, time_back, leaveReason, leaveWay, backWay, address, holidayType, null, null, null) == 1)
                        {
                            result.result   = "success";
                            result.messages = "请假申请成功!";
                        }
                        else
                        {
                            result.result   = "error";
                            result.messages = "数据库提交失败,请重新尝试!";
                        }
                    }
                }
                else if (data.leave_type == "早晚自习请假")
                {
                    string   LV_NUM       = DateTime.Now.ToString("yyMMdd");//流水号生成
                    string   studytime_sp = leaveDate + " " + leaveTime;
                    DateTime time_go      = Convert.ToDateTime(studytime_sp);
                    DateTime time_back    = time_go;
                    var      exist        = from T_LeaveList in db.T_LeaveList where ((T_LeaveList.StudentID == ST_Num) && (T_LeaveList.TimeLeave == time_go) && (T_LeaveList.TypeID == 2)) select T_LeaveList;

                    if (exist.Any())
                    {
                        bool flag = true;
                        foreach (qingjia_MVC.Models.T_LeaveList leaveList in exist.ToList())
                        {
                            if (leaveList.StateBack == "0")
                            {
                                flag = false;
                                break;
                            }
                        }
                        if (flag)
                        {
                            //插入数据库操作
                            if (Insert_LeaveList(LV_NUM, ST_Num, LL_Type, time_go, time_back, leaveReason, leaveWay, backWay, address, holidayType, null, null, null) == 1)
                            {
                                result.result   = "success";
                                result.messages = "请假申请成功!";
                            }
                            else
                            {
                                result.result   = "error";
                                result.messages = "数据库提交失败,请重新尝试!";
                            }
                        }
                        else
                        {
                            result.result   = "error";
                            result.messages = "您已提交过此时间段的请假申请,请不要重复提交!";
                        }
                    }
                    else
                    {
                        //插入数据库操作
                        if (Insert_LeaveList(LV_NUM, ST_Num, LL_Type, time_go, time_back, leaveReason, leaveWay, backWay, address, holidayType, null, null, null) == 1)
                        {
                            result.result   = "success";
                            result.messages = "请假申请成功!";
                        }
                        else
                        {
                            result.result   = "error";
                            result.messages = "数据库提交失败,请重新尝试!";
                        }
                    }
                }
                #endregion
            }
            catch
            {
                result.result   = "error";
                result.messages = "请假失败,请检查参数格式是否符合要求!";
            }

            return(result);
        }