Esempio n. 1
0
        public ActionResult DeletePost(ProdOrderCancelLineViewModel vm)
        {
            List <LogTypeViewModel> LogList = new List <LogTypeViewModel>();

            ProdOrderCancelLine SaleOrderLine = _ProdOrderCancelLineService.Find(vm.ProdOrderCancelLineId);

            LogList.Add(new LogTypeViewModel
            {
                ExObj = SaleOrderLine,
            });

            ProdOrderCancelHeader header = new ProdOrderCancelHeaderService(_unitOfWork).Find(SaleOrderLine.ProdOrderCancelHeaderId);
            int status = header.Status;

            new ProdOrderLineStatusService(_unitOfWork).UpdateProdQtyOnCancel(SaleOrderLine.ProdOrderLineId, SaleOrderLine.ProdOrderCancelLineId, header.DocDate, 0, ref db, false);

            _ProdOrderCancelLineService.Delete(vm.ProdOrderCancelLineId);

            if (header.Status != (int)StatusConstants.Drafted)
            {
                header.Status = (int)StatusConstants.Modified;
                new ProdOrderCancelHeaderService(_unitOfWork).Update(header);
            }
            XElement Modifications = new ModificationsCheckService().CheckChanges(LogList);

            try
            {
                _unitOfWork.Save();
            }

            catch (Exception ex)
            {
                string message = _exception.HandleException(ex);
                TempData["CSEXC"] += message;
                return(PartialView("_Create", vm));
            }

            LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
            {
                DocTypeId       = header.DocTypeId,
                DocId           = header.ProdOrderCancelHeaderId,
                DocLineId       = SaleOrderLine.ProdOrderCancelLineId,
                ActivityType    = (int)ActivityTypeContants.Deleted,
                DocNo           = header.DocNo,
                xEModifications = Modifications,
                DocDate         = header.DocDate,
                DocStatus       = header.Status,
            }));

            return(Json(new { success = true }));
        }
Esempio n. 2
0
        public ActionResult _Create(int Id) //Id ==>Prod Order Cancel Header Id
        {
            ProdOrderCancelHeader        Header = new ProdOrderCancelHeaderService(_unitOfWork).Find(Id);
            ProdOrderCancelLineViewModel svm    = new ProdOrderCancelLineViewModel();

            //Getting Settings
            var settings = new ProdOrderSettingsService(_unitOfWork).GetProdOrderSettingsForDocument(Header.DocTypeId, Header.DivisionId, Header.SiteId);

            svm.ProdOrderSettings = Mapper.Map <ProdOrderSettings, ProdOrderSettingsViewModel>(settings);

            svm.ProdOrderCancelHeaderId = Id;
            ViewBag.LineMode            = "Create";
            svm.DivisionId = Header.DivisionId;
            return(PartialView("_Create", svm));
        }
Esempio n. 3
0
        public ActionResult _Detail(int id)
        {
            ProdOrderCancelLineViewModel temp = _ProdOrderCancelLineService.GetProdOrderCancelLine(id);

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

            ProdOrderCancelHeader H = new ProdOrderCancelHeaderService(_unitOfWork).Find(temp.ProdOrderCancelHeaderId);
            //Getting Settings
            var settings = new ProdOrderSettingsService(_unitOfWork).GetProdOrderSettingsForDocument(H.DocTypeId, H.DivisionId, H.SiteId);

            temp.ProdOrderSettings = Mapper.Map <ProdOrderSettings, ProdOrderSettingsViewModel>(settings);


            return(PartialView("_Create", temp));
        }
Esempio n. 4
0
        private ActionResult _Delete(int id)
        {
            ProdOrderCancelLineViewModel temp = _ProdOrderCancelLineService.GetProdOrderCancelLine(id);

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

            #region DocTypeTimeLineValidation
            try
            {
                TimePlanValidation = DocumentValidation.ValidateDocumentLine(new DocumentUniqueId {
                    LockReason = temp.LockReason
                }, User.Identity.Name, out ExceptionMsg, out Continue);
            }
            catch (Exception ex)
            {
                string message = _exception.HandleException(ex);
                TempData["CSEXCL"] += message;
                TimePlanValidation  = false;
            }

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

            if ((TimePlanValidation || Continue))
            {
                ViewBag.LineMode = "Delete";
            }

            ProdOrderCancelHeader H = new ProdOrderCancelHeaderService(_unitOfWork).Find(temp.ProdOrderCancelHeaderId);
            //Getting Settings
            var settings = new ProdOrderSettingsService(_unitOfWork).GetProdOrderSettingsForDocument(H.DocTypeId, H.DivisionId, H.SiteId);

            temp.ProdOrderSettings = Mapper.Map <ProdOrderSettings, ProdOrderSettingsViewModel>(settings);


            return(PartialView("_Create", temp));
        }
Esempio n. 5
0
        public ActionResult _CreatePost(ProdOrderCancelLineViewModel svm)
        {
            if (svm.ProdOrderCancelLineId <= 0)
            {
                ViewBag.LineMode = "Create";
            }
            else
            {
                ViewBag.LineMode = "Edit";
            }

            if (svm.ProdOrderCancelLineId <= 0)
            {
                ProdOrderCancelLine s      = new ProdOrderCancelLine();
                decimal             balqty = (from p in db.ViewProdOrderBalance
                                              where p.ProdOrderLineId == svm.ProdOrderLineId
                                              select p.BalanceQty).FirstOrDefault();
                if (balqty < svm.Qty)
                {
                    ModelState.AddModelError("Qty", "Qty Exceeding Balance Qty");
                }
                if (svm.Qty == 0)
                {
                    ModelState.AddModelError("Qty", "Please Check Qty");
                }
                if (svm.ProdOrderLineId == 0)
                {
                    ModelState.AddModelError("ProdOrderLineId", "The Prod Order field is required");
                }
                if (ModelState.IsValid)
                {
                    s.ProdOrderCancelHeaderId = svm.ProdOrderCancelHeaderId;
                    s.ProdOrderLineId         = svm.ProdOrderLineId;
                    s.Qty          = svm.Qty;
                    s.CreatedDate  = DateTime.Now;
                    s.ModifiedDate = DateTime.Now;
                    s.CreatedBy    = User.Identity.Name;
                    s.ModifiedBy   = User.Identity.Name;
                    _ProdOrderCancelLineService.Create(s);

                    ProdOrderCancelHeader temp2 = new ProdOrderCancelHeaderService(_unitOfWork).Find(s.ProdOrderCancelHeaderId);

                    new ProdOrderLineStatusService(_unitOfWork).UpdateProdQtyOnCancel(s.ProdOrderLineId, s.ProdOrderCancelLineId, temp2.DocDate, s.Qty, ref db, false);


                    if (temp2.Status != (int)StatusConstants.Drafted && temp2.Status != (int)StatusConstants.Import)
                    {
                        temp2.Status       = (int)StatusConstants.Modified;
                        temp2.ModifiedBy   = User.Identity.Name;
                        temp2.ModifiedDate = DateTime.Now;
                    }
                    new ProdOrderCancelHeaderService(_unitOfWork).Update(temp2);

                    try
                    {
                        _unitOfWork.Save();
                    }
                    catch (Exception ex)
                    {
                        string message = _exception.HandleException(ex);
                        TempData["CSEXCL"] += message;
                        return(PartialView("_Create", svm));
                    }

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

                    return(RedirectToAction("_Create", new { id = s.ProdOrderCancelHeaderId }));
                }
                return(PartialView("_Create", svm));
            }
            else
            {
                List <LogTypeViewModel> LogList = new List <LogTypeViewModel>();

                ProdOrderCancelHeader temp = new ProdOrderCancelHeaderService(_unitOfWork).Find(svm.ProdOrderCancelHeaderId);
                int           status       = temp.Status;
                StringBuilder logstring    = new StringBuilder();

                ProdOrderCancelLine s = _ProdOrderCancelLineService.Find(svm.ProdOrderCancelLineId);

                ProdOrderCancelLine ExRec = new ProdOrderCancelLine();
                ExRec = Mapper.Map <ProdOrderCancelLine>(s);

                decimal balqty = (from p in db.ViewProdOrderBalance
                                  where p.ProdOrderLineId == svm.ProdOrderLineId
                                  select p.BalanceQty).FirstOrDefault();
                if (balqty + s.Qty < svm.Qty)
                {
                    ModelState.AddModelError("Qty", "Qty Exceeding Balance Qty");
                }


                if (ModelState.IsValid)
                {
                    if (svm.Qty > 0)
                    {
                        s.Qty          = svm.Qty;
                        s.ModifiedBy   = User.Identity.Name;
                        s.ModifiedDate = DateTime.Now;
                    }

                    _ProdOrderCancelLineService.Update(s);

                    new ProdOrderLineStatusService(_unitOfWork).UpdateProdQtyOnCancel(s.ProdOrderLineId, s.ProdOrderCancelLineId, temp.DocDate, s.Qty, ref db, false);

                    temp.Status = (int)StatusConstants.Modified;
                    new ProdOrderCancelHeaderService(_unitOfWork).Update(temp);

                    LogList.Add(new LogTypeViewModel
                    {
                        ExObj = ExRec,
                        Obj   = s,
                    });
                    XElement Modifications = new ModificationsCheckService().CheckChanges(LogList);
                    try
                    {
                        _unitOfWork.Save();
                    }

                    catch (Exception ex)
                    {
                        string message = _exception.HandleException(ex);
                        TempData["CSEXCL"] += message;
                        return(PartialView("_Create", svm));
                    }

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

                    return(Json(new { success = true }));
                }
                return(PartialView("_Create", svm));
            }
        }