private void btnTakeaway_Click(object sender, EventArgs e) { SaleOrderHeader header = new SaleOrderHeader(); BaseButton btn = sender as BaseButton; if (btn.DataObject != null) { header = btn.DataObject as SaleOrderHeader; } base.OpernNewScreen <OpenOrder>(header); this.ReLoadScreen(); }
public ActionResult ModifyAfter_Submit(int id, string IndexType) { SaleOrderHeader header = _SaleOrderHeaderService.Find(id); if (header.Status == (int)StatusConstants.Submitted || header.Status == (int)StatusConstants.Modified || header.Status == (int)StatusConstants.ModificationSubmitted) { return(Edit(id, IndexType)); } else { return(HttpNotFound()); } }
public ActionResult Delete(int id) { SaleOrderHeader header = _SaleOrderHeaderService.Find(id); if (header.Status == (int)StatusConstants.Drafted || header.Status == (int)StatusConstants.Import) { return(Remove(id)); } else { return(HttpNotFound()); } }
public ActionResult DeleteAfter_Submit(int id) { SaleOrderHeader header = _SaleOrderHeaderService.Find(id); if (header.Status == (int)StatusConstants.Submitted || header.Status == (int)StatusConstants.Modified) { return(Remove(id)); } else { return(HttpNotFound()); } }
public ActionResult Modify(int id, string IndexType) { SaleOrderHeader header = _SaleOrderHeaderService.Find(id); if (header.Status == (int)StatusConstants.Drafted || header.Status == (int)StatusConstants.Import) { return(Edit(id, IndexType)); } else { return(HttpNotFound()); } }
private void btnPay_Click(object sender, EventArgs e) { SaleOrderHeader orderHear = new SaleOrderHeader(); orderHear.sales_order_head_id = this.OrderHeads.sales_order_head_id; orderHear = ServiceProvider.SaleOrderHeaderService.FindByKeys(orderHear, true); if (orderHear != null) { orderHear.is_payment_procress = true; ServiceProvider.SOTableService.CancelBookTable(this.OrderHeads.TableCode); ServiceProvider.SaleOrderHeaderService.Update(orderHear, ValidationRuleset.Update); } this.CloseScreen(); }
protected void POSScreen_TableClickEvent(string tableCode) { SOTable selectTable = ServiceProvider.SOTableService.GetTaleByCode(tableCode); if (selectTable != null && selectTable.active) { ServiceProvider.SOTableService.BookTable(tableCode); base.OpernNewScreen <OpenOrder>(tableCode); SaleOrderHeader orderHead = ServiceProvider.SaleOrderHeaderService.GetOrdrtHeadByTable(tableCode); if (orderHead == null) { ServiceProvider.SOTableService.CancelBookTable(tableCode); } } this.ReLoadScreen(); }
private void OpenOrder_Shown(object sender, EventArgs e) { string tableCode = string.Empty; if (this.popupDataSource.GetType() == typeof(string)) { tableCode = this.popupDataSource.ToString(); if (!string.IsNullOrEmpty(tableCode)) { this.OrderHeads = ServiceProvider.SaleOrderHeaderService.GetOrderByTable(tableCode); } } else if (this.popupDataSource.GetType() == typeof(SaleOrderHeader)) { SaleOrderHeader takeAwayOrder = this.popupDataSource as SaleOrderHeader; this.OrderHeads = ServiceProvider.SaleOrderHeaderService.GetOrderOrderHeader(takeAwayOrder); } //Update Oder information this.CheckStartEatingTime(); this.OrderHeads.TableCode = tableCode; labPersonCount.Text = this.OrderHeads.Person.ToString(); this.BindListOrder(); this.UpdateOrderHeadToScreen(); //Auto Click Button menu foreach (System.Windows.Forms.Control item in fPnlDiningType.Controls) { if (item.GetType() == typeof(BaseButton)) { BaseButton btn = item as BaseButton; btn.PerformClick(); break; } } foreach (System.Windows.Forms.Control item in fPnlMainMenu.Controls) { if (item.GetType() == typeof(BaseButton)) { BaseButton btn = item as BaseButton; btn.PerformClick(); break; } } }
// GET: /PurchaseOrderHeader/Delete/5 private ActionResult Remove(int id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SaleOrderHeader SaleOrderHeader = _SaleOrderHeaderService.GetSaleOrderHeader(id); if (SaleOrderHeader == null) { return(HttpNotFound()); } if (new RolePermissionService(_unitOfWork).IsActionAllowed(UserRoles, SaleOrderHeader.DocTypeId, null, this.ControllerContext.RouteData.Values["controller"].ToString(), "Remove") == false) { return(PartialView("~/Views/Shared/PermissionDenied_Modal.cshtml").Warning("You don't have permission to do this task.")); } #region DocTypeTimeLineValidation try { TimePlanValidation = DocumentValidation.ValidateDocument(Mapper.Map <DocumentUniqueId>(SaleOrderHeader), DocumentTimePlanTypeConstants.Delete, User.Identity.Name, out ExceptionMsg, out Continue); TempData["CSEXC"] += ExceptionMsg; } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; TimePlanValidation = false; } if (!TimePlanValidation && !Continue) { return(PartialView("AjaxError")); } #endregion ReasonViewModel rvm = new ReasonViewModel() { id = id, }; return(PartialView("_Reason", rvm)); }
public ActionResult Submit(int id, string IndexType, string TransactionType) { SaleOrderHeader s = context.SaleOrderHeader.Find(id); if (new RolePermissionService(_unitOfWork).IsActionAllowed(UserRoles, s.DocTypeId, null, this.ControllerContext.RouteData.Values["controller"].ToString(), "Submit") == false) { return(View("~/Views/Shared/PermissionDenied.cshtml").Warning("You don't have permission to do this task.")); } #region DocTypeTimeLineValidation try { TimePlanValidation = Submitvalidation(id, out ExceptionMsg); TempData["CSEXC"] += ExceptionMsg; } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; TimePlanValidation = false; } try { TimePlanValidation = DocumentValidation.ValidateDocument(Mapper.Map <DocumentUniqueId>(s), DocumentTimePlanTypeConstants.Submit, User.Identity.Name, out ExceptionMsg, out Continue); TempData["CSEXC"] += ExceptionMsg; } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; TimePlanValidation = false; } if (!TimePlanValidation && !Continue) { return(RedirectToAction("Index", new { id = s.DocTypeId, IndexType = IndexType })); } #endregion return(RedirectToAction("Detail", new { id = id, IndexType = IndexType, transactionType = string.IsNullOrEmpty(TransactionType) ? "submit" : TransactionType })); }
public async Task SendUserRegistrationInvitation(string ToEmailId, int AppId, string InvitationBy, string InvitationByEmail, DateTime InvitationDate, string UserRole, int SiteId, int DivisionId) { EmailMessage message = new EmailMessage(); message.Subject = "Invitation for registration"; //string temp = (ConfigurationManager.AppSettings["SalesManager"]); string domain = ConfigurationManager.AppSettings["LoginDomain"]; message.To = ToEmailId; string link = domain + "/Account/Register?ToEmailId=" + ToEmailId + "&AppId=" + AppId + "&InvitationBy=" + InvitationBy + "&InvitationByEmail=" + InvitationByEmail + "&InvitationDate=" + InvitationDate + "&UserRole=" + UserRole + "&SiteId=" + SiteId + "&DivisionId=" + DivisionId; SaleOrderHeader doc = new SaleOrderHeader(); message.Body += "Please use the link to register to the company. <a href='" + link + "' target='_blank'> Click Here </a>"; if (!string.IsNullOrEmpty(InvitationByEmail)) { message.CC = InvitationByEmail; } SendEmail se = new SendEmail(); await se.configSendGridasync(message); }
public async Task SendNewUserRegistrationNotification(string UserId) { EmailMessage message = new EmailMessage(); message.Subject = "New user registered"; string temp = (ConfigurationManager.AppSettings["SalesManager"]); string domain = ConfigurationManager.AppSettings["CurrentDomain"]; message.To = "*****@*****.**"; string link = domain + "/SaleOrderHeader/Detail/" + UserId + "?transactionType=approve"; SaleOrderHeader doc = new SaleOrderHeader(); using (ApplicationDbContext context = new ApplicationDbContext()) { var RegUser = (from p in context.Users where p.Id == UserId select p).FirstOrDefault(); message.Body += "New user " + RegUser.UserName + " registered"; } SendEmail se = new SendEmail(); await se.configSendGridasync(message); }
public ActionResult Detail(int id, string transactionType, string IndexType) { ViewBag.transactionType = transactionType; ViewBag.IndexStatus = IndexType; SaleOrderHeader s = _SaleOrderHeaderService.GetSaleOrderHeader(id); SaleOrderHeaderIndexViewModel svm = Mapper.Map <SaleOrderHeader, SaleOrderHeaderIndexViewModel>(s); var settings = new SaleOrderSettingsService(_unitOfWork).GetSaleOrderSettings(s.DocTypeId, s.DivisionId, s.SiteId); svm.SaleOrderSettings = Mapper.Map <SaleOrderSettings, SaleOrderSettingsViewModel>(settings); PrepareViewBag(svm); if (s == null) { return(HttpNotFound()); } if (String.IsNullOrEmpty(transactionType) || transactionType == "detail") { LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = s.DocTypeId, DocId = s.SaleOrderHeaderId, ActivityType = (int)ActivityTypeContants.Detail, DocNo = s.DocNo, DocDate = s.DocDate, DocStatus = s.Status, })); } return(View("Create", svm)); }
public ActionResult SaleOrderExcelImport(int id) { int BuyerId = 0; var file = Request.Files[0]; string filePath = Request.MapPath(ConfigurationManager.AppSettings["ExcelFilePath"] + file.FileName); file.SaveAs(filePath); var excel = new ExcelQueryFactory(); //excel.FileName =ConfigurationManager.AppSettings["ExcelFilePath"]; // @"C:\Users\guru\Downloads\PO.xls"; //TODO: Rempve hardcode excel.FileName = filePath; var SaleOrderRecordList = from c in excel.Worksheet <SaleOrderExcel>() select c; StringBuilder strSku = new StringBuilder(); StringBuilder strSaleToBuyer = new StringBuilder(); StringBuilder strBillToBuyer = new StringBuilder(); StringBuilder strCurrency = new StringBuilder(); StringBuilder strShipMethod = new StringBuilder(); StringBuilder strDeliveryTerms = new StringBuilder(); StringBuilder strPriority = new StringBuilder(); StringBuilder strOrderNo = new StringBuilder(); foreach (var SaleOrderRecord in SaleOrderRecordList) { if (_SaleOrderHeaderService.FindByDocNo(SaleOrderRecord.OrderNumber) != null) { if (!strOrderNo.ToString().Contains("" + SaleOrderRecord.OrderNumber)) { strOrderNo.Append(" " + SaleOrderRecord.OrderNumber + ","); } } if (_ProductService.Find(SaleOrderRecord.Product) == null) { if (!strSku.ToString().Contains("" + SaleOrderRecord.Product)) { strSku.Append(" " + SaleOrderRecord.Product + ","); } } if (SaleOrderRecord.SaleToBuyer != null) { if (_BuyerService.GetBuyerByName(SaleOrderRecord.SaleToBuyer) == null) { if (!strSaleToBuyer.ToString().Contains("" + SaleOrderRecord.SaleToBuyer)) { strSaleToBuyer.Append(" " + SaleOrderRecord.SaleToBuyer + ","); } } } if (SaleOrderRecord.BillToBuyer != null) { if (_BuyerService.GetBuyerByName(SaleOrderRecord.BillToBuyer) == null) { if (!strBillToBuyer.ToString().Contains("" + SaleOrderRecord.BillToBuyer)) { strBillToBuyer.Append(" " + SaleOrderRecord.BillToBuyer + ","); } } } if (SaleOrderRecord.Currency != null) { if (_currencyService.GetCurrencyByName(SaleOrderRecord.Currency) == null) { if (!strCurrency.ToString().Contains("" + SaleOrderRecord.Currency)) { strCurrency.Append(" " + SaleOrderRecord.Currency + ","); } } } if (SaleOrderRecord.ShipMethod != null) { if (_ShipMethodService.GetShipMethodByName(SaleOrderRecord.ShipMethod) == null) { if (!strShipMethod.ToString().Contains("" + SaleOrderRecord.ShipMethod)) { strShipMethod.Append(" " + SaleOrderRecord.ShipMethod + ","); } } } if (SaleOrderRecord.DeliveryTerms != null) { if (_DeliveryTermsService.GetDeliveryTermsByName(SaleOrderRecord.DeliveryTerms) == null) { if (!strDeliveryTerms.ToString().Contains("" + SaleOrderRecord.DeliveryTerms)) { strDeliveryTerms.Append(" " + SaleOrderRecord.DeliveryTerms + ","); } } } if (SaleOrderRecord.Priority != null) { if (Enum.IsDefined(typeof(SaleOrderPriority), SaleOrderRecord.Priority) == false) { if (!strPriority.ToString().Contains("" + SaleOrderRecord.Priority)) { strPriority.Append(" " + SaleOrderRecord.Priority + ","); } } } } if (!string.IsNullOrEmpty(strSku.ToString()) || !string.IsNullOrEmpty(strOrderNo.ToString()) || !string.IsNullOrEmpty(strSaleToBuyer.ToString()) || !string.IsNullOrEmpty(strBillToBuyer.ToString()) || !string.IsNullOrEmpty(strCurrency.ToString()) || !string.IsNullOrEmpty(strShipMethod.ToString()) || !string.IsNullOrEmpty(strDeliveryTerms.ToString()) || !string.IsNullOrEmpty(strPriority.ToString())) { if (string.IsNullOrEmpty(strOrderNo.ToString())) { ViewBag.orderno = null; } else { ViewBag.orderno = strOrderNo; } if (string.IsNullOrEmpty(strSku.ToString())) { ViewBag.product = null; } else { ViewBag.product = strSku; } if (string.IsNullOrEmpty(strSaleToBuyer.ToString())) { ViewBag.SaleToBuyer = null; } else { ViewBag.SaleToBuyer = strSaleToBuyer; } if (string.IsNullOrEmpty(strBillToBuyer.ToString())) { ViewBag.BillToBuyer = null; } else { ViewBag.BillToBuyer = strBillToBuyer; } if (string.IsNullOrEmpty(strCurrency.ToString())) { ViewBag.Currency = null; } else { ViewBag.Currency = strCurrency; } if (string.IsNullOrEmpty(strShipMethod.ToString())) { ViewBag.ShipMethod = null; } else { ViewBag.ShipMethod = strShipMethod; } if (string.IsNullOrEmpty(strDeliveryTerms.ToString())) { ViewBag.DeliveryTerms = null; } else { ViewBag.DeliveryTerms = strDeliveryTerms; } if (string.IsNullOrEmpty(strPriority.ToString())) { ViewBag.Priority = null; } else { ViewBag.Priority = strPriority; } return(View()); } else { string previousRecord = null; int count = 0; SaleOrderHeader stemp = new SaleOrderHeader(); int LinePk = 0; foreach (var SaleOrderRecord in SaleOrderRecordList) { if (count == 0 || SaleOrderRecord.OrderNumber != previousRecord) { //Object for SaleorderHeader Model to Save Order Num,Order Date, Ship Date and Supplier SaleOrderHeader s = new SaleOrderHeader(); if (SaleOrderRecord.ShipAddress != null) { s.ShipAddress = SaleOrderRecord.ShipAddress; } s.DocDate = SaleOrderRecord.OrderDate; s.DocNo = SaleOrderRecord.OrderNumber; s.DueDate = SaleOrderRecord.DueDate; s.ActualDueDate = SaleOrderRecord.DueDate; s.BuyerOrderNo = SaleOrderRecord.BuyerOrderNo; s.CreatedDate = DateTime.Now; s.ModifiedDate = DateTime.Now; s.CreatedBy = User.Identity.Name; s.ModifiedBy = User.Identity.Name; s.SaleToBuyerId = _BuyerService.GetBuyerByName(SaleOrderRecord.SaleToBuyer).PersonID; if (SaleOrderRecord.BillToBuyer != null) { s.BillToBuyerId = _BuyerService.GetBuyerByName(SaleOrderRecord.BillToBuyer).PersonID; } else { s.BillToBuyerId = s.SaleToBuyerId; } BuyerId = s.SaleToBuyerId; s.DivisionId = (int)System.Web.HttpContext.Current.Session["DivisionId"]; s.SiteId = (int)System.Web.HttpContext.Current.Session["SiteId"]; SaleOrderSettings temp = new SaleOrderSettingsService(_unitOfWork).GetSaleOrderSettings(id, s.DivisionId, s.SiteId); if (temp == null) { throw new Exception("Sale order settings is not configured"); } if (SaleOrderRecord.Currency != null) { s.CurrencyId = _currencyService.GetCurrencyByName(SaleOrderRecord.Currency).ID; } else { s.CurrencyId = temp.CurrencyId; } if (SaleOrderRecord.ShipMethod == null) { s.ShipMethodId = temp.ShipMethodId; } else { s.ShipMethodId = _ShipMethodService.GetShipMethodByName(SaleOrderRecord.ShipMethod).ShipMethodId; } if (SaleOrderRecord.DeliveryTerms == null) { s.DeliveryTermsId = temp.DeliveryTermsId; } else { s.DeliveryTermsId = _DeliveryTermsService.GetDeliveryTermsByName(SaleOrderRecord.DeliveryTerms).DeliveryTermsId; } if (SaleOrderRecord.Priority == null) { s.Priority = temp.Priority; } else if (SaleOrderRecord.Priority == "Low") { s.Priority = (int)(SaleOrderPriority.Low); } else if (SaleOrderRecord.Priority == "High") { s.Priority = (int)(SaleOrderPriority.High); } else { s.Priority = (int)(SaleOrderPriority.Normal); } if (temp != null) { s.DocTypeId = temp.DocTypeId; s.UnitConversionForId = temp.UnitConversionForId; } _SaleOrderHeaderService.Create(s); stemp = s; } //Object for SaleOrderLineDetail Model to Save Rate, Quantity, Product Product product = _ProductService.Find(SaleOrderRecord.Product); SaleOrderLine sl = new SaleOrderLine(); sl.SaleOrderHeaderId = stemp.SaleOrderHeaderId; sl.Rate = (decimal)SaleOrderRecord.Rate; sl.Qty = SaleOrderRecord.Quantity; sl.ProductId = product.ProductId; sl.Specification = product.ProductSpecification; sl.DueDate = SaleOrderRecord.DueDate; sl.DealUnitId = product.UnitId; sl.CreatedDate = DateTime.Now; sl.ModifiedDate = DateTime.Now; sl.DealQty = SaleOrderRecord.Quantity; sl.CreatedBy = User.Identity.Name; sl.ModifiedBy = User.Identity.Name; sl.Amount = sl.Rate * sl.Qty; sl.SaleOrderLineId = LinePk++; if (SaleOrderRecord.BuyerUpcCode != "" && SaleOrderRecord.BuyerUpcCode != null) { ProductBuyer productbuyer = new ProductBuyerService(_unitOfWork).Find(BuyerId, sl.ProductId); if (productbuyer != null) { productbuyer.BuyerUpcCode = SaleOrderRecord.BuyerUpcCode; new ProductBuyerService(_unitOfWork).Update(productbuyer); } else { ProductBuyer Temp = new ProductBuyer(); Temp.BuyerId = BuyerId; Temp.ProductId = sl.ProductId; Temp.BuyerUpcCode = SaleOrderRecord.BuyerUpcCode; Temp.CreatedDate = DateTime.Now; Temp.ModifiedDate = DateTime.Now; Temp.CreatedBy = User.Identity.Name; Temp.ModifiedBy = User.Identity.Name; Temp.ObjectState = Model.ObjectState.Added; new ProductBuyerService(_unitOfWork).Create(Temp); } } _SaleOrderLineService.Create(sl); new SaleOrderLineStatusService(_unitOfWork).CreateLineStatus(sl.SaleOrderLineId); count++; previousRecord = SaleOrderRecord.OrderNumber; _unitOfWork.Save(); } ViewBag.id = id; return(View("Sucess")); } }
public SaleOrderHeader Create(SaleOrderHeader s) { s.ObjectState = ObjectState.Added; _unitOfWork.Repository <SaleOrderHeader>().Insert(s); return(s); }
public void Delete(SaleOrderHeader s) { _unitOfWork.Repository <SaleOrderHeader>().Delete(s); }
public void Update(SaleOrderHeader s) { s.ObjectState = ObjectState.Modified; _unitOfWork.Repository <SaleOrderHeader>().Update(s); }
// GET: /SaleOrderHeader/Edit/5 private ActionResult Edit(int id, string IndexType) { ViewBag.IndexStatus = IndexType; SaleOrderHeader s = _SaleOrderHeaderService.GetSaleOrderHeader(id); if (s == null) { return(HttpNotFound()); } if (new RolePermissionService(_unitOfWork).IsActionAllowed(UserRoles, s.DocTypeId, null, this.ControllerContext.RouteData.Values["controller"].ToString(), "Edit") == false) { return(View("~/Views/Shared/PermissionDenied.cshtml").Warning("You don't have permission to do this task.")); } #region DocTypeTimeLineValidation try { TimePlanValidation = DocumentValidation.ValidateDocument(Mapper.Map <DocumentUniqueId>(s), DocumentTimePlanTypeConstants.Modify, User.Identity.Name, out ExceptionMsg, out Continue); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; TimePlanValidation = false; } if (!TimePlanValidation) { TempData["CSEXC"] += ExceptionMsg; } #endregion if ((!TimePlanValidation && !Continue)) { return(RedirectToAction("DetailInformation", new { id = id, IndexType = IndexType })); } SaleOrderHeaderIndexViewModel svm = Mapper.Map <SaleOrderHeader, SaleOrderHeaderIndexViewModel>(s); PrepareViewBag(svm); ViewBag.Mode = "Edit"; SaleOrderSettings temp = new SaleOrderSettingsService(_unitOfWork).GetSaleOrderSettings(s.DocTypeId, s.DivisionId, s.SiteId); svm.SaleOrderSettings = Mapper.Map <SaleOrderSettings, SaleOrderSettingsViewModel>(temp); svm.ProcessId = temp.ProcessId; if (!(System.Web.HttpContext.Current.Request.UrlReferrer.PathAndQuery).Contains("Create")) { LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = s.DocTypeId, DocId = s.SaleOrderHeaderId, ActivityType = (int)ActivityTypeContants.Detail, DocNo = s.DocNo, DocDate = s.DocDate, DocStatus = s.Status, })); } return(View("Create", svm)); }
public int LedgerPost(SaleOrderHeader pd) { int LedgerHeaderId = 0; if (pd.LedgerHeaderId == 0 || pd.LedgerHeaderId == null) { LedgerHeader LedgerHeader = new LedgerHeader(); LedgerHeader.DocTypeId = pd.DocTypeId; LedgerHeader.DocDate = pd.DocDate; LedgerHeader.DocNo = pd.DocNo; LedgerHeader.DivisionId = pd.DivisionId; LedgerHeader.SiteId = pd.SiteId; LedgerHeader.Remark = pd.Remark; LedgerHeader.CreatedBy = pd.CreatedBy; LedgerHeader.CreatedDate = DateTime.Now.Date; LedgerHeader.ModifiedBy = pd.ModifiedBy; LedgerHeader.ModifiedDate = DateTime.Now.Date; new LedgerHeaderService(_unitOfWork).Create(LedgerHeader); } else { LedgerHeader LedgerHeader = new LedgerHeaderService(_unitOfWork).Find((int)pd.LedgerHeaderId); LedgerHeader.DocTypeId = pd.DocTypeId; LedgerHeader.DocDate = pd.DocDate; LedgerHeader.DocNo = pd.DocNo; LedgerHeader.DivisionId = pd.DivisionId; LedgerHeader.SiteId = pd.SiteId; LedgerHeader.Remark = pd.Remark; LedgerHeader.ModifiedBy = pd.ModifiedBy; LedgerHeader.ModifiedDate = DateTime.Now.Date; new LedgerHeaderService(_unitOfWork).Update(LedgerHeader); IEnumerable <Ledger> LedgerList = new LedgerService(_unitOfWork).FindForLedgerHeader(LedgerHeader.LedgerHeaderId); foreach (Ledger item in LedgerList) { new LedgerService(_unitOfWork).Delete(item); } LedgerHeaderId = LedgerHeader.LedgerHeaderId; } int SalesAc = new LedgerAccountService(_unitOfWork).Find(LedgerAccountConstants.Sale).LedgerAccountId; if (pd.Advance > 0) { Ledger LedgerDr = new Ledger(); if (LedgerHeaderId != 0) { LedgerDr.LedgerHeaderId = LedgerHeaderId; } LedgerDr.LedgerAccountId = SalesAc; LedgerDr.ContraLedgerAccountId = pd.BillToBuyerId; LedgerDr.AmtDr = pd.Advance ?? 0; LedgerDr.AmtCr = 0; LedgerDr.Narration = ""; new LedgerService(_unitOfWork).Create(LedgerDr); Ledger LedgerCr = new Ledger(); if (LedgerHeaderId != 0) { LedgerCr.LedgerHeaderId = LedgerHeaderId; } LedgerCr.LedgerAccountId = pd.BillToBuyerId; LedgerCr.ContraLedgerAccountId = SalesAc; LedgerCr.AmtDr = 0; LedgerCr.AmtCr = pd.Advance ?? 0; LedgerCr.Narration = ""; new LedgerService(_unitOfWork).Create(LedgerCr); } return(LedgerHeaderId); }
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 ActionResult HeaderPost(SaleOrderHeaderIndexViewModel svm) { if (svm.DocDate > svm.DueDate) { ModelState.AddModelError("DueDate", "DueDate cannot be greater than DocDate"); } #region DocTypeTimeLineValidation try { if (svm.SaleOrderHeaderId <= 0) { TimePlanValidation = DocumentValidation.ValidateDocument(Mapper.Map <DocumentUniqueId>(svm), DocumentTimePlanTypeConstants.Create, User.Identity.Name, out ExceptionMsg, out Continue); } else { TimePlanValidation = DocumentValidation.ValidateDocument(Mapper.Map <DocumentUniqueId>(svm), DocumentTimePlanTypeConstants.Modify, User.Identity.Name, out ExceptionMsg, out Continue); } } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; TimePlanValidation = false; } if (!TimePlanValidation) { TempData["CSEXC"] += ExceptionMsg; } #endregion if (ModelState.IsValid && (TimePlanValidation || Continue)) { #region CreateRecord if (svm.SaleOrderHeaderId == 0) { SaleOrderHeader s = Mapper.Map <SaleOrderHeaderIndexViewModel, SaleOrderHeader>(svm); s.ActualDueDate = s.DueDate; s.CreatedDate = DateTime.Now; s.ModifiedDate = DateTime.Now; s.CreatedBy = User.Identity.Name; s.ModifiedBy = User.Identity.Name; s.Status = (int)StatusConstants.Drafted; _SaleOrderHeaderService.Create(s); try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; PrepareViewBag(svm); ViewBag.Mode = "Add"; return(View("Create", svm)); } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = s.DocTypeId, DocId = s.SaleOrderHeaderId, ActivityType = (int)ActivityTypeContants.Added, DocNo = s.DocNo, DocDate = s.DocDate, DocStatus = s.Status, })); return(RedirectToAction("Modify", new { id = s.SaleOrderHeaderId }).Success("Data saved Successfully")); } #endregion #region EditRecord else { List <LogTypeViewModel> LogList = new List <LogTypeViewModel>(); //string tempredirect = (Request["Redirect"].ToString()); SaleOrderHeader s = Mapper.Map <SaleOrderHeaderIndexViewModel, SaleOrderHeader>(svm); StringBuilder logstring = new StringBuilder(); SaleOrderHeader temp = _SaleOrderHeaderService.Find(s.SaleOrderHeaderId); SaleOrderHeader ExRec = new SaleOrderHeader(); ExRec = Mapper.Map <SaleOrderHeader>(temp); int status = temp.Status; if (temp.Status != (int)StatusConstants.Drafted && temp.Status != (int)StatusConstants.Import) { temp.Status = (int)StatusConstants.Modified; } temp.DocTypeId = s.DocTypeId; temp.DocDate = s.DocDate; temp.DocNo = s.DocNo; temp.BuyerOrderNo = s.BuyerOrderNo; temp.SaleToBuyerId = s.SaleToBuyerId; temp.BillToBuyerId = s.BillToBuyerId; temp.CurrencyId = s.CurrencyId; temp.Priority = s.Priority; temp.UnitConversionForId = s.UnitConversionForId; temp.ShipMethodId = s.ShipMethodId; temp.ShipAddress = s.ShipAddress; temp.DeliveryTermsId = s.DeliveryTermsId; temp.Remark = s.Remark; temp.DueDate = s.DueDate; temp.Advance = s.Advance; temp.FinancierId = s.FinancierId; temp.SalesExecutiveId = s.SalesExecutiveId; temp.ModifiedDate = DateTime.Now; temp.ModifiedBy = User.Identity.Name; _SaleOrderHeaderService.Update(temp); 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); TempData["CSEXC"] += message; PrepareViewBag(svm); ViewBag.Mode = "Edit"; return(View("Create", svm)); } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = temp.DocTypeId, DocId = temp.SaleOrderHeaderId, ActivityType = (int)ActivityTypeContants.Modified, DocNo = temp.DocNo, xEModifications = Modifications, DocDate = temp.DocDate, DocStatus = temp.Status, })); return(RedirectToAction("Index", new { id = svm.DocTypeId }).Success("Data saved successfully")); } #endregion } PrepareViewBag(svm); ViewBag.Mode = "Add"; return(View("Create", svm)); }
public static void SendSaleOrderModifiedEmail(int DocId, string Reason) { EmailMessage message = new EmailMessage(); message.Subject = "Approve modified sale order"; message.To = ConfigurationManager.AppSettings["SalesManager"]; string path = ConfigurationManager.AppSettings["CurrentDomain"]; string link = path + "/SaleOrderHeader/Detail/" + DocId + "?transactionType=approve"; SaleOrderHeader doc = new SaleOrderHeader(); using (ApplicationDbContext context = new ApplicationDbContext()) { doc = context.SaleOrderHeader.Find(DocId); string format = "dd/MMM/yyyy"; var SaleOrder = (from H in context.SaleOrderHeader where H.SaleOrderHeaderId == DocId select new { OrderNo = H.DocNo, OrderDate = H.DocDate, BuyerOrderNo = H.BuyerOrderNo, DueDate = H.DueDate, DocumentTypeName = H.DocType.DocumentTypeName, BuyerName = H.SaleToBuyer.Name }).FirstOrDefault(); message.Body += "<div style='width:100% ;font-family sans-serif;'>" + "<table style='border: 1px solid rgb(79,129,189);border-spacing:0px;width: 100%;font-size:1.4em;'>" + "<tr style='background-color:rgb(79,129,189)'>" + "<td colspan='6'>" + "<table style='width:100%'> <tr> <td style='width:85%'> <h2 style='color:#FFF;margin-top:10px;margin-bottom:10px'> Please approve modified sale order : " + SaleOrder.OrderNo + " </h2> </td>" + " <td>" + "<!--[if mso]>" + "<v:roundrect xmlns:v='urn:schemas-microsoft-com:vml' xmlns:w='urn:schemas-microsoft-com:office:word' href='" + link + "' style='height:36px;v-text-anchor:middle;width:150px;' arcsize='5%' strokecolor='black' fillcolor='white'>" + "<w:anchorlock/>" + "<center style='color:black;font-family:Helvetica, Arial,sans-serif;font-size:16px;'>Approve →</center>" + "</v:roundrect>" + "<![endif]-->" + "<a href='" + link + "' style='background-color: #FFF; border: 1px solid #2980b9; border-radius: 3px; float: right; color: #000; display: inline-block; font-family: sans-serif; font-size: 16px; line-height: 30px; text-align: center; text-decoration: none; width: 100px; -webkit-text-size-adjust: none; mso-hide: all;margin-right:15% '>Approve →</a>" + "</td> </tr> </table>" + "<tr style='height: 30px; '>" + "<td style='font-weight:bold;width:18%'> Order Type </td>" + "<td style='width:3%'>:</td>" + "<td style='width:26%'>" + SaleOrder.DocumentTypeName + "</td>" + "<td style='font-weight: bold; width: 18%'> Order No</td>" + "<td style='width:3%'>:</td>" + "<td> " + SaleOrder.OrderNo + " </td>" + "</tr>" + "<tr style='height: 30px; background-color: rgb(220, 230, 241); '>" + "<td style='font-weight: bold; width: 18%; '> Order Date</td>" + "<td style='width:3%'>:</td>" + "<td style='width:26%'>" + SaleOrder.OrderDate.ToString(format) + " </td>" + "<td style='font-weight: bold; width: 18%'> Buyer Order No</td>" + "<td style='width:3%'>:</td>" + "<td> " + SaleOrder.BuyerOrderNo + " </td>" + "</tr>" + "<tr style='height: 30px; '>" + "<td style='font-weight: bold; width: 18%; '> Due Date</td>" + "<td style='width:3%'>:</td>" + "<td style='width:26%'>" + SaleOrder.DueDate.ToString(format) + "</td>" + "<td style='font-weight: bold; width: 18%; '> Buyer</td>" + "<td style='width:3%'>:</td>" + "<td> " + SaleOrder.BuyerName + " </td>" + "</tr>" + "</table>" + "<h3 style='color:#C70505'> User Remark:" + Reason + "</h3>" + "</div>"; } SendEmail.SendEmailMsg(message); }
private void PrepareViewBag(SaleOrderHeader H) { ViewBag.Docno = H.DocNo; ViewBag.DeliveryUnitList = new UnitService(_unitOfWork).GetUnitList().ToList(); }