public JsonResult GetProductCustomDetailJson(int ProductId, int SaleEnquiryHeaderId) { SaleEnquiryHeader Header = new SaleEnquiryHeaderService(_unitOfWork).Find(SaleEnquiryHeaderId); ProductCustomDetailViewModel ProductCustomDetail = (from P in db.ViewProductBuyer where P.ProductId == ProductId && P.BuyerId == Header.SaleToBuyerId select new ProductCustomDetailViewModel { BuyerSpecification = P.BuyerSpecification, BuyerSpecification1 = P.BuyerSpecification1, BuyerSpecification2 = P.BuyerSpecification2, BuyerSpecification3 = P.BuyerSpecification3 }).FirstOrDefault(); List <ProductCustomDetailViewModel> ProductCustomDetailJson = new List <ProductCustomDetailViewModel>(); ProductCustomDetailJson.Add(new ProductCustomDetailViewModel() { BuyerSpecification = ProductCustomDetail.BuyerSpecification, BuyerSpecification1 = ProductCustomDetail.BuyerSpecification1, BuyerSpecification2 = ProductCustomDetail.BuyerSpecification2, BuyerSpecification3 = ProductCustomDetail.BuyerSpecification3 }); return(Json(ProductCustomDetailJson)); }
public ActionResult _Create(int Id) //Id ==>Sale Order Header Id { SaleEnquiryHeader H = new SaleEnquiryHeaderService(_unitOfWork).GetSaleEnquiryHeader(Id); SaleEnquiryLineViewModel s = new SaleEnquiryLineViewModel(); s.SaleEnquiryHeaderId = H.SaleEnquiryHeaderId; s.UnitId = "PCS"; ViewBag.DocNo = H.DocNo; ViewBag.Status = H.Status; ViewBag.LineMode = "Create"; var settings = new SaleEnquirySettingsService(_unitOfWork).GetSaleEnquirySettingsForDucument(H.DocTypeId, H.DivisionId, H.SiteId); s.SaleEnquirySettings = Mapper.Map <SaleEnquirySettings, SaleEnquirySettingsViewModel>(settings); var count = _SaleEnquiryLineService.GetSaleEnquiryLineListForIndex(Id).Count(); if (count > 0) { s.DealUnitId = _SaleEnquiryLineService.GetSaleEnquiryLineListForIndex(Id).OrderByDescending(m => m.SaleEnquiryLineId).FirstOrDefault().DealUnitId; } else { s.DealUnitId = settings.DealUnitId; } ProductBuyerSettings ProductBuyerSettings = new ProductBuyerSettingsService(_unitOfWork).GetProductBuyerSettings(H.DivisionId, H.SiteId); s.ProductBuyerSettings = Mapper.Map <ProductBuyerSettings, ProductBuyerSettingsViewModel>(ProductBuyerSettings); var LastTransactionDetail = _SaleEnquiryLineService.GetLastTransactionDetail(Id); if (LastTransactionDetail != null) { if (LastTransactionDetail.BuyerSpecification != null && LastTransactionDetail.BuyerSpecification != "") { ViewBag.LastTransaction = LastTransactionDetail.BuyerSpecification; } if (LastTransactionDetail.BuyerSpecification1 != null && LastTransactionDetail.BuyerSpecification1 != "") { ViewBag.LastTransaction = ViewBag.LastTransaction + ", " + LastTransactionDetail.BuyerSpecification1; } if (LastTransactionDetail.BuyerSpecification2 != null && LastTransactionDetail.BuyerSpecification2 != "") { ViewBag.LastTransaction = ViewBag.LastTransaction + ", " + LastTransactionDetail.BuyerSpecification2; } if (LastTransactionDetail.BuyerSpecification3 != null && LastTransactionDetail.BuyerSpecification3 != "") { ViewBag.LastTransaction = ViewBag.LastTransaction + ", " + LastTransactionDetail.BuyerSpecification3; } } PrepareViewBag(H); return(PartialView("_Create", s)); }
public JsonResult GetUnitConversionDetailJson(int ProductId, string UnitId, string DeliveryUnitId, int HeaderId) { int UnitConversionForId = new SaleEnquiryHeaderService(_unitOfWork).Find(HeaderId).UnitConversionForId; UnitConversion uc = new UnitConversionService(_unitOfWork).GetUnitConversionForUCF(ProductId, UnitId, DeliveryUnitId, UnitConversionForId); List <SelectListItem> UnitConversionJson = new List <SelectListItem>(); if (uc != null) { UnitConversionJson.Add(new SelectListItem { Text = uc.Multiplier.ToString(), Value = uc.Multiplier.ToString() }); } else { UnitConversionJson.Add(new SelectListItem { Text = "0", Value = "0" }); } return(Json(UnitConversionJson)); }
private ActionResult _Modify(int id) { SaleEnquiryLine temp = _SaleEnquiryLineService.GetSaleEnquiryLine(id); SaleEnquiryLineExtended Extended = new SaleEnquiryLineExtendedService(_unitOfWork).Find(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 = "Edit"; } SaleEnquiryHeader H = new SaleEnquiryHeaderService(_unitOfWork).GetSaleEnquiryHeader(temp.SaleEnquiryHeaderId); ViewBag.DocNo = H.DocNo; SaleEnquiryLineViewModel s = Mapper.Map <SaleEnquiryLine, SaleEnquiryLineViewModel>(temp); s.BuyerSpecification = Extended.BuyerSpecification; s.BuyerSpecification1 = Extended.BuyerSpecification1; s.BuyerSpecification2 = Extended.BuyerSpecification2; s.BuyerSpecification3 = Extended.BuyerSpecification3; s.BuyerSku = Extended.BuyerSku; s.BuyerUpcCode = Extended.BuyerUpcCode; var settings = new SaleEnquirySettingsService(_unitOfWork).GetSaleEnquirySettingsForDucument(H.DocTypeId, H.DivisionId, H.SiteId); s.SaleEnquirySettings = Mapper.Map <SaleEnquirySettings, SaleEnquirySettingsViewModel>(settings); ProductBuyerSettings ProductBuyerSettings = new ProductBuyerSettingsService(_unitOfWork).GetProductBuyerSettings(H.DivisionId, H.SiteId); s.ProductBuyerSettings = Mapper.Map <ProductBuyerSettings, ProductBuyerSettingsViewModel>(ProductBuyerSettings); PrepareViewBag(H); return(PartialView("_Create", s)); }
// GET: /ProductMaster/Edit/5 public ActionResult Edit(int id) { SaleEnquiryLine temp = _SaleEnquiryLineService.GetSaleEnquiryLine(id); SaleEnquiryLineExtended Extended = new SaleEnquiryLineExtendedService(_unitOfWork).Find(id); if (temp == null) { return(HttpNotFound()); } SaleEnquiryHeader H = new SaleEnquiryHeaderService(_unitOfWork).GetSaleEnquiryHeader(temp.SaleEnquiryHeaderId); ViewBag.DocNo = H.DocNo; SaleEnquiryLineViewModel s = Mapper.Map <SaleEnquiryLine, SaleEnquiryLineViewModel>(temp); s.BuyerSpecification = Extended.BuyerSpecification; s.BuyerSpecification1 = Extended.BuyerSpecification1; s.BuyerSpecification2 = Extended.BuyerSpecification2; s.BuyerSpecification3 = Extended.BuyerSpecification3; s.BuyerSku = Extended.BuyerSku; s.BuyerUpcCode = Extended.BuyerUpcCode; s.SaleEnquiryDocNo = H.DocNo; s.SaleToBuyerId = H.SaleToBuyerId; s.SaleEnquiryHeaderId = H.SaleEnquiryHeaderId; var settings = new SaleEnquirySettingsService(_unitOfWork).GetSaleEnquirySettingsForDucument(H.DocTypeId, H.DivisionId, H.SiteId); s.SaleEnquirySettings = Mapper.Map <SaleEnquirySettings, SaleEnquirySettingsViewModel>(settings); ProductBuyerSettings ProductBuyerSettings = new ProductBuyerSettingsService(_unitOfWork).GetProductBuyerSettings(H.DivisionId, H.SiteId); s.ProductBuyerSettings = Mapper.Map <ProductBuyerSettings, ProductBuyerSettingsViewModel>(ProductBuyerSettings); if (temp.DealUnitId == "MT2") { string SizeinFeet = ""; using (SqlConnection sqlConnection = new SqlConnection((string)System.Web.HttpContext.Current.Session["DefaultConnectionString"])) { sqlConnection.Open(); SqlCommand Totalf = new SqlCommand("SELECT Web.FGetSizeinFeet('" + Extended.BuyerSpecification1 + "')", sqlConnection); SizeinFeet = Convert.ToString(Totalf.ExecuteScalar() == DBNull.Value ? "" : Totalf.ExecuteScalar()); } ViewBag.SizeinFeet = "Feet :" + SizeinFeet; } return(View("Create", s)); }
public IQueryable <ComboBoxResult> GetCustomProductsHelpList(int Id, string term) { var SaleEnquiry = new SaleEnquiryHeaderService(_unitOfWork).Find(Id); var settings = new SaleEnquirySettingsService(_unitOfWork).GetSaleEnquirySettingsForDucument(SaleEnquiry.DocTypeId, SaleEnquiry.DivisionId, SaleEnquiry.SiteId); string[] ProductTypes = null; if (!string.IsNullOrEmpty(settings.filterProductTypes)) { ProductTypes = settings.filterProductTypes.Split(",".ToCharArray()); } else { ProductTypes = new string[] { "NA" }; } string[] Products = null; if (!string.IsNullOrEmpty(settings.filterProducts)) { Products = settings.filterProducts.Split(",".ToCharArray()); } else { Products = new string[] { "NA" }; } string[] ProductGroups = null; if (!string.IsNullOrEmpty(settings.filterProductGroups)) { ProductGroups = settings.filterProductGroups.Split(",".ToCharArray()); } else { ProductGroups = new string[] { "NA" }; } return(from Pt in db.FinishedProduct join Vrs in db.ViewRugSize on Pt.ProductId equals Vrs.ProductId into ViewRugSizeTable from ViewRugSizeTab in ViewRugSizeTable.DefaultIfEmpty() where (string.IsNullOrEmpty(settings.filterProductTypes) ? 1 == 1 : ProductTypes.Contains(Pt.ProductGroup.ProductTypeId.ToString())) && (string.IsNullOrEmpty(settings.filterProducts) ? 1 == 1 : Products.Contains(Pt.ProductId.ToString())) && (string.IsNullOrEmpty(settings.filterProductGroups) ? 1 == 1 : ProductGroups.Contains(Pt.ProductGroupId.ToString())) && (string.IsNullOrEmpty(term) ? 1 == 1 : Pt.ProductName.ToLower().Contains(term.ToLower())) orderby Pt.ProductName select new ComboBoxResult { id = Pt.ProductId.ToString(), text = Pt.ProductName, AProp1 = "Design : " + Pt.ProductGroup.ProductGroupName, AProp2 = "Size : " + ViewRugSizeTab.StandardSizeName, TextProp1 = "Colour : " + Pt.Colour.ColourName, TextProp2 = "Quality : " + Pt.ProductQuality.ProductQualityName }); }
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); } } }
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)); }
private ActionResult _Detail(int id) { SaleEnquiryLine temp = _SaleEnquiryLineService.GetSaleEnquiryLine(id); if (temp == null) { return(HttpNotFound()); } SaleEnquiryHeader H = new SaleEnquiryHeaderService(_unitOfWork).GetSaleEnquiryHeader(temp.SaleEnquiryHeaderId); ViewBag.DocNo = H.DocNo; SaleEnquiryLineViewModel s = Mapper.Map <SaleEnquiryLine, SaleEnquiryLineViewModel>(temp); PrepareViewBag(H); return(PartialView("_Create", s)); }
public ActionResult GetCustomPerson(string searchTerm, int pageSize, int pageNum, int filter)//DocId { var SaleEnquiry = new SaleEnquiryHeaderService(_unitOfWork).Find(filter); var Query = new SaleEnquiryHeaderService(_unitOfWork).GetCustomPerson(SaleEnquiry.DocTypeId, searchTerm); var temp = Query.Skip(pageSize * (pageNum - 1)) .Take(pageSize) .ToList(); var count = Query.Count(); ComboBoxPagedResult Data = new ComboBoxPagedResult(); Data.Results = temp; Data.Total = count; return(new JsonpResult { Data = Data, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public void CreateSaleOrder(int SaleEnquiryHeaderId) { SaleEnquiryHeader EnquiryHeader = new SaleEnquiryHeaderService(_unitOfWork).Find(SaleEnquiryHeaderId); SaleEnquirySettings Settings = new SaleEnquirySettingsService(_unitOfWork).GetSaleEnquirySettingsForDucument(EnquiryHeader.DocTypeId, EnquiryHeader.DivisionId, EnquiryHeader.SiteId); SaleOrderHeader OrderHeader = new SaleOrderHeader(); OrderHeader.DocTypeId = (int)Settings.SaleOrderDocTypeId; OrderHeader.DocDate = EnquiryHeader.DocDate; OrderHeader.DocNo = EnquiryHeader.DocNo; OrderHeader.DivisionId = EnquiryHeader.DivisionId; OrderHeader.SiteId = EnquiryHeader.SiteId; OrderHeader.BuyerOrderNo = EnquiryHeader.BuyerEnquiryNo; OrderHeader.SaleToBuyerId = EnquiryHeader.SaleToBuyerId; OrderHeader.BillToBuyerId = EnquiryHeader.BillToBuyerId; OrderHeader.CurrencyId = EnquiryHeader.CurrencyId; OrderHeader.Priority = EnquiryHeader.Priority; OrderHeader.UnitConversionForId = EnquiryHeader.UnitConversionForId; OrderHeader.ShipMethodId = EnquiryHeader.ShipMethodId; OrderHeader.ShipAddress = EnquiryHeader.ShipAddress; OrderHeader.DeliveryTermsId = EnquiryHeader.DeliveryTermsId; OrderHeader.Remark = EnquiryHeader.Remark; OrderHeader.DueDate = EnquiryHeader.DueDate; OrderHeader.ActualDueDate = EnquiryHeader.ActualDueDate; OrderHeader.Advance = EnquiryHeader.Advance; OrderHeader.ReferenceDocId = EnquiryHeader.SaleEnquiryHeaderId; OrderHeader.ReferenceDocTypeId = EnquiryHeader.DocTypeId; OrderHeader.CreatedDate = DateTime.Now; OrderHeader.ModifiedDate = DateTime.Now; OrderHeader.ModifiedDate = DateTime.Now; OrderHeader.ModifiedBy = User.Identity.Name; OrderHeader.Status = (int)StatusConstants.Submitted; OrderHeader.ReviewBy = User.Identity.Name; OrderHeader.ReviewCount = 1; //OrderHeader.LockReason = "Sale order is created for enquiry.Now you can't modify enquiry, changes can be done in sale order."; new SaleOrderHeaderService(_unitOfWork).Create(OrderHeader); IEnumerable <SaleEnquiryLine> LineList = new SaleEnquiryLineService(_unitOfWork).GetSaleEnquiryLineListForHeader(SaleEnquiryHeaderId).Where(m => m.ProductId != null); int i = 0; foreach (SaleEnquiryLine Line in LineList) { SaleOrderLine OrderLine = new SaleOrderLine(); OrderLine.SaleOrderLineId = i; i = i - 1; 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); } }
public void Post(int SaleEnquiryLineId, string ProductName) { SaleEnquiryLine Line = new SaleEnquiryLineService(_unitOfWork).Find(SaleEnquiryLineId); SaleEnquiryLineExtended LineExtended = new SaleEnquiryLineExtendedService(_unitOfWork).Find(SaleEnquiryLineId); Product Product = new ProductService(_unitOfWork).Find(ProductName); if (Product != null) { Line.ProductId = Product.ProductId; Line.ModifiedDate = DateTime.Now; Line.ModifiedBy = User.Identity.Name; Line.ObjectState = Model.ObjectState.Modified; new SaleEnquiryLineService(_unitOfWork).Update(Line); SaleEnquiryHeader Header = new SaleEnquiryHeaderService(_unitOfWork).Find(Line.SaleEnquiryHeaderId); ProductBuyer PB = new ProductBuyerService(_unitOfWork).Find((int)Header.SaleToBuyerId, Product.ProductId); if (PB == null) { string BuyerSku = LineExtended.BuyerSpecification.Replace("-", "") + "-" + LineExtended.BuyerSpecification1 + "-" + LineExtended.BuyerSpecification2; ProductBuyer ProdBuyer = new ProductBuyer(); ProdBuyer.BuyerId = (int)Header.SaleToBuyerId; ProdBuyer.ProductId = Product.ProductId; ProdBuyer.BuyerSku = LineExtended.BuyerSku == null ? BuyerSku : LineExtended.BuyerSku; ProdBuyer.BuyerUpcCode = LineExtended.BuyerUpcCode; ProdBuyer.BuyerSpecification = LineExtended.BuyerSpecification; ProdBuyer.BuyerSpecification1 = LineExtended.BuyerSpecification1; ProdBuyer.BuyerSpecification2 = LineExtended.BuyerSpecification2; ProdBuyer.BuyerSpecification3 = LineExtended.BuyerSpecification3; ProdBuyer.CreatedDate = DateTime.Now; ProdBuyer.CreatedBy = User.Identity.Name; ProdBuyer.ModifiedDate = DateTime.Now; ProdBuyer.ModifiedBy = User.Identity.Name; ProdBuyer.ObjectState = Model.ObjectState.Added; new ProductBuyerService(_unitOfWork).Create(ProdBuyer); } SaleOrderHeader SaleOrderHeader = new SaleOrderHeaderService(_unitOfWork).Find_ByReferenceDocId(Header.DocTypeId, Header.SaleEnquiryHeaderId); if (SaleOrderHeader == null) { CreateSaleOrder(Header.SaleEnquiryHeaderId); } else { CreateSaleOrderLine(Line.SaleEnquiryLineId, SaleOrderHeader.SaleOrderHeaderId); } try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); } } }
public ActionResult Post(SaleEnquiryLineViewModel vm) { if (ModelState.IsValid) { List <LogTypeViewModel> LogList = new List <LogTypeViewModel>(); SaleEnquiryLine temp = new SaleEnquiryLineService(_unitOfWork).Find(vm.SaleEnquiryLineId); SaleEnquiryLine ExRec = Mapper.Map <SaleEnquiryLine>(temp); temp.ProductId = vm.ProductId; temp.ModifiedDate = DateTime.Now; temp.ModifiedBy = User.Identity.Name; temp.ObjectState = Model.ObjectState.Modified; new SaleEnquiryLineService(_unitOfWork).Update(temp); ProductBuyer PB = new ProductBuyerService(_unitOfWork).Find((int)vm.SaleToBuyerId, (int)vm.ProductId); if (PB == null) { string BuyerSku = vm.BuyerSpecification.Replace("-", "") + "-" + vm.BuyerSpecification1 + "-" + vm.BuyerSpecification2; ProductBuyer ProdBuyer = new ProductBuyer(); ProdBuyer.BuyerId = (int)vm.SaleToBuyerId; ProdBuyer.ProductId = (int)vm.ProductId; ProdBuyer.BuyerSku = vm.BuyerSku == null ? BuyerSku : vm.BuyerSku; ProdBuyer.BuyerUpcCode = vm.BuyerUpcCode; ProdBuyer.BuyerSpecification = vm.BuyerSpecification; ProdBuyer.BuyerSpecification1 = vm.BuyerSpecification1; ProdBuyer.BuyerSpecification2 = vm.BuyerSpecification2; ProdBuyer.BuyerSpecification3 = vm.BuyerSpecification3; ProdBuyer.CreatedDate = DateTime.Now; ProdBuyer.CreatedBy = User.Identity.Name; ProdBuyer.ModifiedDate = DateTime.Now; ProdBuyer.ModifiedBy = User.Identity.Name; ProdBuyer.ObjectState = Model.ObjectState.Added; new ProductBuyerService(_unitOfWork).Create(ProdBuyer); } SaleEnquiryHeader SaleEnquiryHeader = new SaleEnquiryHeaderService(_unitOfWork).Find(temp.SaleEnquiryHeaderId); SaleOrderHeader SaleOrderHeader = new SaleOrderHeaderService(_unitOfWork).Find_ByReferenceDocId(SaleEnquiryHeader.DocTypeId, SaleEnquiryHeader.SaleEnquiryHeaderId); if (SaleOrderHeader == null) { CreateSaleOrder(temp.SaleEnquiryHeaderId); } else { CreateSaleOrderLine(temp.SaleEnquiryLineId, SaleOrderHeader.SaleOrderHeaderId); } 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); ModelState.AddModelError("", message); return(View("Create", vm)); } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = new DocumentTypeService(_unitOfWork).FindByName(TransactionDoctypeConstants.SaleEnquiryProductMapping).DocumentTypeId, DocId = temp.SaleEnquiryLineId, ActivityType = (int)ActivityTypeContants.Modified, xEModifications = Modifications, })); //return RedirectToAction("Index").Success("Data saved successfully"); //var SaleEnquiryProductMapping = _SaleEnquiryLineService.GetSaleEnquiryLineListForIndex().OrderBy(m => m.SaleEnquiryLineId).OrderBy(m => m.SaleEnquiryLineId).FirstOrDefault(); //if (SaleEnquiryProductMapping != null) //{ // return RedirectToAction("Edit", new { id = SaleEnquiryProductMapping.SaleEnquiryLineId }).Success("Data saved successfully"); //} //else //{ // return RedirectToAction("Index").Success("Data saved successfully"); //} int SaleEnquiryId = _SaleEnquiryLineService.NextId(vm.SaleEnquiryLineId); if (SaleEnquiryId > 0) { return(RedirectToAction("Edit", new { id = SaleEnquiryId }).Success("Data saved successfully")); } else { return(RedirectToAction("Index").Success("Data saved successfully")); } } return(View("Create", vm)); }
public ActionResult _CreatePost(SaleEnquiryLineViewModel svm) { SaleEnquiryLine s = Mapper.Map <SaleEnquiryLineViewModel, SaleEnquiryLine>(svm); SaleEnquiryHeader temp = new SaleEnquiryHeaderService(_unitOfWork).Find(s.SaleEnquiryHeaderId); //if (Command == "Submit" && (s.ProductId == 0)) // return RedirectToAction("Submit", "SaleEnquiryHeader", new { id = s.SaleEnquiryHeaderId }).Success("Data saved successfully"); if (svm.BuyerSpecification != null || svm.BuyerSpecification1 != null || svm.BuyerSpecification2 != null || svm.BuyerSpecification3 != null) { SaleEnquiryLine es = new SaleEnquiryLineService(_unitOfWork).Find_WithLineDetail(svm.SaleEnquiryHeaderId, svm.BuyerSpecification, svm.BuyerSpecification1, svm.BuyerSpecification2, svm.BuyerSpecification3); if (es != null) { if (es != null && es.SaleEnquiryLineId != svm.SaleEnquiryLineId) { ModelState.AddModelError("ProductId", "This Detail is already Added !"); } } } if (svm.Qty <= 0) { //ModelState.AddModelError("Qty", "Please Check Qty"); ViewBag.LineMode = "Create"; string message = "Please Check Qty"; TempData["CSEXCL"] += message; PrepareViewBag(temp); return(PartialView("_Create", svm)); } if (svm.DueDate < temp.DocDate) { ModelState.AddModelError("DueDate", "DueDate greater than DocDate"); } if (svm.SaleEnquiryLineId <= 0) { ViewBag.LineMode = "Create"; } else { ViewBag.LineMode = "Edit"; } if (ModelState.IsValid) { if (svm.SaleEnquiryLineId <= 0) { if (svm.BuyerSpecification != null || svm.BuyerSpecification1 != null || svm.BuyerSpecification2 != null || svm.BuyerSpecification3 != null) { ProductBuyer BP = new ProductBuyerService(_unitOfWork).Find(temp.SaleToBuyerId, svm.BuyerSpecification, svm.BuyerSpecification1, svm.BuyerSpecification2, svm.BuyerSpecification3); if (BP != null) { s.ProductId = BP.ProductId; } } s.CreatedDate = DateTime.Now; s.ModifiedDate = DateTime.Now; s.CreatedBy = User.Identity.Name; s.ModifiedBy = User.Identity.Name; s.ObjectState = Model.ObjectState.Added; _SaleEnquiryLineService.Create(s); SaleEnquiryLineExtended Extended = new SaleEnquiryLineExtended(); Extended.SaleEnquiryLineId = s.SaleEnquiryLineId; Extended.BuyerSpecification = svm.BuyerSpecification; Extended.BuyerSpecification1 = svm.BuyerSpecification1; Extended.BuyerSpecification2 = svm.BuyerSpecification2; Extended.BuyerSpecification3 = svm.BuyerSpecification3; Extended.BuyerSku = svm.BuyerSku; Extended.BuyerUpcCode = svm.BuyerUpcCode; new SaleEnquiryLineExtendedService(_unitOfWork).Create(Extended); //new SaleEnquiryLineStatusService(_unitOfWork).CreateLineStatus(s.SaleEnquiryLineId); SaleEnquiryHeader header = new SaleEnquiryHeaderService(_unitOfWork).Find(s.SaleEnquiryHeaderId); if (header.Status != (int)StatusConstants.Drafted && header.Status != (int)StatusConstants.Import) { header.Status = (int)StatusConstants.Modified; header.ModifiedDate = DateTime.Now; header.ModifiedBy = User.Identity.Name; new SaleEnquiryHeaderService(_unitOfWork).Update(header); } 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(RedirectToAction("_Create", new { id = s.SaleEnquiryHeaderId })); } else { List <LogTypeViewModel> LogList = new List <LogTypeViewModel>(); SaleEnquiryHeader header = new SaleEnquiryHeaderService(_unitOfWork).Find(svm.SaleEnquiryHeaderId); StringBuilder logstring = new StringBuilder(); int status = header.Status; SaleEnquiryLine temp1 = _SaleEnquiryLineService.Find(svm.SaleEnquiryLineId); SaleEnquiryLine ExRec = new SaleEnquiryLine(); ExRec = Mapper.Map <SaleEnquiryLine>(temp1); //End of Tracking the Modifications:: temp1.DueDate = svm.DueDate; temp1.ProductId = svm.ProductId; temp1.Specification = svm.Specification; temp1.Dimension1Id = svm.Dimension1Id; temp1.Dimension2Id = svm.Dimension2Id; temp1.Dimension3Id = svm.Dimension3Id; temp1.Dimension4Id = svm.Dimension4Id; temp1.Qty = svm.Qty; temp1.UnitId = svm.UnitId; temp1.DealQty = svm.DealQty ?? 0; temp1.DealUnitId = svm.DealUnitId; temp1.UnitConversionMultiplier = svm.UnitConversionMultiplier; temp1.Rate = svm.Rate ?? 0; temp1.Amount = svm.Amount ?? 0; temp1.Remark = svm.Remark; temp1.ModifiedDate = DateTime.Now; temp1.ModifiedBy = User.Identity.Name; _SaleEnquiryLineService.Update(temp1); SaleEnquiryLineExtended Extended = new SaleEnquiryLineExtendedService(_unitOfWork).Find(svm.SaleEnquiryLineId); Extended.BuyerSpecification = svm.BuyerSpecification; Extended.BuyerSpecification1 = svm.BuyerSpecification1; Extended.BuyerSpecification2 = svm.BuyerSpecification2; Extended.BuyerSpecification3 = svm.BuyerSpecification3; new SaleEnquiryLineExtendedService(_unitOfWork).Update(Extended); LogList.Add(new LogTypeViewModel { ExObj = ExRec, Obj = temp1, }); 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 SaleEnquiryHeaderService(_unitOfWork).Update(header); } XElement Modifications = new ModificationsCheckService().CheckChanges(LogList); try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXCL"] += message; PrepareViewBag(temp); return(PartialView("_Create", svm)); } //Saving the Activity Log LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = temp.DocTypeId, DocId = temp1.SaleEnquiryHeaderId, DocLineId = temp1.SaleEnquiryLineId, ActivityType = (int)ActivityTypeContants.Modified, DocNo = temp.DocNo, xEModifications = Modifications, DocDate = temp.DocDate, DocStatus = temp.Status, })); //End of Saving the Activity Log return(Json(new { success = true })); } } //string messages = string.Join("; ", ModelState.Values // .SelectMany(x => x.Errors) // .Select(x => x.ErrorMessage)); //TempData["CSEXCL"] += messages; ViewBag.Status = temp.Status; PrepareViewBag(temp); return(PartialView("_Create", svm)); }
public ActionResult DeletePost(SaleEnquiryLineViewModel vm) { List <LogTypeViewModel> LogList = new List <LogTypeViewModel>(); new SaleEnquiryLineExtendedService(_unitOfWork).Delete(vm.SaleEnquiryLineId); SaleEnquiryLine SaleEnquiryLine = _SaleEnquiryLineService.Find(vm.SaleEnquiryLineId); //new SaleEnquiryLineStatusService(_unitOfWork).Delete(vm.SaleEnquiryLineId); SaleEnquiryHeader header = new SaleEnquiryHeaderService(_unitOfWork).Find(SaleEnquiryLine.SaleEnquiryHeaderId); var PersonProductUid = (from p in db.PersonProductUid where p.GenLineId == SaleEnquiryLine.SaleEnquiryLineId && p.GenDocTypeId == header.DocTypeId && p.GenDocId == header.SaleEnquiryHeaderId select p).ToList(); foreach (var item2 in PersonProductUid) { new PersonProductUidService(_unitOfWork).Delete(item2.PersonProductUidId); } _SaleEnquiryLineService.Delete(vm.SaleEnquiryLineId); 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 SaleEnquiryHeaderService(_unitOfWork).Update(header); } LogList.Add(new LogTypeViewModel { Obj = SaleEnquiryLine, }); 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.SaleEnquiryHeaderId, DocLineId = SaleEnquiryLine.SaleEnquiryLineId, ActivityType = (int)ActivityTypeContants.Deleted, DocNo = header.DocNo, xEModifications = Modifications, DocDate = header.DocDate, DocStatus = header.Status, })); return(Json(new { success = true })); }
public ActionResult Delete(ReasonViewModel vm) { if (ModelState.IsValid) { List <LogTypeViewModel> LogList = new List <LogTypeViewModel>(); //string temp = (Request["Redirect"].ToString()); //first find the Purchase Order Object based on the ID. (sience this object need to marked to be deleted IE. ObjectState.Deleted) var SaleOrderHeader = _SaleOrderHeaderService.GetSaleOrderHeader(vm.id); //For Updating Enquiry Header and Lines so that it can be edited and deleted as needed. if (SaleOrderHeader.ReferenceDocId != null && SaleOrderHeader.ReferenceDocId != 0) { var SaleEnquiryHeader = (from H in context.SaleEnquiryHeader where H.SaleEnquiryHeaderId == SaleOrderHeader.ReferenceDocId && H.DocTypeId == SaleOrderHeader.ReferenceDocTypeId select H).FirstOrDefault(); if (SaleEnquiryHeader != null) { SaleEnquiryHeader Header = new SaleEnquiryHeaderService(_unitOfWork).Find(SaleEnquiryHeader.SaleEnquiryHeaderId); Header.LockReason = null; new SaleEnquiryHeaderService(_unitOfWork).Update(Header); IEnumerable <SaleEnquiryLine> LineList = new SaleEnquiryLineService(_unitOfWork).GetSaleEnquiryLineListForHeader(SaleEnquiryHeader.SaleEnquiryHeaderId); foreach (SaleEnquiryLine Line in LineList) { Line.LockReason = null; new SaleEnquiryLineService(_unitOfWork).Update(Line); } } } LogList.Add(new LogTypeViewModel { ExObj = SaleOrderHeader, }); //Then find all the Purchase Order Header Line associated with the above ProductType. var SaleOrderLine = new SaleOrderLineService(_unitOfWork).GetSaleOrderLineList(vm.id); List <int> StockIdList = new List <int>(); //Mark ObjectState.Delete to all the Purchase Order Lines. foreach (var item in SaleOrderLine) { if (item.StockId != null) { StockIdList.Add((int)item.StockId); } LogList.Add(new LogTypeViewModel { ExObj = item, }); new SaleOrderLineStatusService(_unitOfWork).Delete(item.SaleOrderLineId); new SaleOrderLineService(_unitOfWork).Delete(item.SaleOrderLineId); } foreach (var item in StockIdList) { if (item != null) { new StockService(_unitOfWork).DeleteStock((int)item); } } int?StockHeaderId = null; StockHeaderId = SaleOrderHeader.StockHeaderId; int LedgerHeaderId = SaleOrderHeader.LedgerHeaderId ?? 0; // Now delete the Sale Order Header new SaleOrderHeaderService(_unitOfWork).Delete(vm.id); // Now delete the Ledger & Ledger Header if (LedgerHeaderId != 0) { var LedgerList = new LedgerService(_unitOfWork).FindForLedgerHeader(LedgerHeaderId).ToList(); foreach (var item in LedgerList) { new LedgerService(_unitOfWork).Delete(item.LedgerId); } new LedgerHeaderService(_unitOfWork).Delete(LedgerHeaderId); } if (StockHeaderId != null) { new StockHeaderService(_unitOfWork).Delete((int)StockHeaderId); } XElement Modifications = new ModificationsCheckService().CheckChanges(LogList); //Commit the DB try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; return(PartialView("_Reason", vm)); } //Logging Activity LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = SaleOrderHeader.DocTypeId, DocId = SaleOrderHeader.SaleOrderHeaderId, ActivityType = (int)ActivityTypeContants.Deleted, UserRemark = vm.Reason, DocNo = SaleOrderHeader.DocNo, xEModifications = Modifications, DocDate = SaleOrderHeader.DocDate, DocStatus = SaleOrderHeader.Status, })); return(Json(new { success = true })); } return(PartialView("_Reason", vm)); }
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)); }