public void CreateSaleOrderLine(int SaleEnquiryLineId, int SaleOrderHeaderId)
        {
            SaleEnquiryLine   Line          = new SaleEnquiryLineService(_unitOfWork).Find(SaleEnquiryLineId);
            SaleEnquiryHeader EnquiryHeader = new SaleEnquiryHeaderService(_unitOfWork).Find(Line.SaleEnquiryHeaderId);

            SaleOrderLine OrderLine = new SaleOrderLine();

            OrderLine.SaleOrderHeaderId = SaleOrderHeaderId;
            OrderLine.DueDate           = Line.DueDate;
            OrderLine.ProductId         = Line.ProductId ?? 0;
            OrderLine.Specification     = Line.Specification;
            OrderLine.Dimension1Id      = Line.Dimension1Id;
            OrderLine.Dimension2Id      = Line.Dimension2Id;
            OrderLine.Qty        = Line.Qty;
            OrderLine.DealQty    = Line.DealQty;
            OrderLine.DealUnitId = Line.DealUnitId;
            OrderLine.UnitConversionMultiplier = Line.UnitConversionMultiplier;
            OrderLine.Rate               = Line.Rate;
            OrderLine.Amount             = Line.Amount;
            OrderLine.Remark             = Line.Remark;
            OrderLine.ReferenceDocTypeId = EnquiryHeader.DocTypeId;
            OrderLine.ReferenceDocLineId = Line.SaleEnquiryLineId;
            OrderLine.CreatedDate        = DateTime.Now;
            OrderLine.ModifiedDate       = DateTime.Now;
            OrderLine.CreatedBy          = User.Identity.Name;
            OrderLine.ModifiedBy         = User.Identity.Name;
            new SaleOrderLineService(_unitOfWork).Create(OrderLine);

            new SaleOrderLineStatusService(_unitOfWork).CreateLineStatus(OrderLine.SaleOrderLineId);

            Line.LockReason = "Sale order is created for enquiry.Now you can't modify enquiry, changes can be done in sale order.";
            new SaleEnquiryLineService(_unitOfWork).Update(Line);

            var PersonProductUid = (from p in db.PersonProductUid
                                    where p.GenLineId == SaleEnquiryLineId && p.GenDocTypeId == EnquiryHeader.DocTypeId && p.GenDocId == EnquiryHeader.SaleEnquiryHeaderId
                                    select p).ToList();

            if (PersonProductUid.Count() != 0)
            {
                foreach (var item2 in PersonProductUid)
                {
                    PersonProductUid PPU = new PersonProductUidService(_unitOfWork).Find(item2.PersonProductUidId);
                    PPU.SaleOrderLineId = OrderLine.SaleOrderLineId;
                    PPU.ObjectState     = Model.ObjectState.Modified;
                    new PersonProductUidService(_unitOfWork).Create(PPU);
                }
            }
        }
Esempio n. 2
0
        private ActionResult _PersonProductUid(int id)
        {
            SaleEnquiryLine         SIL  = new SaleEnquiryLineService(_unitOfWork).Find(id);
            SaleEnquiryHeader       SIH  = new SaleEnquiryHeaderService(_unitOfWork).Find(SIL.SaleEnquiryHeaderId);
            SaleEnquiryLineExtended SILE = new SaleEnquiryLineExtendedService(_unitOfWork).Find(id);

            IQueryable <PersonProductUidViewModel> p = new PersonProductUidService(_unitOfWork).GetPersonProductUidList(SIH.DocTypeId, SIH.SaleEnquiryHeaderId, SIL.SaleEnquiryLineId);

            PersonProductUidSummaryViewModel vm = new PersonProductUidSummaryViewModel();

            vm.JobInvoiceSummaryViewModel = p.ToList();
            vm.GenDocLineId = SIL.SaleEnquiryLineId;

            ViewBag.DocNo = (SIH.BuyerEnquiryNo ?? SIH.DocNo).ToString() + "-" + SILE.BuyerSpecification + "-" + SILE.BuyerSpecification1 + "-" + SILE.BuyerSpecification2 + "-" + SILE.BuyerSpecification3;
            return(PartialView("_PersonProductUid", vm));
        }
Esempio n. 3
0
        public ActionResult _PersonProductUidPost(PersonProductUidSummaryViewModel svm)
        {
            SaleEnquiryLine   s    = new SaleEnquiryLineService(_unitOfWork).Find((int)svm.GenDocLineId);
            SaleEnquiryHeader temp = new SaleEnquiryHeaderService(_unitOfWork).Find(s.SaleEnquiryHeaderId);


            if (ModelState.IsValid)
            {
                //var PersonProductUid = (from p in db.PersonProductUid
                //                        where p.GenLineId == s.SaleEnquiryLineId && p.GenDocTypeId == temp.DocTypeId && p.GenDocId == temp.SaleEnquiryHeaderId
                //                        select p).ToList();

                //foreach (var item2 in PersonProductUid)
                //{
                //    new PersonProductUidService(_unitOfWork).Delete(item2.PersonProductUidId);

                //}

                if (svm.JobInvoiceSummaryViewModel[0].PersonProductUidId == 0)
                {
                    foreach (var item in svm.JobInvoiceSummaryViewModel)
                    {
                        PersonProductUid PPU = new PersonProductUid();
                        PPU.GenLineId               = s.SaleEnquiryLineId;
                        PPU.ProductUidName          = item.ProductUidName;
                        PPU.ProductUidSpecification = item.ProductUidSpecification;
                        PPU.GenDocId     = temp.SaleEnquiryHeaderId;
                        PPU.GenDocNo     = temp.BuyerEnquiryNo;
                        PPU.GenDocTypeId = temp.DocTypeId;
                        PPU.CreatedDate  = DateTime.Now;
                        PPU.ModifiedDate = DateTime.Now;
                        PPU.CreatedBy    = User.Identity.Name;
                        PPU.ModifiedBy   = User.Identity.Name;
                        PPU.ObjectState  = Model.ObjectState.Added;
                        new PersonProductUidService(_unitOfWork).Create(PPU);
                    }
                }
                else
                {
                    foreach (var item in svm.JobInvoiceSummaryViewModel)
                    {
                        PersonProductUid PPU = new PersonProductUidService(_unitOfWork).Find(item.PersonProductUidId);
                        PPU.ProductUidName          = item.ProductUidName;
                        PPU.ProductUidSpecification = item.ProductUidSpecification;
                        PPU.ModifiedDate            = DateTime.Now;
                        PPU.ModifiedBy  = User.Identity.Name;
                        PPU.ObjectState = Model.ObjectState.Modified;
                        new PersonProductUidService(_unitOfWork).Update(PPU);
                    }
                }



                try
                {
                    _unitOfWork.Save();
                }

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

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


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