Ejemplo n.º 1
0
        public ActionResult _ResultsPost(SaleDeliveryMasterDetailModel vm)
        {
            if (ModelState.IsValid)
            {
                SaleDeliveryOrderHeader Header = new SaleDeliveryOrderHeaderService(_unitOfWork).Find(vm.SaleDeliveryOrderLineViewModel.FirstOrDefault().SaleDeliveryOrderHeaderId);

                foreach (var item in vm.SaleDeliveryOrderLineViewModel)
                {
                    decimal balqty = (from p in db.ViewSaleOrderBalanceForCancellation
                                      where p.SaleOrderLineId == item.SaleOrderLineId
                                      select p.BalanceQty).FirstOrDefault();

                    if (item.Qty > 0 && item.Qty <= balqty)
                    {
                        SaleDeliveryOrderLine line = new SaleDeliveryOrderLine();

                        line.SaleDeliveryOrderHeaderId = item.SaleDeliveryOrderHeaderId;
                        line.SaleOrderLineId           = item.SaleOrderLineId;
                        line.Qty          = item.Qty;
                        line.CreatedDate  = DateTime.Now;
                        line.ModifiedDate = DateTime.Now;
                        line.CreatedBy    = User.Identity.Name;
                        line.ModifiedBy   = User.Identity.Name;
                        line.Remark       = item.Remark;
                        _SaleDeliveryOrderLineService.Create(line);
                    }
                }

                if (Header.Status != (int)StatusConstants.Drafted && Header.Status != (int)StatusConstants.Import)
                {
                    Header.Status      = (int)StatusConstants.Modified;
                    Header.ObjectState = Model.ObjectState.Modified;
                    new SaleDeliveryOrderHeaderService(_unitOfWork).Update(Header);
                }

                try
                {
                    _unitOfWork.Save();
                }
                catch (Exception ex)
                {
                    string message = _exception.HandleException(ex);
                    ModelState.AddModelError("", message);
                    return(PartialView("_Results", vm));
                }

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

                return(Json(new { success = true }));
            }
            return(PartialView("_Results", vm));
        }
Ejemplo n.º 2
0
        public ActionResult _FilterPost(SaleDeliveryOrderFilterViewModel vm)
        {
            List <SaleDeliveryOrderLineViewModel> temp = _SaleDeliveryOrderLineService.GetSaleOrderLineForMultiSelect(vm).ToList();
            SaleDeliveryMasterDetailModel         svm  = new SaleDeliveryMasterDetailModel();

            svm.SaleDeliveryOrderLineViewModel = temp;
            return(PartialView("_Results", svm));
        }