protected void btnAddChangeContact_Click(object sender, EventArgs e) { if (!ValidateFormData()) return; var contact = new CustomerContact { Name = txtContactName.Text, Country = cboCountry.SelectedItem.Text, CountryId = Int32.Parse(cboCountry.SelectedValue), City = HttpUtility.HtmlEncode(txtContactCity.Text), RegionName = HttpUtility.HtmlEncode(txtContactZone.Text), Address = HttpUtility.HtmlEncode(txtContactAddress.Text), Zip = HttpUtility.HtmlEncode(txtContactZip.Text), }; switch (ViewState["AddOrEdit"].ToString()) { case "Add": contact.CustomerGuid = Customer.Id; CustomerService.AddContact(contact, Customer.Id); break; case "Edit": contact.CustomerContactID = new Guid(CustomerContacts.SelectedValue); CustomerService.UpdateContact(contact); break; } DisplayAddressBook(); mvAdressBook.SetActiveView(vAdressBook); }
public static int UpdateContact(CustomerContact contact) { SQLDataAccess.ExecuteNonQuery("[Customers].[sp_UpdateCustomerContact]", CommandType.StoredProcedure, new SqlParameter("@ContactID", contact.CustomerContactID), new SqlParameter("@Name", contact.Name), new SqlParameter("@Country", contact.Country), new SqlParameter("@City", contact.City), new SqlParameter("@Zone", contact.RegionName), new SqlParameter("@Address", contact.Address), new SqlParameter("@Zip", contact.Zip), new SqlParameter("@CountryID", contact.CountryId), new SqlParameter("@RegionID", contact.RegionId.HasValue && contact.RegionId != -1 ? (object)contact.RegionId : DBNull.Value) ); return(0); }
public static Guid AddContact(CustomerContact contact, Guid customerId) { var id = SQLDataAccess.ExecuteScalar("[Customers].[sp_AddCustomerContact]", CommandType.StoredProcedure, new SqlParameter("@CustomerID", customerId), new SqlParameter("@Name", contact.Name), new SqlParameter("@Country", contact.Country), new SqlParameter("@City", contact.City), new SqlParameter("@Zone", contact.RegionName), new SqlParameter("@Address", contact.Address), new SqlParameter("@Zip", contact.Zip), new SqlParameter("@CountryID", contact.CountryId), new SqlParameter("@RegionID", contact.RegionId.HasValue && contact.RegionId > 0 ? contact.RegionId : (object)DBNull.Value)); return(SQLDataHelper.GetGuid(id)); }
public static CustomerContact GetContactFromSqlDataReader(SqlDataReader reader) { var contact = new CustomerContact { CustomerContactID = SQLDataHelper.GetGuid(reader, "ContactID"), Address = SQLDataHelper.GetString(reader, "Address"), City = SQLDataHelper.GetString(reader, "City"), Country = SQLDataHelper.GetString(reader, "Country"), Name = SQLDataHelper.GetString(reader, "Name"), Zip = SQLDataHelper.GetString(reader, "Zip"), RegionName = SQLDataHelper.GetString(reader, "Zone"), CountryId = SQLDataHelper.GetInt(reader, "CountryID"), RegionId = SQLDataHelper.GetNullableInt(reader, "RegionID"), CustomerGuid = SQLDataHelper.GetGuid(reader, "CustomerID") }; return(contact); }
public static Guid AddContact(CustomerContact contact, Guid customerId) { return SQLDataHelper.GetGuid(SQLDataAccess.ExecuteScalar("[Customers].[sp_AddCustomerContact]", CommandType.StoredProcedure, new SqlParameter("@CustomerID", customerId), new SqlParameter("@Name", contact.Name), new SqlParameter("@Country", contact.Country), new SqlParameter("@City", contact.City), new SqlParameter("@Zone", contact.RegionName), new SqlParameter("@Address", contact.Address), new SqlParameter("@Zip", contact.Zip), new SqlParameter("@CountryID", contact.CountryId), new SqlParameter("@RegionID", contact.RegionId.HasValue && contact.RegionId != -1 ? (object)contact.RegionId : DBNull.Value) )); }
public static float CalculateTaxesTotal(OrderItem orderItem, CustomerContact shippingContact, CustomerContact billingContact, float discountPercent) { if (orderItem.ProductID != null) { ICollection<TaxElement> taxes = GetTaxesForProduct((int)orderItem.ProductID, billingContact, shippingContact); return taxes.Where(tax => !tax.ShowInPrice).Sum(tax => CalculateTax(orderItem, tax, discountPercent)); } return 0; }
public static float CalculateTaxesTotal(ShoppingCartItem basketItem, CustomerContact shippingContact, CustomerContact billingContact, float discountPercent) { var orderItem = (OrderItem)basketItem; return CalculateTaxesTotal(orderItem, shippingContact, billingContact, discountPercent); }
public static int UpdateContact(CustomerContact contact) { SQLDataAccess.ExecuteNonQuery("[Customers].[sp_UpdateCustomerContact]", CommandType.StoredProcedure, new SqlParameter("@ContactID", contact.CustomerContactID), new SqlParameter("@Name", contact.Name), new SqlParameter("@Country", contact.Country), new SqlParameter("@City", contact.City), new SqlParameter("@Zone", contact.RegionName), new SqlParameter("@Address", contact.Address), new SqlParameter("@Zip", contact.Zip), new SqlParameter("@CountryID", contact.CountryId), new SqlParameter("@RegionID", contact.RegionId.HasValue && contact.RegionId != -1 ? (object) contact.RegionId : DBNull.Value) ); return 0; }
protected void Page_Load(object sender, EventArgs e) { if (EmptyCheck || Order == null) { return; } _currency = (Order.OrderCurrency ?? CurrencyService.Currency("USD")) ?? new Currency { IsCodeBefore = true, Iso3 = "USD", Name = "USD", PriceFormat = CurrencyService.DefaultPriceFormat, Symbol = "$", Value = 1 }; //var check = new Check_PaymentModule(); lCompanyName.Text = _Check.CompanyName; lAddress.Text = _Check.Adress; lCountry.Text = _Check.Country; lState.Text = _Check.State; lCity.Text = _Check.City; lCompanyPhone.Text = _Check.Phone; lInterPhone.Text = _Check.IntPhone; lCompanyFax.Text = _Check.Fax; lOrderDate.Text = AdvantShop.Localization.Culture.ConvertDate(Order.OrderDate); // AdvantShop.Localization.Culture.ConvertDate((DateTime)reader["OrderDate"]); lOrderId.Text = @"#" + Order.OrderID; lShippingMethod.Text = Order.ShippingMethodName; // reader["ShippingMethod"].ToString(); lName.Text = Order.BillingContact.Name; lPhone.Text = Order.OrderCustomer.MobilePhone; //lFax.Text = Order.BillingContact.Fax; //lEmail.Text = Order.BillingContact.Email; lEmail.Text = Order.OrderCustomer.Email; lBillingAddress.Text = Order.BillingContact.Address; lBillingCity.Text = Order.BillingContact.City; lBillingState.Text = Order.BillingContact.Zone; lBillingCountry.Text = Order.BillingContact.Country; lBillingZip.Text = Order.BillingContact.Zip; lShippingAddress.Text = Order.ShippingContact.Address; lShippingCity.Text = Order.ShippingContact.City; lShippingState.Text = Order.ShippingContact.Zone; lShippingCountry.Text = Order.ShippingContact.Country; lShippingZip.Text = Order.ShippingContact.Zip; lSubTotal.Text = EvalPrice((Order.Sum - Order.ShippingCost) * 100.0M / (100 - Order.OrderDiscount)); lShippingCost.Text = EvalPrice(Order.ShippingCost); lDiscount.Text = EvalPrice(Order.OrderDiscount * (Order.Sum - Order.ShippingCost / (100 - Order.OrderDiscount))); var shippingContact = new AdvantShop.Customers.CustomerContact { CountryId = CountryService.GetCountryIdByName(lShippingCountry.Text), RegionId = RegionService.GetRegionIdByName(lShippingState.Text) }; var billingContact = new AdvantShop.Customers.CustomerContact { CountryId = CountryService.GetCountryIdByName(lBillingCountry.Text), RegionId = RegionService.GetRegionIdByName(lBillingState.Text) }; rptOrderItems.DataBind(); IList <OrderItem> dtOrder = Order.OrderItems; var taxedItems = new List <TaxValue>(); foreach (OrderItem item in dtOrder) { ICollection <TaxElement> t = TaxServices.GetTaxesForProduct(item.EntityId, billingContact, shippingContact); foreach (TaxElement tax in t) { TaxValue taxedItem = taxedItems.Find(tv => tv.TaxID == tax.TaxId); if (taxedItem != null) { taxedItem.TaxSum += TaxServices.CalculateTax(item, tax); } else { taxedItems.Add(new TaxValue { TaxID = tax.TaxId, TaxName = tax.Name, TaxShowInPrice = tax.ShowInPrice, TaxSum = TaxServices.CalculateTax(item, tax) }); } } } literalTaxCost.Text = BuildTaxTable(taxedItems, _currency.Value, _currency.Iso3, Resource.Admin_ViewOrder_Taxes); lTotal.Text = EvalPrice(Order.Sum); }
public static bool RefreshTotal(int orderId) { Order order = GetOrder(orderId); var taxedItems = new List<TaxValue>(); float totalPaymentPrice = 0; float totalPrice = 0; float totaldiscount = 0; float supplyTotal = 0; if (order.OrderCertificates != null && order.OrderCertificates.Count > 0) { foreach (var item in order.OrderCertificates) { foreach (var taxId in GiftCertificateService.GetCertificateTaxesId()) { var tax = TaxServices.GetTax(taxId); TaxValue taxedItem = taxedItems.Find(tv => tv.TaxID == tax.TaxId); if (taxedItem != null) { taxedItem.TaxSum += TaxServices.CalculateTax(item.Sum, tax); } else { taxedItems.Add(new TaxValue { TaxID = tax.TaxId, TaxName = tax.Name, TaxSum = TaxServices.CalculateTax(item.Sum, tax), TaxShowInPrice = tax.ShowInPrice }); } } totalPrice += item.Sum; } } else { var shippingContact = new CustomerContact { CountryId = CountryService.GetCountryIdByName(order.ShippingContact.Country), RegionId = RegionService.GetRegionIdByName(order.ShippingContact.Zone) }; var billingContact = new CustomerContact { CountryId = CountryService.GetCountryIdByName(order.BillingContact.Country), RegionId = RegionService.GetRegionIdByName(order.BillingContact.Zone) }; foreach (OrderItem item in order.OrderItems) { if (item.ProductID != null) { var t = (List<TaxElement>) TaxServices.GetTaxesForProduct((int)item.ProductID, billingContact, shippingContact); foreach (TaxElement tax in t) { TaxValue taxedItem = taxedItems.Find(tv => tv.TaxID == tax.TaxId); if (taxedItem != null) { taxedItem.TaxSum += TaxServices.CalculateTax(item, tax, order.OrderDiscount); } else { taxedItems.Add(new TaxValue { TaxID = tax.TaxId, TaxName = tax.Name, TaxSum = TaxServices.CalculateTax(item, tax, order.OrderDiscount), TaxShowInPrice = tax.ShowInPrice }); } } } } totalPrice = order.OrderItems.Sum(item => item.Price * item.Amount); supplyTotal = order.OrderItems.Sum(item => item.SupplyPrice * item.Amount); totaldiscount += order.OrderDiscount > 0 ? order.OrderDiscount * totalPrice / 100 : 0; if (order.Certificate != null) { totaldiscount += order.Certificate.Price != 0 ? order.Certificate.Price : 0; } if (order.Coupon != null) { switch (order.Coupon.Type) { case CouponType.Fixed: var productsPrice = order.OrderItems.Where(item => item.IsCouponApplied).Sum(p => p.Price * p.Amount); totaldiscount += productsPrice >= order.Coupon.Value ? order.Coupon.Value : productsPrice; break; case CouponType.Percent: totaldiscount += order.OrderItems.Where(item => item.IsCouponApplied) .Sum(item => order.Coupon.Value * item.Price / 100 * item.Amount); break; } } } if (taxedItems.Count > 0) { TaxServices.ClearOrderTaxes(order.OrderID); TaxServices.SetOrderTaxes(order.OrderID, taxedItems); } float taxNotInPrice = taxedItems.Where(tv => !tv.TaxShowInPrice).Sum(tv => tv.TaxSum); float taxTotal = taxedItems.Sum(tv => tv.TaxSum); totalPaymentPrice = totalPrice + order.ShippingCost + order.PaymentCost + taxNotInPrice - totaldiscount; if (totalPaymentPrice < 0) totalPaymentPrice = 0; SQLDataAccess.ExecuteNonQuery( "UPDATE [Order].[Order] SET [Sum] = @Sum, [TaxCost] = @TaxCost, [SupplyTotal] = @SupplyTotal WHERE [OrderID] = @OrderID", CommandType.Text, new SqlParameter("@OrderID", orderId), new SqlParameter("@Sum", totalPaymentPrice), new SqlParameter("@TaxCost", taxTotal), new SqlParameter("@SupplyTotal", supplyTotal)); return true; }
public static Dictionary<TaxElement, float> GetTaxItems(IList<OrderItem> shoppingCartitems, CustomerContact shippingContact, CustomerContact billingContact, float discountPercent) { var taxesItems = new Dictionary<TaxElement, float>(); foreach (var item in shoppingCartitems) { if (item.ProductID != null) { var t = (List<TaxElement>)GetTaxesForProduct((int)item.ProductID, billingContact, shippingContact); foreach (var tax in t) { if (taxesItems.ContainsKey(tax)) { taxesItems[tax] += CalculateTax(item, tax, discountPercent); } else { taxesItems.Add(tax, CalculateTax(item, tax, discountPercent)); } } } } return taxesItems; }
private void SetShippingContact(CustomerContact customerContact) { if (customerContact == null) return; cboCountry.SelectedValue = customerContact.CountryId.ToString(CultureInfo.InvariantCulture); txtCity.Text = customerContact.City; txtState.Text = customerContact.RegionName; txtAdress.Text = customerContact.Address; txtZip.Text = customerContact.Zip; }
private void SetBillingContact(CustomerContact customerContact) { if (customerContact == null) return; txtBillingName.Text = customerContact.Name; cboBillingCountry.SelectedValue = customerContact.CountryId.ToString(CultureInfo.InvariantCulture); txtBillingCity.Text = customerContact.City; txtBillingState.Text = customerContact.RegionName; txtBillingAddress.Text = customerContact.Address; txtBillingZip.Text = customerContact.Zip; }
private static Dictionary<TaxElement, float> GetTaxItems(ShoppingCart shoppingCart, CustomerContact shippingContact, CustomerContact billingContact, float discountPercent) { var taxesItems = new Dictionary<TaxElement, float>(); foreach (var item in shoppingCart) { var t = (List<TaxElement>)TaxServices.GetTaxesForProduct(item.Offer.ProductId, billingContact, shippingContact); foreach (var tax in t) { if (taxesItems.ContainsKey(tax)) { taxesItems[tax] += TaxServices.CalculateTax((OrderItem)item, tax, discountPercent); } else { taxesItems.Add(tax, TaxServices.CalculateTax((OrderItem)item, tax, discountPercent)); } } } return taxesItems; }
public static ICollection<TaxElement> GetTaxesForProduct(int productId, CustomerContact billingContact, CustomerContact shippingContact) { var selC = SettingProvider.GetSellerContact(); return GetTaxesForProduct(productId, selC, billingContact, shippingContact); }
public static ICollection<TaxElement> GetTaxesForProduct(int productId, CustomerContact sellerContact, CustomerContact billingContact, CustomerContact shippingContact) { using (var da = new SQLDataAccess()) { da.cmd.CommandText = "SELECT [Catalog].[Tax].*, [Catalog].[TaxRegionRate].[RegionID], [Catalog].[TaxRegionRate].[RegionRate] " + "FROM [Catalog].[Tax] " + "LEFT JOIN [Catalog].[TaxRegionRate] ON [Tax].[TaxId] = [TaxRegionRate].[TaxId] " + "WHERE [Tax].TaxId in (select TaxId from [Catalog].[TaxMappingOnProduct] where [ProductID] = @ProductID) AND [Enabled] = 1 AND " + "([DependsOnAddress] = @default AND [CountryID] = @sellerCountry AND ([RegionID] = @sellerRegion OR [RegionID] is null)) OR " + "([DependsOnAddress] = @shipping AND [CountryID] = @shippingCountry AND ([RegionID] = @shippingRegion OR [RegionID] is null)) OR " + "([DependsOnAddress] = @billing AND [CountryID] = @billingCountry AND ([RegionID] = @billingRegion OR [RegionID] is null))"; da.cmd.CommandType = CommandType.Text; da.cmd.Parameters.AddWithValue("@default", (int)TypeRateDepends.Default); da.cmd.Parameters.AddWithValue("@shipping", (int)TypeRateDepends.ByShippingAddress); da.cmd.Parameters.AddWithValue("@billing", (int)TypeRateDepends.ByBillingAddress); da.cmd.Parameters.AddWithValue("@sellerCountry", sellerContact.CountryId); da.cmd.Parameters.AddWithValue("@sellerRegion", sellerContact.RegionId.HasValue ? sellerContact.RegionId : (object)DBNull.Value); da.cmd.Parameters.AddWithValue("@shippingCountry", shippingContact.CountryId); da.cmd.Parameters.AddWithValue("@shippingRegion", shippingContact.RegionId.HasValue ? shippingContact.RegionId : (object)DBNull.Value); da.cmd.Parameters.AddWithValue("@billingCountry", billingContact.CountryId); da.cmd.Parameters.AddWithValue("@billingRegion", billingContact.RegionId.HasValue ? billingContact.RegionId : (object)DBNull.Value); da.cmd.Parameters.AddWithValue("@ProductID", productId); da.cnOpen(); var result = new List<TaxElement>(); using (SqlDataReader reader = da.cmd.ExecuteReader()) while (reader.Read()) { var t = ReadTax(reader); var regionalRateCollection = new List<RegionalRate>(); t.RegionalRates = regionalRateCollection; if (!(reader["RegionID"] is DBNull)) { var regionalRate = new RegionalRate { RegionId = SQLDataHelper.GetInt(reader, "RegionID"), Rate = SQLDataHelper.GetFloat(reader, "RegionRate") }; regionalRateCollection.Add(regionalRate); } result.Add(t); } return result; } }
public static string ConvertToLinedAddress(CustomerContact cc) { string address = string.Empty; if (!String.IsNullOrEmpty(cc.Country.Trim())) { address += cc.Country + ", "; } if (cc.RegionName.Trim() != "-") { address += cc.RegionName + ", "; } if (!String.IsNullOrEmpty(cc.City.Trim())) { address += cc.City + ", "; } if (cc.Zip.Trim() != "-") { address += cc.Zip + ", "; } if (!String.IsNullOrEmpty(cc.Address.Trim())) { address += cc.Address + ", "; } return address; }
private void LoadTotal(Order order) { if (order.OrderCurrency != null) { CurrencyValue = order.OrderCurrency.CurrencyValue; CurrencyCode = order.OrderCurrency.CurrencyCode; } lblShippingPrice.Text = string.Format("+{0}", CatalogService.GetStringPrice(order.ShippingCost, CurrencyValue, CurrencyCode)); var shippingContact = new CustomerContact(); if (order.ShippingContact != null) { var region = RegionService.GetRegionIdByName(order.ShippingContact.Zone); shippingContact = new CustomerContact { CountryId = CountryService.GetCountryIdByName(order.ShippingContact.Country), RegionId = region != 0 ? (int?)region : null }; } var billingContact = new CustomerContact(); if (order.BillingContact != null) { var region = RegionService.GetRegionIdByName(order.BillingContact.Zone); billingContact = new CustomerContact { CountryId = CountryService.GetCountryIdByName(order.BillingContact.Country), RegionId = region != 0 ? (int?)region : null }; } float taxCost = 0; var taxedItems = new List<TaxValue>(); if (order.OrderCertificates != null && order.OrderCertificates.Count > 0) { foreach (var item in order.OrderCertificates) { foreach (var taxId in GiftCertificateService.GetCertificateTaxesId()) { var tax = TaxServices.GetTax(taxId); TaxValue taxedItem = taxedItems.Find(tv => tv.TaxID == tax.TaxId); if (taxedItem != null) { taxedItem.TaxSum += TaxServices.CalculateTax(item.Sum, tax); } else { taxedItems.Add(new TaxValue { TaxID = tax.TaxId, TaxName = tax.Name, TaxSum = TaxServices.CalculateTax(item.Sum, tax), TaxShowInPrice = tax.ShowInPrice }); } } } taxCost = taxedItems.Sum(tv => tv.TaxSum); } else { foreach (OrderItem item in order.OrderItems) { if (item.ProductID == null) continue; var t = TaxServices.GetTaxesForProduct((int)item.ProductID, billingContact, shippingContact); foreach (TaxElement tax in t) { TaxValue taxedItem = taxedItems.Find(tv => tv.TaxID == tax.TaxId); if (taxedItem != null) { taxedItem.TaxSum += TaxServices.CalculateTax(item, tax, order.OrderDiscount); } else { taxedItems.Add(new TaxValue { TaxID = tax.TaxId, TaxName = tax.Name, TaxShowInPrice = tax.ShowInPrice, TaxSum = TaxServices.CalculateTax(item, tax, order.OrderDiscount) }); } } } taxCost = order.OrderItems.Sum(oi => TaxServices.CalculateTaxesTotal(oi, shippingContact, billingContact, order.OrderDiscount)); } lvTaxes.DataSource = taxedItems; lvTaxes.DataBind(); float prodTotal = 0; if (order.OrderCertificates != null && order.OrderCertificates.Count > 0) { prodTotal = order.OrderCertificates.Sum(item => item.Sum); } else { prodTotal = order.OrderItems.Sum(oi => oi.Price * oi.Amount); } float totalDiscount = 0; totalDiscount += order.OrderDiscount > 0 ? Convert.ToSingle(Math.Round(prodTotal / 100 * order.OrderDiscount, 2)) : 0; lblTotalOrderPrice.Text = CatalogService.GetStringPrice(prodTotal, CurrencyValue, CurrencyCode); lblOrderDiscount.Text = string.Format("-{0}", CatalogService.GetStringPrice(totalDiscount, CurrencyValue, CurrencyCode)); lblOrderDiscountPercent.Text = order.OrderDiscount + @"%"; trDiscount.Visible = order.OrderDiscount != 0; liPaymentPrice.Visible = order.PaymentCost != 0; lblPaymentPrice.Text = CatalogService.GetStringPrice(order.PaymentCost, CurrencyValue, CurrencyCode); if (order.Certificate != null) { trCertificatePrice.Visible = order.Certificate.Price != 0; lblCertificatePrice.Text = string.Format("-{0}", CatalogService.GetStringPrice(order.Certificate.Price)); totalDiscount += order.Certificate.Price; } if (order.Coupon != null) { trCoupon.Visible = order.Coupon.Value != 0; switch (order.Coupon.Type) { case CouponType.Fixed: var productsPrice = order.OrderItems.Where(p => p.IsCouponApplied).Sum(p => p.Price * p.Amount); totalDiscount += productsPrice >= order.Coupon.Value ? order.Coupon.Value : productsPrice; lblCoupon.Text = String.Format("-{0} ({1})", CatalogService.GetStringPrice(totalDiscount, CurrencyValue, CurrencyCode), order.Coupon.Code); break; case CouponType.Percent: totalDiscount += order.OrderItems.Where(p => p.IsCouponApplied).Sum( p => order.Coupon.Value * p.Price / 100 * p.Amount); lblCoupon.Text = String.Format("-{0} ({1}%) ({2})", CatalogService.GetStringPrice(totalDiscount, CurrencyValue, CurrencyCode), CatalogService.FormatPriceInvariant(order.Coupon.Value), order.Coupon.Code); break; } } float sum = taxCost + prodTotal + order.ShippingCost + order.PaymentCost - totalDiscount; lblTotalPrice.Text = CatalogService.GetStringPrice(sum < 0 ? 0 : sum, CurrencyValue, CurrencyCode); }
public static CustomerContact GetContactFromSqlDataReader(SqlDataReader reader) { var contact = new CustomerContact { CustomerContactID = SQLDataHelper.GetGuid(reader, "ContactID"), Address = SQLDataHelper.GetString(reader, "Address"), City = SQLDataHelper.GetString(reader, "City"), Country = SQLDataHelper.GetString(reader, "Country"), Name = SQLDataHelper.GetString(reader, "Name"), Zip = SQLDataHelper.GetString(reader, "Zip"), RegionName = SQLDataHelper.GetString(reader, "Zone"), CountryId = SQLDataHelper.GetInt(reader, "CountryID"), RegionId = SQLDataHelper.GetNullableInt(reader, "RegionID"), CustomerGuid = SQLDataHelper.GetGuid(reader, "CustomerID") }; return contact; }
public static string GenerateHtmlOrderTable(IList<OrderItem> orderItems, Currency currency, float productsPrice, float orderDiscountPercent, OrderCoupon coupon, OrderCertificate certificate, float totalDiscount, float shippingPrice, float paymentPrice, float taxesTotal, CustomerContact billingContact, CustomerContact shippingContact) { var htmlOrderTable = new StringBuilder(); htmlOrderTable.Append("<table width=\'100%\' border=\'0\' cellspacing=\'1\' cellpadding=\'2\'>"); htmlOrderTable.Append("<tr>"); htmlOrderTable.AppendFormat("<td style=\'width:100px; text-align: center;\'> </td>"); htmlOrderTable.AppendFormat("<td style=\'width:100px; text-align: center;\'>{0}</td>", Resource.Client_OrderConfirmation_SKU); htmlOrderTable.AppendFormat("<td>{0}</td>", Resource.Client_OrderConfirmation_Name); htmlOrderTable.AppendFormat("<td>{0}</td>", Resource.Client_OrderConfirmation_CustomOptions); htmlOrderTable.AppendFormat("<td style=\'width:200px;\'>{0}</td>", Resource.Client_OrderConfirmation_Price); htmlOrderTable.AppendFormat("<td style=\'width:240px; text-align: center;\' >{0}</td>", Resource.Client_OrderConfirmation_Count); htmlOrderTable.AppendFormat("<td style=\'width:200px;\'>{0}</td>", Resource.Client_OrderConfirmation_Cost); htmlOrderTable.Append("</tr>"); // Добавление заказанных товаров foreach (var item in orderItems) { if (item.ProductID.HasValue) { htmlOrderTable.Append("<tr>"); if (item.ProductID != null) { var p = ProductService.GetProduct((int)item.ProductID); if (p != null && p.Photo.IsNotEmpty()) { htmlOrderTable.AppendFormat("<td style=\'text-align: center;\'><img src='{0}' /></td>", SettingsMain.SiteUrl.Trim('/') + '/' + FoldersHelper.GetImageProductPath(ProductImageType.Small, p.Photo, false)); } else { htmlOrderTable.AppendFormat("<td> </td>"); } } htmlOrderTable.AppendFormat("<td style=\'text-align: center;\' >{0}</td>", item.ArtNo); htmlOrderTable.AppendFormat("<td>{0}</td>", item.Name); htmlOrderTable.AppendFormat("<td>{0}{1}{2}</td>", item.Color != null ? SettingsCatalog.ColorsHeader + ": " + item.Color + "<br/>" : "", item.Size != null ? SettingsCatalog.SizesHeader + ": " + item.Size + "<br/>" : "", RenderSelectedOptions(item.SelectedOptions)); htmlOrderTable.AppendFormat("<td style=\'width:200px;\'>{0}</td>", CatalogService.GetStringPrice(item.Price, currency)); htmlOrderTable.AppendFormat("<td style=\'width:240px; text-align: center;\' >{0}</td>", item.Amount); htmlOrderTable.AppendFormat("<td style=\'width:200px;\'>{0}</td>", CatalogService.GetStringPrice(item.Price * item.Amount, currency)); htmlOrderTable.Append("</tr>"); } } // Стоимость заказа htmlOrderTable.Append("<tr>"); htmlOrderTable.AppendFormat("<td colspan=\'6\' style=\'text-align:right;\'><b>{0}:</b></td>", Resource.Client_OrderConfirmation_OrderCost); htmlOrderTable.AppendFormat("<td style=\'width:200px\'><b>{0}</b></td>", CatalogService.GetStringPrice(productsPrice, currency)); htmlOrderTable.Append("</tr>"); if (orderDiscountPercent != 0) { htmlOrderTable.Append("<tr>"); htmlOrderTable.AppendFormat("<td colspan=\'6\' style=\'text-align:right;\'><b>{0}:</b></td>", Resource.Client_OrderConfirmation_Discount); htmlOrderTable.AppendFormat("<td style=\'width:200px\'><b>-{0}</b></td>", CatalogService.GetStringDiscountPercent(productsPrice, orderDiscountPercent, false)); htmlOrderTable.Append("</tr>"); } if (certificate != null) { htmlOrderTable.Append("<tr>"); htmlOrderTable.AppendFormat("<td colspan=\'6\' style=\'text-align:right;\'><b>{0}:</b></td>", Resource.Client_OrderConfirmation_Certificate); htmlOrderTable.AppendFormat("<td style=\'width:200px\'><b>-{0}</b></td>", CatalogService.GetStringPrice(certificate.Price, currency)); htmlOrderTable.Append("</tr>"); } if (coupon != null) { htmlOrderTable.Append("<tr>"); htmlOrderTable.AppendFormat("<td colspan=\'6\' style=\'text-align:right;\'><b>{0}:</b></td>", Resource.Client_OrderConfirmation_Coupon); if (coupon.Type == CouponType.Fixed) { htmlOrderTable.AppendFormat("<td style=\'width:200px\'><b>-{0}</b></td>", CatalogService.GetStringPrice(coupon.Value, currency)); } else { htmlOrderTable.AppendFormat("<td style=\'width:200px\'><b>-{0}%</b></td>", CatalogService.FormatPriceInvariant(coupon.Value)); } htmlOrderTable.Append("</tr>"); } // Стоимость доставки htmlOrderTable.Append("<tr>"); htmlOrderTable.AppendFormat("<td colspan=\'6\' style=\'text-align:right;\'><b>{0}:</b></td>", Resource.Client_OrderConfirmation_DeliveryCost); htmlOrderTable.AppendFormat("<td style=\'width:200px\'><b>{0}</b></td>", CatalogService.GetStringPrice(shippingPrice, currency)); htmlOrderTable.Append("</tr>"); if (paymentPrice != 0) { htmlOrderTable.Append("<tr>"); htmlOrderTable.AppendFormat("<td colspan=\'6\' style=\'text-align:right;\'><b>{0}:</b></td>", paymentPrice > 0 ? Resource.Client_OrderConfirmation_PaymentCost : Resource.Client_OrderConfirmation_PaymentDiscount); htmlOrderTable.AppendFormat("<td style=\'width:200px\'><b>{0}</b></td>", CatalogService.GetStringPrice(paymentPrice, currency)); htmlOrderTable.Append("</tr>"); } // Налоги var taxTotal = TaxServices.GetTaxItems(orderItems, shippingContact, billingContact, orderDiscountPercent); if (taxTotal.Any()) { foreach (TaxElement tax in taxTotal.Keys) { htmlOrderTable.Append("<tr>"); htmlOrderTable.AppendFormat("<td colspan=\'6\' style=\'text-align:right;\'><b>{0}:</b></td>", (tax.ShowInPrice ? Resource.Core_TaxServices_Include_Tax : "") + " " + tax.Name); htmlOrderTable.AppendFormat("<td style=\'width:200px\'><b>{0}</b></td>", (tax.ShowInPrice ? "" : "+") + CatalogService.GetStringPrice(taxTotal[tax], currency)); htmlOrderTable.Append("</tr>"); } } var total = productsPrice - totalDiscount + shippingPrice + paymentPrice + taxesTotal; if (total < 0) total = 0; // Итого htmlOrderTable.Append("<tr>"); htmlOrderTable.AppendFormat("<td colspan=\'6\' style=\'text-align:right;\'><b>{0}:</b></td>", Resource.Client_OrderConfirmation_Total); htmlOrderTable.AppendFormat("<td style=\'width:200px\'><b>{0}</b></td>", CatalogService.GetStringPrice(total, currency)); htmlOrderTable.Append("</tr>"); htmlOrderTable.Append("</table>"); return htmlOrderTable.ToString(); }
public static string GetContactId(CustomerContact contact) { var res = SQLDataHelper.GetNullableGuid(SQLDataAccess.ExecuteScalar("[Customers].[sp_GetContactIDByContent]", CommandType.StoredProcedure, new SqlParameter("@Name", contact.Name), new SqlParameter("@Country", contact.Country), new SqlParameter("@City", contact.City), new SqlParameter("@Zone", contact.RegionName ?? ""), new SqlParameter("@Zip", contact.Zip ?? ""), new SqlParameter("@Address", contact.Address), new SqlParameter("@CustomerID", contact.CustomerGuid) )); return res == null ? null : res.ToString(); }