Example #1
0
        public ActionResult Create(RegisterForOvertimeViewModel model)
        {
            if (ModelState.IsValid)
            {
                var RegisterForOvertime = new RegisterForOvertime();
                AutoMapper.Mapper.Map(model, RegisterForOvertime);
                RegisterForOvertime.IsDeleted      = false;
                RegisterForOvertime.CreatedUserId  = WebSecurity.CurrentUserId;
                RegisterForOvertime.ModifiedUserId = WebSecurity.CurrentUserId;
                RegisterForOvertime.AssignedUserId = WebSecurity.CurrentUserId;
                RegisterForOvertime.CreatedDate    = DateTime.Now;
                RegisterForOvertime.ModifiedDate   = DateTime.Now;
                string   strStartTime = RegisterForOvertime.DayOvertime.Value.ToString("dd/MM/yyyy") + " " + model.str_StartHour;
                DateTime StartTime    = DateTime.ParseExact(strStartTime, "dd/MM/yyyy HH:mm", null);
                string   strEndTime   = RegisterForOvertime.DayOvertime.Value.ToString("dd/MM/yyyy") + " " + model.str_EndHour;
                DateTime EndTime      = DateTime.ParseExact(strEndTime, "dd/MM/yyyy HH:mm", null);
                RegisterForOvertime.StartHour = StartTime;
                RegisterForOvertime.EndHour   = EndTime;
                RegisterForOvertimeRepository.InsertRegisterForOvertime(RegisterForOvertime);

                var prefix1 = Erp.BackOffice.Helpers.Common.GetSetting("prefixOrderNo_RegisterForOverTime");
                RegisterForOvertime.Code = Erp.BackOffice.Helpers.Common.GetCode(prefix1, RegisterForOvertime.Id);
                RegisterForOvertimeRepository.UpdateRegisterForOvertime(RegisterForOvertime);
                TempData[Globals.SuccessMessageKey] = App_GlobalResources.Wording.InsertSuccess;
                if (Request["IsPopup"] == "true" || Request["IsPopup"] == "True")
                {
                    ViewBag.closePopup = "true";
                    model.Id           = RegisterForOvertime.Id;
                    return(View(model));
                }
            }
            return(View(model));
        }
Example #2
0
        public ActionResult Detail(int?Id)
        {
            var RegisterForOvertime = RegisterForOvertimeRepository.GetRegisterForOvertimeById(Id.Value);

            if (RegisterForOvertime != null && RegisterForOvertime.IsDeleted != true)
            {
                var model = new RegisterForOvertimeViewModel();
                AutoMapper.Mapper.Map(RegisterForOvertime, model);

                //if (model.CreatedUserId != Helpers.Common.CurrentUser.Id && Helpers.Common.CurrentUser.UserTypeId != 1)
                //{
                //    TempData["FailedMessage"] = "NotOwner";
                //    return RedirectToAction("Index");
                //}

                return(View(model));
            }
            if (Request.UrlReferrer != null)
            {
                return(Redirect(Request.UrlReferrer.AbsoluteUri));
            }
            return(RedirectToAction("Index"));
        }
Example #3
0
        public ActionResult Edit(RegisterForOvertimeViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (Request["Submit"] == "Save")
                {
                    var RegisterForOvertime = RegisterForOvertimeRepository.GetRegisterForOvertimeById(model.Id);
                    AutoMapper.Mapper.Map(model, RegisterForOvertime);
                    RegisterForOvertime.ModifiedUserId = WebSecurity.CurrentUserId;
                    RegisterForOvertime.ModifiedDate   = DateTime.Now;
                    string   strStartTime = RegisterForOvertime.DayOvertime.Value.ToString("dd/MM/yyyy") + " " + model.str_StartHour;
                    DateTime StartTime    = DateTime.ParseExact(strStartTime, "dd/MM/yyyy HH:mm", null);
                    string   strEndTime   = RegisterForOvertime.DayOvertime.Value.ToString("dd/MM/yyyy") + " " + model.str_EndHour;
                    DateTime EndTime      = DateTime.ParseExact(strEndTime, "dd/MM/yyyy HH:mm", null);
                    RegisterForOvertime.StartHour = StartTime;
                    RegisterForOvertime.EndHour   = EndTime;
                    RegisterForOvertimeRepository.UpdateRegisterForOvertime(RegisterForOvertime);

                    TempData[Globals.SuccessMessageKey] = App_GlobalResources.Wording.UpdateSuccess;
                    if (Request["IsPopup"] == "true" || Request["IsPopup"] == "True")
                    {
                        ViewBag.closePopup = "true";
                        model.Id           = RegisterForOvertime.Id;
                        return(View(model));
                    }
                }

                return(View(model));
            }

            return(View(model));

            //if (Request.UrlReferrer != null)
            //    return Redirect(Request.UrlReferrer.AbsoluteUri);
            //return RedirectToAction("Index");
        }
Example #4
0
        public ViewResult Create()
        {
            var model = new RegisterForOvertimeViewModel();

            return(View(model));
        }