Exemple #1
0
        public IActionResult Edit(TLeaveApplicationCreateViewModel T)
        {
            var errors = ModelState.Values.SelectMany(v => v.Errors);

            if (ModelState.IsValid)
            {
                if (T != null)
                {
                    TLeaveApplication _revised = MyHr.TLeaveApplications.FirstOrDefault(i => i.CApplyNumber == T.CApplyNumber);

                    if (_revised != null)
                    {
                        _revised.CApplyDate      = T.CApplyDate;
                        _revised.CLeaveCategory  = T.CLeaveCategory;
                        _revised.CLeaveStartTime = T.CLeaveStartTime;
                        _revised.CLeaveEndTime   = T.CLeaveEndTime;
                        _revised.CReason         = T.CReason;
                        _revised.CLeaveHours     = T.CLeaveHours;

                        MyHr.SaveChanges();
                    }
                }

                return(RedirectToAction("LeaveList"));
            }
            else
            {
                List <TLeave> listLeave = GetLeaveList();
                ViewBag.LeaveCate = listLeave;
                return(View());
            }
        }
        //勾選退件
        public JsonResult getFailString(string d)
        {
            string[]   ids  = d.Split('\\', '"', '[', ',', ']');
            List <int> list = new List <int>();

            foreach (var item in ids)
            {
                if (item != "")
                {
                    list.Add(int.Parse(item));
                }
            }
            foreach (var i in list)
            {
                TLeaveApplication leave = DB.TLeaveApplications.FirstOrDefault(c => c.CApplyNumber == i);
                if (leave.CCheckStatus == 1)
                {
                    if (leave != null)
                    {
                        leave.CCheckStatus = 3;
                        DB.SaveChanges();
                    }
                }
            }
            return(Json(d));
        }
Exemple #3
0
        public IActionResult Delete(int?Id)  //刪除
        {
            if (Id != null)
            {
                TLeaveApplication T = MyHr.TLeaveApplications.FirstOrDefault(i => i.CApplyNumber == Id);
                if (T != null)
                {
                    MyHr.TLeaveApplications.Remove(T);
                    MyHr.SaveChanges();
                }
            }

            return(RedirectToAction("LeaveList"));
        }
 public IActionResult fail(int?id)
 {
     if (id != null)
     {
         dbMyCompanyContext db    = new dbMyCompanyContext();
         TLeaveApplication  leave = db.TLeaveApplications.FirstOrDefault(l => l.CApplyNumber == id);
         if (leave != null)
         {
             if (leave.CCheckStatus == 1)
             {
                 leave.CCheckStatus = 3;
                 db.SaveChanges();
             }
         }
     }
     return(RedirectToAction("List"));
 }
        //通過或退件
        public IActionResult pass(int?id)
        {
            if (id != null)
            {
                TLeaveApplication leave = DB.TLeaveApplications.FirstOrDefault(l => l.CApplyNumber == id);

                if (leave != null)
                {
                    if (leave.CCheckStatus == 1)
                    {
                        leave.CCheckStatus = 2;
                        DB.SaveChanges();
                    }
                }
            }
            return(RedirectToAction("List"));
        }
Exemple #6
0
        public IActionResult Edit(int?Id)
        {
            List <TLeave> listLeave = GetLeaveList();  //從資料庫取假別下拉是選單

            ViewBag.LeaveCate = listLeave;



            ViewData[CDictionary.CURRENT_LOGINED_USERDEPARTMENTID] = HttpContext.Session.GetString(CDictionary.CURRENT_LOGINED_USERDEPARTMENTID);
            ViewData[CDictionary.CURRENT_LOGINED_USERDEPARTMENT]   = HttpContext.Session.GetString(CDictionary.CURRENT_LOGINED_USERDEPARTMENT);
            ViewData[CDictionary.CURRENT_LOGINED_USERID]           = HttpContext.Session.GetString(CDictionary.CURRENT_LOGINED_USERID);
            ViewData[CDictionary.CURRENT_LOGINED_USERNAME]         = HttpContext.Session.GetString(CDictionary.CURRENT_LOGINED_USERNAME);
            ViewData["Today"] = DateTime.Now.ToString("yyyy-MM-dd");

            if (Id != null)
            {
                TLeaveApplication T = MyHr.TLeaveApplications.FirstOrDefault(i => i.CApplyNumber == Id);
                if (T != null)
                {
                    return(View(new TLeaveApplicationEditViewModel(T)));
                }
            }
            return(RedirectToAction("LeaveList"));
        }
Exemple #7
0
        //------------------------------------------------------------

        public TLeaveApplicationViewModel()
        {
            iv_Leave      = new TLeaveApplication();
            iv_User       = new TUser();
            iv_Department = new TUserDepartment();
        }
Exemple #8
0
 public TLeaveApplicationViewModel(TLeaveApplication p, TUserDepartment d, TUser u)
 {
     iv_Leave      = p;
     iv_Department = d;
     iv_User       = u;
 }
Exemple #9
0
 public TLeaveApplicationViewModel(TLeaveApplication p, TUser u)
 {
     iv_Leave = p;
     iv_User  = u;
 }
 public TLeaveApplicationEditViewModel()
 {
     iv_Leave = new TLeaveApplication();
 }
 public TLeaveApplicationEditViewModel(TLeaveApplication p)
 {
     iv_Leave = p;
 }
 public TLeaveApplicationCreateViewModel()
 {
     iv_Leave = new TLeaveApplication();
 }
 public TLeaveApplicationCreateViewModel(TLeaveApplication p)
 {
     iv_Leave = p;
 }
Exemple #14
0
        public JsonResult newLeaveApply()
        {
            //int[] memberBox = new int[]
            //{
            //    2,16
            //};
            int[] categoryBox = new int[]
            {
                1, 2, 3, 4, 1
            };
            string[] dateBox = new string[]
            {
                "2021-05-01T10:15",
                "2021-05-01T07:20",
                "2021-05-01T09:38",
                "2021-09-01T08:50",
                "2021-09-01T10:20",
                "2021-09-02T11:40",
                "2021-11-06T16:15",
                "2021-11-04T10:26",
                "2021-11-01T08:33",
                "2021-05-01T10:45",
                "2021-09-15T09:56",
                "2021-04-01T12:44",
                "2021-10-01T14:20",
                "2021-11-01T07:19",
                "2021-05-01T09:44",
            };

            string[] reasonBox = new string[]
            {
                "隨機資料1",
                "隨機資料2",
                "隨機資料3",
                "隨機資料4",
                "隨機資料5",
            };

            int[] hoursBox = new int[]
            {
                2, 3, 4, 5, 1
            };

            Random random   = new Random();
            var    LeaveBox = MyHr.TLeaveApplications.ToList();

            for (int i = 0; i < 15; i++)
            {
                TLeaveApplication order = new TLeaveApplication()
                {
                    CDepartmentId   = 2,
                    CEmployeeId     = 30,
                    CApplyDate      = dateBox[random.Next(0, dateBox.Count())],
                    CLeaveCategory  = categoryBox[random.Next(0, 5)],
                    CLeaveStartTime = dateBox[random.Next(0, dateBox.Count())],
                    CLeaveEndTime   = dateBox[random.Next(0, dateBox.Count())],
                    CReason         = reasonBox[random.Next(0, 4)],
                    CLeaveHours     = hoursBox[random.Next(0, 4)],
                    CCheckStatus    = 1,
                };
                MyHr.TLeaveApplications.Add(order);
            }
            MyHr.SaveChanges();

            return(Json("done"));
        }