protected void Page_Load(object sender, EventArgs e) { if (string.IsNullOrEmpty(Request["ordernumber"])) { Response.Redirect("default.aspx"); } try { int orderId = OrderService.GetOrderIdByNumber(Request["ordernumber"]); lblOrderID.Text = Resource.Admin_ViewOrder_ItemNum + orderId; if (!IsPostBack) { order = OrderService.GetOrder(orderId); if (order != null) { ordCurrency = order.OrderCurrency; lOrderDate.Text = AdvantShop.Localization.Culture.ConvertDate(order.OrderDate); if (order.OrderCertificates == null || order.OrderCertificates.Count == 0) { lblShipping.Text = @"<b>" + Resource.Admin_ViewOrder_Name + @"</b> " + order.ShippingContact.Name; lblShipping.Text += @"<br />"; lblShipping.Text += @" <b>" + Resource.Admin_ViewOrder_Country + @"</b> " + order.ShippingContact.Country + @"<br />"; lblShipping.Text += @" <b>" + Resource.Admin_ViewOrder_City + @"</b> " + order.ShippingContact.City + @"<br />"; if (order.ShippingContact.Zone != null) { lblShipping.Text += @" <b>" + Resource.Admin_ViewOrder_Zone + @"</b> " + order.ShippingContact.Zone.Trim() + @"<br />"; } if (order.ShippingContact.Zip != null) { lblShipping.Text += @" <b>" + Resource.Admin_ViewOrder_Zip + @"</b> " + order.ShippingContact.Zip.Trim() + @"<br />"; } lblShipping.Text += @" <b>" + Resource.Admin_ViewOrder_Address + @"</b> " + order.ShippingContact.Address + @"<br />"; lblBilling.Text = @"<b>" + Resource.Admin_ViewOrder_Name + @"</b> " + order.BillingContact.Name; lblBilling.Text += @"<br />"; lblBilling.Text += @" <b>" + Resource.Admin_ViewOrder_Country + @"</b> " + order.BillingContact.Country + @"<br />"; lblBilling.Text += @" <b>" + Resource.Admin_ViewOrder_City + @"</b> " + order.BillingContact.City + @"<br />"; if (order.BillingContact.Zone != null) { lblBilling.Text += @" <b>" + Resource.Admin_ViewOrder_Zone + @"</b> " + order.BillingContact.Zone.Trim() + @"<br />"; } if (order.BillingContact.Zip != null) { lblBilling.Text += @" <b>" + Resource.Admin_ViewOrder_Zip + @"</b> " + order.BillingContact.Zip.Trim() + @"<br />"; } lblBilling.Text += @" <b>" + Resource.Admin_ViewOrder_Address + @"</b> " + order.BillingContact.Address + @"<br />"; } else { trBilling.Visible = false; trShipping.Visible = false; } lblShippingMethod.Text = @"<b>" + order.ArchivedShippingName + @"</b>"; if (order.OrderPickPoint != null) { lblShippingMethod.Text += @"</br><b>" + order.OrderPickPoint.PickPointAddress + @"</b>"; } lblPaymentType.Text = @"<b>" + order.PaymentMethodName + @"</b>"; // ------------------------------------------------------------------------------------ float productPrice = order.OrderCertificates != null && order.OrderCertificates.Count > 0 ? order.OrderCertificates.Sum(item => item.Sum) : order.OrderItems.Sum(item => item.Amount*item.Price); float totalDiscount = order.OrderDiscount; lblProductPrice.Text = CatalogService.GetStringPrice(productPrice, ordCurrency.CurrencyValue, ordCurrency.CurrencyCode); trDiscount.Visible = order.OrderDiscount != 0; lblOrderDiscount.Text = string.Format("-{0}", CatalogService.GetStringDiscountPercent(productPrice, totalDiscount, ordCurrency .CurrencyValue, order .OrderCurrency .CurrencySymbol, order .OrderCurrency .IsCodeBefore, CurrencyService .CurrentCurrency .PriceFormat, false)); if (order.Certificate != null) { trCertificate.Visible = true; lblCertificate.Text = string.Format("-{0}", CatalogService.GetStringPrice(order.Certificate.Price, ordCurrency.CurrencyValue, ordCurrency.CurrencyCode)); } else { trCertificate.Visible = false; } if (order.Coupon != null) { trCoupon.Visible = true; switch (order.Coupon.Type) { case CouponType.Fixed: lblCoupon.Text = String.Format("-{0} ({1})", CatalogService.GetStringPrice(order.Coupon.Value, ordCurrency.CurrencyValue, ordCurrency.CurrencyCode), order.Coupon.Code); break; case CouponType.Percent: lblCoupon.Text = String.Format("-{0} ({1}%) ({2})", CatalogService.GetStringPrice(productPrice * order.Coupon.Value / 100, ordCurrency.CurrencyValue, ordCurrency.CurrencyCode), CatalogService.FormatPriceInvariant(order.Coupon.Value), order.Coupon.Code); break; } } else { trCoupon.Visible = false; } lblShippingPrice.Text = string.Format("+{0}", CatalogService.GetStringPrice(order.ShippingCost, order.OrderCurrency .CurrencyValue, order.OrderCurrency .CurrencyCode)); PaymentRow.Visible = order.PaymentCost != 0; lblPaymentPrice.Text = string.Format("+{0}", CatalogService.GetStringPrice(order.PaymentCost, order.OrderCurrency .CurrencyValue, order.OrderCurrency .CurrencyCode)); List<TaxValue> taxedItems = TaxServices.GetOrderTaxes(order.OrderID); literalTaxCost.Text = TaxServices.BuildTaxTable(taxedItems, order.OrderCurrency.CurrencyValue, order.OrderCurrency.CurrencyCode, Resource.Admin_ViewOrder_Taxes); lblTotalPrice.Text = CatalogService.GetStringPrice(order.Sum, order.OrderCurrency.CurrencyValue, order.OrderCurrency.CurrencyCode); // ------------------------------------------------------------------------------------ if (string.IsNullOrEmpty(order.CustomerComment)) { lblUserComments.Visible = false; } else { lblUserComments.Text = Resource.Client_PrintOrder_YourComment + @" <br /> " + order.CustomerComment; lblUserComments.Visible = true; } if (order.OrderCertificates == null || order.OrderCertificates.Count == 0) { lvOrderItems.DataSource = order.OrderItems; lvOrderItems.DataBind(); } else { lvOrderGiftCertificates.DataSource = order.OrderCertificates; lvOrderGiftCertificates.DataBind(); } mapAdress = order.ShippingContact.Country + "," + order.ShippingContact.Zone + "," + order.ShippingContact.City + "," + order.ShippingContact.Address; } } } catch (Exception ex) { Debug.LogError(ex); } }
protected string GetPriceFormat(float price, OrderCurrency currency) { return (price/currency.CurrencyValue*Bill.CurrencyValue).ToString("####0.00").Replace(",", "."); }
private static void AddOrderCurrency(int orderId, OrderCurrency orderCurrency) { SQLDataAccess.ExecuteNonQuery( "INSERT INTO [Order].[OrderCurrency] (OrderID, CurrencyCode, CurrencyNumCode, CurrencyValue, CurrencySymbol, IsCodeBefore ) VALUES (@OrderID, @CurrencyCode, @CurrencyNumCode, @CurrencyValue, @CurrencySymbol, @IsCodeBefore)", CommandType.Text, new SqlParameter("@OrderID", orderId), new SqlParameter("@CurrencyCode", orderCurrency.CurrencyCode), new SqlParameter("@CurrencyNumCode", orderCurrency.CurrencyNumCode), new SqlParameter("@CurrencyValue", orderCurrency.CurrencyValue), new SqlParameter("@CurrencySymbol", orderCurrency.CurrencySymbol), new SqlParameter("@IsCodeBefore", orderCurrency.IsCodeBefore)); }
private static string BuildTaxTable(ICollection<TaxValue> taxes, OrderCurrency currency) { var sb = new StringBuilder(); if (taxes.Count != 0) { foreach (var tax in taxes) { sb.Append( "<tr bgcolor=\"white\" runat=\"server\" id=\"rowNDS\"><td align=\"right\" width=\"82%\"><font class=\"sc\">"); sb.Append((tax.TaxShowInPrice ? Resource.Core_TaxServices_Include_Tax : "") + " " + tax.TaxName); sb.Append(":</font></td><td align=\"right\" width=\"18%\"><font class=\"sc\"><b>"); sb.Append(CatalogService.GetStringPrice(tax.TaxSum, currency.CurrencyValue, currency.CurrencyCode)); sb.Append("</b></font></td></tr>"); } } else { sb.Append( "<tr bgcolor=\"white\" runat=\"server\" id=\"rowNDS\"><td align=\"right\" width=\"82%\"><font class=\"sc\">"); sb.Append(Resource.Client_Bill2_NDSAlreadyIncluded); sb.Append("</font></td><td align=\"right\" width=\"18%\"><font class=\"sc\"><b>"); sb.Append("Без НДС"); sb.Append("</b></font></td></tr>"); } return sb.ToString(); }