Esempio n. 1
0
        public IQueryable <ComboBoxResult> GetBuyerSpecification3(string term, int filter)
        {
            var list = (from Le in db.SaleEnquiryLineExtended
                        join L in db.SaleEnquiryLine on Le.SaleEnquiryLineId equals L.SaleEnquiryLineId into SaleEnquiryLineTable
                        from SaleEnquiryLineTab in SaleEnquiryLineTable.DefaultIfEmpty()
                        join H in db.SaleEnquiryHeader on SaleEnquiryLineTab.SaleEnquiryHeaderId equals H.SaleEnquiryHeaderId into SaleEnquiryHeaderTable
                        from SaleEnquiryHeaderTab in SaleEnquiryHeaderTable.DefaultIfEmpty()
                        where SaleEnquiryHeaderTab.SaleToBuyerId == filter && Le.BuyerSpecification3 != null &&
                        (string.IsNullOrEmpty(term) ? 1 == 1 : Le.BuyerSpecification3.ToLower().Contains(term.ToLower()))
                        group new { Le } by new { Le.BuyerSpecification3 } into Result
                        orderby Result.Key.BuyerSpecification3
                        select new ComboBoxResult
            {
                id = Result.Key.BuyerSpecification3,
                text = Result.Key.BuyerSpecification3
            });

            return(list);
        }
        public ActionResult DeletePost(SaleOrderLineViewModel vm)
        {
            List <LogTypeViewModel> LogList = new List <LogTypeViewModel>();

            SaleOrderLine SaleOrderLine = _SaleOrderLineService.Find(vm.SaleOrderLineId);

            int?StockId = 0;

            StockId = SaleOrderLine.StockId;

            if (StockId != null)
            {
                new StockService(_unitOfWork).DeleteStock((int)StockId);
            }

            if (SaleOrderLine.ReferenceDocLineId != null && SaleOrderLine.ReferenceDocLineId != 0 && SaleOrderLine.ReferenceDocTypeId != null && SaleOrderLine.ReferenceDocTypeId != 0)
            {
                var temp = (from L in db.SaleEnquiryLine
                            join H in db.SaleEnquiryHeader on L.SaleEnquiryHeaderId equals H.SaleEnquiryHeaderId into SaleEnquiryHeaderTable
                            from SaleEnquiryHeaderTab in SaleEnquiryHeaderTable.DefaultIfEmpty()
                            where SaleEnquiryHeaderTab.DocTypeId == SaleOrderLine.ReferenceDocTypeId && L.SaleEnquiryLineId == SaleOrderLine.ReferenceDocLineId
                            select L).FirstOrDefault();
                if (temp != null)
                {
                    SaleEnquiryLine SaleEnquiryLine = new SaleEnquiryLineService(_unitOfWork).Find(temp.SaleEnquiryLineId);
                    SaleEnquiryLine.LockReason = null;
                    new SaleEnquiryLineService(_unitOfWork).Update(SaleEnquiryLine);
                }
            }

            new SaleOrderLineStatusService(_unitOfWork).Delete(vm.SaleOrderLineId);



            _SaleOrderLineService.Delete(vm.SaleOrderLineId);
            SaleOrderHeader header = new SaleOrderHeaderService(_unitOfWork).Find(SaleOrderLine.SaleOrderHeaderId);

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



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

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

            try
            {
                _unitOfWork.Save();
            }
            catch (Exception ex)
            {
                string message = _exception.HandleException(ex);
                TempData["CSEXCL"]      += message;
                ViewBag.Docno            = header.DocNo;
                ViewBag.DeliveryUnitList = new UnitService(_unitOfWork).GetUnitList().ToList();
                return(PartialView("_Create", vm));
            }

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

            return(Json(new { success = true }));
        }