protected void Page_Load(object sender, EventArgs e) { SetMeta(string.Format("{0} - {1}", SettingsMain.ShopName, Resource.Admin_m_News_Header)); if (IsPostBack) { return; } if (CertificateId != 0) { btnOK.Text = Resource.Admin_m_News_Save; LoadCertificateById(CertificateId); } else { lblCertificateCode.Text = GiftCertificateService.GenerateCertificateCode(); } }
protected void Page_Load(object sender, EventArgs e) { Page.Title = string.Format("{0} - {1}", SettingsMain.ShopName, Resource.Admin_m_News_Header); if (IsPostBack) { return; } cboCountry.DataSource = CountryService.GetAllCountries(); cboCountry.DataBind(); //Check item count for region dropDownList List <int> ipList = CountryService.GetCountryIdByIp(Request.UserHostAddress); string countryId = ipList.Count == 1 ? ipList[0].ToString() : SettingsMain.SalerCountryId.ToString();//CountryService.GetCountryIdByIso3(Resource.Admin_Default_CountryISO3).ToString(); ICollection <Region> regions = CountryService.GetRegions(Int32.Parse(countryId)); if (cboCountry.Items.FindByValue(countryId) != null) { cboCountry.SelectedValue = countryId; } if (regions.Count > 0) { MultiViewRegion.ActiveViewIndex = 0; cboRegion.DataSource = regions; cboRegion.DataBind(); } else { MultiViewRegion.ActiveViewIndex = 1; } if (CertificateId != 0) { btnOK.Text = Resource.Admin_m_News_Save; LoadCertificateById(CertificateId); } else { lblCertificateCode.Text = GiftCertificateService.GenerateCertificateCode(); } }
protected int CreateCertificate() { if (!DataValidation()) { return(0); } var curCurrency = CurrencyService.CurrentCurrency; var certificate = new GiftCertificate { CertificateCode = GiftCertificateService.GenerateCertificateCode(), ToName = txtTo.Text, FromName = txtFrom.Text, Sum = Convert.ToDecimal(txtSum.Text), CertificateMessage = txtMessage.Text, Type = rbtnEmail.Checked ? CertificatePostType.Email : CertificatePostType.Mail, Enable = true, CurrencyCode = curCurrency.Symbol, CurrencyValue = curCurrency.Value, FromEmail = CustomerSession.CurrentCustomer.RegistredUser ? CustomerSession.CurrentCustomer.EMail : string.Empty }; if (rbtnEmail.Checked) { certificate.Email = txtEmail.Text; } else { certificate.Country = cboCountry.SelectedItem.Text; certificate.Zone = txtState.Text; certificate.City = txtCity.Text; certificate.Zip = txtZip.Text; certificate.Address = txtAdress.Text; } var certificateId = GiftCertificateService.AddCertificate(certificate); return(certificateId); }
protected int CreateCertificateOrder() { var certificate = new GiftCertificate { CertificateCode = GiftCertificateService.GenerateCertificateCode(), ToName = txtTo.Text, FromName = txtFrom.Text, Sum = Convert.ToSingle(txtSum.Text.Trim()), CertificateMessage = txtMessage.Text, Enable = true, ToEmail = txtEmail.Text }; var orderContact = new OrderContact { Address = string.Empty, City = string.Empty, Country = string.Empty, Name = string.Empty, Zip = string.Empty, Zone = string.Empty }; var taxes = TaxServices.CalculateCertificateTaxes(certificate.Sum); var taxOverPay = taxes.Where(tax => !tax.Key.ShowInPrice).Sum(tax => tax.Value); float orderSum = certificate.Sum + taxOverPay; var payment = PaymentService.GetPaymentMethod(hfPaymentMethod.Value.TryParseInt()); float paymentPrice = payment.Extracharge == 0 ? 0 : (payment.ExtrachargeType == ExtrachargeType.Fixed ? payment.Extracharge : payment.Extracharge / 100 * certificate.Sum + taxOverPay); var baseCurrency = CurrencyService.BaseCurrency; var order = new Order { OrderDate = DateTime.Now, OrderCustomer = new OrderCustomer { CustomerID = CustomerContext.CurrentCustomer.Id, Email = txtEmailFrom.Text, FirstName = CustomerContext.CurrentCustomer.FirstName, LastName = CustomerContext.CurrentCustomer.LastName, CustomerIP = HttpContext.Current.Request.UserHostAddress }, OrderCurrency = new OrderCurrency { //CurrencyCode = CurrencyService.CurrentCurrency.Iso3, //CurrencyNumCode = CurrencyService.CurrentCurrency.NumIso3, //CurrencyValue = CurrencyService.CurrentCurrency.Value, //CurrencySymbol = CurrencyService.CurrentCurrency.Symbol, //IsCodeBefore = CurrencyService.CurrentCurrency.IsCodeBefore CurrencyCode = baseCurrency.Iso3, CurrencyValue = baseCurrency.Value, CurrencySymbol = baseCurrency.Symbol, CurrencyNumCode = baseCurrency.NumIso3, IsCodeBefore = baseCurrency.IsCodeBefore }, OrderStatusId = OrderService.DefaultOrderStatus, AffiliateID = 0, ArchivedShippingName = Resource.Client_GiftCertificate_DeliveryByEmail, PaymentMethodId = Convert.ToInt32(hfPaymentMethod.Value), ArchivedPaymentName = payment.Name, PaymentDetails = null, Sum = orderSum + paymentPrice, PaymentCost = paymentPrice, OrderCertificates = new List <GiftCertificate> { certificate }, TaxCost = taxes.Sum(tax => tax.Value), Taxes = taxes.Select(tax => new OrderTax() { TaxID = tax.Key.TaxId, TaxName = tax.Key.Name, TaxShowInPrice = tax.Key.ShowInPrice, TaxSum = tax.Value }).ToList(), ShippingContact = orderContact, BillingContact = orderContact, Number = OrderService.GenerateNumber(1) }; if (order.PaymentMethod.Type == PaymentType.QIWI) { order.PaymentDetails = new PaymentDetails() { Phone = txtPhone.Text }; } OrderId = order.OrderID = OrderService.AddOrder(order); OrderNumber = order.Number = OrderService.GenerateNumber(order.OrderID); OrderService.UpdateNumber(order.OrderID, order.Number); OrderService.ChangeOrderStatus(order.OrderID, OrderService.DefaultOrderStatus); string email = txtEmailFrom.Text; string htmlOrderTable = OrderService.GenerateHtmlOrderCertificateTable(order.OrderCertificates, CurrencyService.CurrentCurrency, order.PaymentCost, order.TaxCost); var orderMailTemplate = new NewOrderMailTemplate(order.OrderID.ToString(), order.Number, email, string.Empty, order.ArchivedShippingName, order.ArchivedPaymentName, htmlOrderTable, CurrencyService.CurrentCurrency.Iso3, order.Sum.ToString(), order.CustomerComment, OrderService.GetBillingLinkHash(order)); orderMailTemplate.BuildMail(); SendMail.SendMailNow(email, orderMailTemplate.Subject, orderMailTemplate.Body, true); SendMail.SendMailNow(SettingsMail.EmailForOrders, orderMailTemplate.Subject, orderMailTemplate.Body, true); return(OrderId); }