protected void Page_Load(object sender, EventArgs e) { PurchaseOrderModel model = MapOrder(); model.BillingAddress = MapOrderAddress(TransactionLibrary.GetBillingInformation()); model.ShippingAddress = MapOrderAddress(TransactionLibrary.GetShippingInformation()); var basket = UCommerce.Api.TransactionLibrary.GetBasket(false).PurchaseOrder; var billingCurrency = basket.BillingCurrency; foreach (var basketOrderLine in basket.OrderLines) { var orderLineModel = new OrderlineModel(); orderLineModel.Sku = basketOrderLine.Sku; orderLineModel.VariantSku = basketOrderLine.VariantSku; orderLineModel.ProductName = basketOrderLine.ProductName; orderLineModel.Quantity = basketOrderLine.Quantity; orderLineModel.Total = new UCommerce.Money(basketOrderLine.Total.GetValueOrDefault(), billingCurrency).ToString(); model.OrderLines.Add(orderLineModel); } model.SubTotal = GetMoneyFormat(basket.SubTotal.GetValueOrDefault(), billingCurrency); model.TaxTotal = GetMoneyFormat(basket.TaxTotal.GetValueOrDefault(), billingCurrency); model.DiscountTotal = GetMoneyFormat(basket.DiscountTotal.GetValueOrDefault(), billingCurrency); model.ShippingTotal = GetMoneyFormat(basket.ShippingTotal.GetValueOrDefault(), billingCurrency); model.PaymentTotal = GetMoneyFormat(basket.PaymentTotal.GetValueOrDefault(), billingCurrency); model.OrderTotal = GetMoneyFormat(basket.OrderTotal.GetValueOrDefault(), billingCurrency); BuildPage(model); }
private PurchaseOrderModel MapBasket(PurchaseOrder basket) { var basketModel = new PurchaseOrderModel(); UCommerce.EntitiesV2.Currency billingCurrency = basket.BillingCurrency; basketModel.OrderTotal = new Money(basket.OrderTotal.GetValueOrDefault(), billingCurrency).ToString(); foreach (UCommerce.EntitiesV2.OrderLine basketOrderLine in basket.OrderLines) { var orderlineModel = new OrderlineModel(); orderlineModel.Quantity = basketOrderLine.Quantity; orderlineModel.ProductName = basketOrderLine.ProductName; var total = new Money(basketOrderLine.Total.GetValueOrDefault(), basket.BillingCurrency); orderlineModel.Sku = basketOrderLine.Sku; orderlineModel.OrderLineId = basketOrderLine.OrderLineId; orderlineModel.VariantSku = basketOrderLine.VariantSku; orderlineModel.Total = new Money(basketOrderLine.Total.GetValueOrDefault(), billingCurrency).ToString(); basketModel.OrderLines.Add(orderlineModel); } return(basketModel); }
public bool UpdateOrderline(OrderlineModel orderline) { throw new NotImplementedException(); }
public void LoadOrder() { //reset orderlines OrderlineList = new BindingList <OrderlineModel>(); DataGrid.DataSource = OrderlineList; if (CurrentOrder == null) { CurrentOrder = new OrderEntity() { OrderType = (int)enumOrderType.Purchase, OrderDate = DateTime.Now, CompanyId = ApplicationHelper.CurrentUserProfile.CompanyId, CreatedBy = ApplicationHelper.CurrentUserProfile.ContactId, ResponsibleBy = ApplicationHelper.CurrentUserProfile.ContactId, OrderNumber = "" }; } else { var orderlines = VinaGerman.Entity.Factory.Resolve <VinaGerman.DataSource.IOrderDS>().GetOrderlinesForOrder(CurrentOrder, true); if (orderlines != null && orderlines.Count > 0) { for (int i = 0; i < orderlines.Count; i++) { var newOrderline = new OrderlineModel() { OrderlineId = orderlines[i].OrderlineId, OrderId = orderlines[i].OrderId, ArticleId = orderlines[i].ArticleId, CreatedBy = orderlines[i].CreatedBy, ModifiedBy = orderlines[i].ModifiedBy, ModifiedDate = orderlines[i].ModifiedDate, PaidDate = orderlines[i].PaidDate, PayDate = orderlines[i].PayDate, Price = orderlines[i].Price, Quantity = orderlines[i].Quantity, RealQuantity = orderlines[i].RealQuantity, RemainingQuantity = orderlines[i].RemainingQuantity, Unit = orderlines[i].Unit }; //populate loan list if (orderlines[i].LoanList != null && orderlines[i].LoanList.Count > 0) { for (int j = 0; j < orderlines[i].LoanList.Count; j++) { newOrderline.ChildList.Add(new LoanModel() { LoanId = orderlines[i].LoanList[j].LoanId, OrderlineId = orderlines[i].LoanList[j].OrderlineId, ArticleId = orderlines[i].LoanList[j].ArticleId, Quantity = orderlines[i].LoanList[j].Quantity, RemainingQuantity = orderlines[i].LoanList[j].RemainingQuantity, Unit = orderlines[i].Unit }); } } OrderlineList.Add(newOrderline); } } } StatusList = new List <KeyValuePair <int, string> >(); StatusList.Add(new KeyValuePair <int, string>((int)enumOrderStatus.Ready, "Chờ xử lí")); StatusList.Add(new KeyValuePair <int, string>((int)enumOrderStatus.Approved, "Đã duyệt")); StatusList.Add(new KeyValuePair <int, string>((int)enumOrderStatus.Processed, "Đã xử lí")); ArticleList = VinaGerman.Entity.Factory.Resolve <VinaGerman.DataSource.IBaseDataDS>().SearchArticle(new ArticleSearchEntity() { SearchText = "" }); BusinessList = VinaGerman.Entity.Factory.Resolve <VinaGerman.DataSource.IBaseDataDS>().SearchBusiness(new BusinessSearchEntity() { SearchText = "" }); IndustryList = VinaGerman.Entity.Factory.Resolve <VinaGerman.DataSource.IBaseDataDS>().SearchIndustry(new IndustrySearchEntity() { SearchText = "" }); CustomerList = VinaGerman.Entity.Factory.Resolve <VinaGerman.DataSource.ICompanyDS>().SearchCompanies(new CompanySearchEntity() { SearchText = "", IsSupplier = true, NotIncludedCompany = ApplicationHelper.CurrentUserProfile.CompanyId }); EmployeeList = VinaGerman.Entity.Factory.Resolve <VinaGerman.DataSource.ICompanyDS>().SearchContact(new ContactSearchEntity() { SearchText = "" }); this.RepositoryArticleLookupEdit.DataSource = ArticleList; this.cboCustomer.Properties.DataSource = CustomerList; this.cboCustomer.EditValue = CurrentOrder.CustomerCompanyId; this.cboEmployee.Properties.DataSource = EmployeeList; this.cboEmployee.EditValue = ApplicationHelper.CurrentUserProfile.ContactId; this.cboBusiness.Properties.DataSource = BusinessList; this.cboBusiness.EditValue = CurrentOrder.BusinessId; this.cboIndustry.Properties.DataSource = IndustryList; this.cboIndustry.EditValue = CurrentOrder.IndustryId; this.cboStatus.Properties.DataSource = StatusList; this.cboStatus.EditValue = CurrentOrder.OrderStatus; this.txtOrderDate.EditValue = CurrentOrder.OrderDate; this.txtOrderNumber.Text = CurrentOrder.OrderNumber; ExpandAllRows(MasterGridView); }