Esempio n. 1
0
        public ActionResult Delete(int id)
        {
            SaleDeliveryOrderHeader header = _SaleDeliveryOrderHeaderService.Find(id);

            if (header.Status == (int)StatusConstants.Drafted || header.Status == (int)StatusConstants.Import)
            {
                return(Remove(id));
            }
            else
            {
                return(HttpNotFound());
            }
        }
Esempio n. 2
0
        public ActionResult DeleteAfter_Submit(int id)
        {
            SaleDeliveryOrderHeader header = _SaleDeliveryOrderHeaderService.Find(id);

            if (header.Status == (int)StatusConstants.Submitted || header.Status == (int)StatusConstants.Modified)
            {
                return(Remove(id));
            }
            else
            {
                return(HttpNotFound());
            }
        }
Esempio n. 3
0
        public ActionResult ModifyAfter_Submit(int id, string IndexType)
        {
            SaleDeliveryOrderHeader header = _SaleDeliveryOrderHeaderService.Find(id);

            if (header.Status == (int)StatusConstants.Submitted || header.Status == (int)StatusConstants.Modified || header.Status == (int)StatusConstants.ModificationSubmitted)
            {
                return(Edit(id, IndexType));
            }
            else
            {
                return(HttpNotFound());
            }
        }
Esempio n. 4
0
        public ActionResult Modify(int id, string IndexType)
        {
            SaleDeliveryOrderHeader header = _SaleDeliveryOrderHeaderService.Find(id);

            if (header.Status == (int)StatusConstants.Drafted || header.Status == (int)StatusConstants.Import)
            {
                return(Edit(id, IndexType));
            }
            else
            {
                return(HttpNotFound());
            }
        }
Esempio n. 5
0
        public ActionResult Submit(int id, string IndexType, string TransactionType)
        {
            SaleDeliveryOrderHeader s = context.SaleDeliveryOrderHeader.Find(id);

            if (new RolePermissionService(_unitOfWork).IsActionAllowed(UserRoles, s.DocTypeId, null, this.ControllerContext.RouteData.Values["controller"].ToString(), "Submit") == false)
            {
                return(View("~/Views/Shared/PermissionDenied.cshtml").Warning("You don't have permission to do this task."));
            }

            #region DocTypeTimeLineValidation


            try
            {
                TimePlanValidation = Submitvalidation(id, out ExceptionMsg);
                TempData["CSEXC"] += ExceptionMsg;
            }
            catch (Exception ex)
            {
                string message = _exception.HandleException(ex);
                TempData["CSEXC"] += message;
                TimePlanValidation = false;
            }
            try
            {
                TimePlanValidation = DocumentValidation.ValidateDocument(Mapper.Map <DocumentUniqueId>(s), DocumentTimePlanTypeConstants.Submit, User.Identity.Name, out ExceptionMsg, out Continue);
                TempData["CSEXC"] += ExceptionMsg;
            }
            catch (Exception ex)
            {
                string message = _exception.HandleException(ex);
                TempData["CSEXC"] += message;
                TimePlanValidation = false;
            }

            if (!TimePlanValidation && !Continue)
            {
                return(RedirectToAction("Index", new { id = s.DocTypeId, IndexType = IndexType }));
            }
            #endregion

            return(RedirectToAction("Detail", new { id = id, IndexType = IndexType, transactionType = string.IsNullOrEmpty(TransactionType) ? "submit" : TransactionType }));
        }
Esempio n. 6
0
        public ActionResult Detail(int id, string transactionType, string IndexType)
        {
            ViewBag.transactionType = transactionType;
            ViewBag.IndexStatus     = IndexType;

            SaleDeliveryOrderHeader s = _SaleDeliveryOrderHeaderService.GetSaleDeliveryOrderHeader(id);

            if (s == null)
            {
                return(HttpNotFound());
            }

            //Job Order Settings
            var settings = new SaleDeliveryOrderSettingsService(_unitOfWork).GetSaleDeliveryOrderSettingsForDocument(s.DocTypeId, s.DivisionId, s.SiteId);

            if (settings == null)
            {
                return(RedirectToAction("Create", "SaleDeliveryOrderSettings", new { id = s.DocTypeId }).Warning("Please create SaleDeliveryOrder settings"));
            }

            SaleDeliveryOrderHeaderViewModel svm = Mapper.Map <SaleDeliveryOrderHeader, SaleDeliveryOrderHeaderViewModel>(s);

            svm.SaleDeliveryOrderSettings = Mapper.Map <SaleDeliveryOrderSettings, SaleDeliveryOrderSettingsViewModel>(settings);

            PrepareViewBag(svm.DocTypeId);

            if (String.IsNullOrEmpty(transactionType) || transactionType == "detail")
            {
                LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
                {
                    DocTypeId    = s.DocTypeId,
                    DocId        = s.SaleDeliveryOrderHeaderId,
                    ActivityType = (int)ActivityTypeContants.Detail,
                    DocNo        = s.DocNo,
                    DocDate      = s.DocDate,
                    DocStatus    = s.Status,
                }));
            }


            return(View("Create", svm));
        }
Esempio n. 7
0
 public void Update(SaleDeliveryOrderHeader s)
 {
     s.ObjectState = ObjectState.Modified;
     _unitOfWork.Repository <SaleDeliveryOrderHeader>().Update(s);
 }
Esempio n. 8
0
 public void Delete(SaleDeliveryOrderHeader s)
 {
     _unitOfWork.Repository <SaleDeliveryOrderHeader>().Delete(s);
 }
Esempio n. 9
0
 public SaleDeliveryOrderHeader Create(SaleDeliveryOrderHeader s)
 {
     s.ObjectState = ObjectState.Added;
     _unitOfWork.Repository <SaleDeliveryOrderHeader>().Insert(s);
     return(s);
 }
Esempio n. 10
0
        // GET: /SaleDeliveryOrderHeader/Edit/5
        private ActionResult Edit(int id, string IndexType)
        {
            ViewBag.IndexStatus = IndexType;

            SaleDeliveryOrderHeader s = _SaleDeliveryOrderHeaderService.GetSaleDeliveryOrderHeader(id);

            if (s == null)
            {
                return(HttpNotFound());
            }

            if (new RolePermissionService(_unitOfWork).IsActionAllowed(UserRoles, s.DocTypeId, null, this.ControllerContext.RouteData.Values["controller"].ToString(), "Edit") == false)
            {
                return(View("~/Views/Shared/PermissionDenied.cshtml").Warning("You don't have permission to do this task."));
            }

            #region DocTypeTimeLineValidation
            try
            {
                TimePlanValidation = DocumentValidation.ValidateDocument(Mapper.Map <DocumentUniqueId>(s), DocumentTimePlanTypeConstants.Modify, User.Identity.Name, out ExceptionMsg, out Continue);
            }
            catch (Exception ex)
            {
                string message = _exception.HandleException(ex);
                TempData["CSEXC"] += message;
                TimePlanValidation = false;
            }

            if (!TimePlanValidation)
            {
                TempData["CSEXC"] += ExceptionMsg;
            }
            #endregion

            if ((!TimePlanValidation && !Continue))
            {
                return(RedirectToAction("DetailInformation", new { id = id, IndexType = IndexType }));
            }
            //Job Order Settings
            var settings = new SaleDeliveryOrderSettingsService(_unitOfWork).GetSaleDeliveryOrderSettingsForDocument(s.DocTypeId, s.DivisionId, s.SiteId);

            if (settings == null && UserRoles.Contains("SysAdmin"))
            {
                return(RedirectToAction("Create", "SaleDeliveryOrderSettings", new { id = s.DocTypeId }).Warning("Please create SaleDeliveryOrder settings"));
            }
            else if (settings == null && !UserRoles.Contains("SysAdmin"))
            {
                return(View("~/Views/Shared/InValidSettings.cshtml"));
            }

            SaleDeliveryOrderHeaderViewModel svm = Mapper.Map <SaleDeliveryOrderHeader, SaleDeliveryOrderHeaderViewModel>(s);
            svm.SaleDeliveryOrderSettings = Mapper.Map <SaleDeliveryOrderSettings, SaleDeliveryOrderSettingsViewModel>(settings);

            PrepareViewBag(s.DocTypeId);
            ViewBag.Mode = "Edit";

            if (!(System.Web.HttpContext.Current.Request.UrlReferrer.PathAndQuery).Contains("Create"))
            {
                LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
                {
                    DocTypeId    = s.DocTypeId,
                    DocId        = s.SaleDeliveryOrderHeaderId,
                    ActivityType = (int)ActivityTypeContants.Detail,
                    DocNo        = s.DocNo,
                    DocDate      = s.DocDate,
                    DocStatus    = s.Status,
                }));
            }

            return(View("Create", svm));
        }
Esempio n. 11
0
        public ActionResult HeaderPost(SaleDeliveryOrderHeaderViewModel svm)
        {
            if (svm.DocDate > svm.DueDate)
            {
                ModelState.AddModelError("DueDate", "DueDate cannot be greater than DocDate");
            }

            #region DocTypeTimeLineValidation

            try
            {
                if (svm.SaleDeliveryOrderHeaderId <= 0)
                {
                    TimePlanValidation = DocumentValidation.ValidateDocument(Mapper.Map <DocumentUniqueId>(svm), DocumentTimePlanTypeConstants.Create, User.Identity.Name, out ExceptionMsg, out Continue);
                }
                else
                {
                    TimePlanValidation = DocumentValidation.ValidateDocument(Mapper.Map <DocumentUniqueId>(svm), DocumentTimePlanTypeConstants.Modify, User.Identity.Name, out ExceptionMsg, out Continue);
                }
            }
            catch (Exception ex)
            {
                string message = _exception.HandleException(ex);
                TempData["CSEXC"] += message;
                TimePlanValidation = false;
            }

            if (!TimePlanValidation)
            {
                TempData["CSEXC"] += ExceptionMsg;
            }

            #endregion

            if (ModelState.IsValid && (TimePlanValidation || Continue))
            {
                #region CreateRecord
                if (svm.SaleDeliveryOrderHeaderId <= 0)
                {
                    SaleDeliveryOrderHeader s = Mapper.Map <SaleDeliveryOrderHeaderViewModel, SaleDeliveryOrderHeader>(svm);

                    s.CreatedDate  = DateTime.Now;
                    s.ModifiedDate = DateTime.Now;
                    s.CreatedBy    = User.Identity.Name;
                    s.ModifiedBy   = User.Identity.Name;
                    s.Status       = (int)StatusConstants.Drafted;
                    _SaleDeliveryOrderHeaderService.Create(s);

                    try
                    {
                        _unitOfWork.Save();
                    }

                    catch (Exception ex)
                    {
                        string message = _exception.HandleException(ex);
                        TempData["CSEXC"] += message;
                        PrepareViewBag(svm.DocTypeId);
                        ViewBag.Mode = "Add";
                        return(View("Create", svm));
                    }

                    LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
                    {
                        DocTypeId    = s.DocTypeId,
                        DocId        = s.SaleDeliveryOrderHeaderId,
                        ActivityType = (int)ActivityTypeContants.Added,
                        DocNo        = s.DocNo,
                        DocDate      = s.DocDate,
                        DocStatus    = s.Status,
                    }));

                    return(RedirectToAction("Modify", new { id = s.SaleDeliveryOrderHeaderId }).Success("Data saved Successfully"));
                }
                #endregion

                #region EditRecord
                else
                {
                    //string tempredirect = (Request["Redirect"].ToString());
                    List <LogTypeViewModel> LogList = new List <LogTypeViewModel>();

                    SaleDeliveryOrderHeader s         = Mapper.Map <SaleDeliveryOrderHeaderViewModel, SaleDeliveryOrderHeader>(svm);
                    StringBuilder           logstring = new StringBuilder();
                    SaleDeliveryOrderHeader temp      = _SaleDeliveryOrderHeaderService.Find(s.SaleDeliveryOrderHeaderId);

                    SaleDeliveryOrderHeader ExRec = new SaleDeliveryOrderHeader();
                    ExRec = Mapper.Map <SaleDeliveryOrderHeader>(temp);

                    int status = temp.Status;

                    if (temp.Status != (int)StatusConstants.Drafted && temp.Status != (int)StatusConstants.Import)
                    {
                        temp.Status = (int)StatusConstants.Modified;
                    }

                    temp.DocDate      = s.DocDate;
                    temp.DocNo        = s.DocNo;
                    temp.Priority     = s.Priority;
                    temp.ShipMethodId = s.ShipMethodId;
                    temp.ShipAddress  = s.ShipAddress;
                    temp.Remark       = s.Remark;
                    temp.DueDate      = s.DueDate;
                    temp.ModifiedDate = DateTime.Now;
                    temp.ModifiedBy   = User.Identity.Name;
                    _SaleDeliveryOrderHeaderService.Update(temp);

                    LogList.Add(new LogTypeViewModel
                    {
                        ExObj = ExRec,
                        Obj   = temp,
                    });

                    XElement Modifications = new ModificationsCheckService().CheckChanges(LogList);

                    try
                    {
                        _unitOfWork.Save();
                    }

                    catch (Exception ex)
                    {
                        string message = _exception.HandleException(ex);
                        TempData["CSEXC"] += message;
                        PrepareViewBag(svm.DocTypeId);
                        ViewBag.Mode = "Edit";
                        return(View("Create", svm));
                    }

                    LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
                    {
                        DocTypeId       = temp.DocTypeId,
                        DocId           = temp.SaleDeliveryOrderHeaderId,
                        ActivityType    = (int)ActivityTypeContants.Modified,
                        DocNo           = temp.DocNo,
                        xEModifications = Modifications,
                        DocDate         = temp.DocDate,
                        DocStatus       = temp.Status,
                    }));

                    return(RedirectToAction("Index", new { id = svm.DocTypeId }).Success("Data saved successfully"));
                }
                #endregion
            }
            PrepareViewBag(svm.DocTypeId);
            ViewBag.Mode = "Add";
            return(View("Create", svm));
        }