protected void grid_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "DeleteCertificate") { GiftCertificateService.DeleteCertificateById(Convert.ToInt32(e.CommandArgument)); } }
protected void Page_Load(object sender, EventArgs e) { SetMeta(string.Format("{0} - {1}", SettingsMain.ShopName, Resource.Admin_CertificateAdmin_Header)); if (string.IsNullOrEmpty(Request["certificatecode"])) { Response.Redirect("default.aspx"); } try { if (!IsPostBack) { var certificate = GiftCertificateService.GetCertificateByCode(Request["certificatecode"]); if (certificate != null) { lblCertificateID.Text = certificate.CertificateId.ToString(); lblCertificateCode.Text = certificate.CertificateCode; lblOrderNumber.Text = certificate.ApplyOrderNumber; lblSum.Text = certificate.Sum.ToString(); lblFrom.Text = certificate.FromName; lblTo.Text = certificate.ToName; lblUserMessage.Text = certificate.CertificateMessage; lblEmail.Text = certificate.ToEmail; } } } catch (Exception ex) { Debug.LogError(ex); } }
protected void SaveCertificate() { if (!DataValidation()) { return; } try { Certificate.CertificateId = CertificateId; Certificate.CertificateCode = lblCertificateCode.Text; Certificate.CertificateMessage = txtMessage.Text; Certificate.FromName = txtFromName.Text; Certificate.ToName = txtToName.Text; Certificate.Used = chkUsed.Checked; Certificate.Enable = chkEnable.Checked; Certificate.Sum = Convert.ToSingle(txtSum.Text); Certificate.CertificateMessage = txtMessage.Text; Certificate.ToEmail = txtEmail.Text; GiftCertificateService.UpdateCertificateById(Certificate); OrderService.PayOrder(Certificate.OrderId, chkPaid.Checked); } catch (Exception ex) { MsgErr(ex.Message + " SaveSertificate error"); Debug.LogError(ex); } }
protected void Page_PreRender(object sender, EventArgs e) { if (grid.UpdatedRow != null) { decimal sum; if (decimal.TryParse(grid.UpdatedRow["Sum"], out sum)) { var certificate = GiftCertificateService.GetCertificateByID(Convert.ToInt32(grid.UpdatedRow["ID"])); if (!certificate.Paid && Convert.ToBoolean(grid.UpdatedRow["Paid"]) && !CustomerSession.CurrentCustomer.IsVirtual) { GiftCertificateService.SendCertificateMails(certificate); } certificate.Sum = sum; certificate.Enable = Convert.ToBoolean(grid.UpdatedRow["Enable"]); certificate.Type = (CertificatePostType)int.Parse(grid.UpdatedRow["Type"]); certificate.Used = Convert.ToBoolean(grid.UpdatedRow["Used"]); certificate.Paid = Convert.ToBoolean(grid.UpdatedRow["Paid"]); GiftCertificateService.UpdateCertificateById(certificate); } } DataTable data = _paging.PageItems; while (data.Rows.Count < 1 && _paging.CurrentPageIndex > 1) { _paging.CurrentPageIndex--; data = _paging.PageItems; } var clmn = new DataColumn("IsSelected", typeof(bool)) { DefaultValue = _inverseSelection }; data.Columns.Add(clmn); if ((_selectionFilter != null) && (_selectionFilter.Values != null)) { for (int i = 0; i <= data.Rows.Count - 1; i++) { int intIndex = i; if (Array.Exists(_selectionFilter.Values, c => c == (data.Rows[intIndex]["ID"]).ToString())) { data.Rows[i]["IsSelected"] = !_inverseSelection; } } } if (data.Rows.Count < 1) { goToPage.Visible = false; } grid.DataSource = data; grid.DataBind(); pageNumberer.PageCount = _paging.PageCount; lblFound.Text = _paging.TotalRowsCount.ToString(); }
protected void Page_PreRender(object sender, EventArgs e) { GiftCertificatePaymentMethods = new List <int>(GiftCertificateService.GetCertificatePaymentMethodsID()); lvPaymentMethods.DataSource = PaymentService.GetAllPaymentMethods(true).Where(payment => payment.Type != PaymentType.GiftCertificate); lvPaymentMethods.DataBind(); GiftCertificateTaxes = TaxServices.GetCertificateTaxes().Select(tax => tax.TaxId).ToList(); lvTaxes.DataSource = TaxServices.GetTaxes(); lvTaxes.DataBind(); }
protected void Page_PreRender(object sender, EventArgs e) { if (grid.UpdatedRow != null) { var certificate = GiftCertificateService.GetCertificateByID(SQLDataHelper.GetInt(grid.UpdatedRow["ID"])); //if (!certificate.Paid && SQLDataHelper.GetBoolean(grid.UpdatedRow["Paid"]) && !CustomerContext.CurrentCustomer.IsVirtual) //{ // GiftCertificateService.SendCertificateMails(certificate); //} OrderService.PayOrder(certificate.OrderId, SQLDataHelper.GetBoolean(grid.UpdatedRow["Paid"])); certificate.Enable = SQLDataHelper.GetBoolean(grid.UpdatedRow["Enable"]); certificate.Used = SQLDataHelper.GetBoolean(grid.UpdatedRow["Used"]); GiftCertificateService.UpdateCertificateById(certificate); } DataTable data = _paging.PageItems; while (data.Rows.Count < 1 && _paging.CurrentPageIndex > 1) { _paging.CurrentPageIndex--; data = _paging.PageItems; } var clmn = new DataColumn("IsSelected", typeof(bool)) { DefaultValue = _inverseSelection }; data.Columns.Add(clmn); if ((_selectionFilter != null) && (_selectionFilter.Values != null)) { for (int i = 0; i <= data.Rows.Count - 1; i++) { int intIndex = i; if (Array.Exists(_selectionFilter.Values, c => c == (data.Rows[intIndex]["ID"]).ToString())) { data.Rows[i]["IsSelected"] = !_inverseSelection; } } } if (data.Rows.Count < 1) { goToPage.Visible = false; } grid.DataSource = data; grid.DataBind(); pageNumberer.PageCount = _paging.PageCount; lblFound.Text = _paging.TotalRowsCount.ToString(); }
private Order DoCreateOrder() { var shoppingCart = ShoppingCartService.CurrentShoppingCart; if (shoppingCart.GetHashCode() != PageData.OrderConfirmationData.CheckSum || !shoppingCart.HasItems) { Response.Redirect("shoppingcart.aspx"); return(null); } if (PageData.OrderConfirmationData.UserType == EnUserType.JustRegistredUser) { RegistrationNow(); } if (PageData.OrderConfirmationData.UserType == EnUserType.RegisteredUserWithoutAddress) { UpdateCustomerContact(); } var order = CreateOrder(shoppingCart); SendOrderMail(order, shoppingCart); var certificate = shoppingCart.Certificate; if (certificate != null) { certificate.ApplyOrderNumber = order.Number; certificate.Used = true; certificate.Enable = true; GiftCertificateService.DeleteCustomerCertificate(certificate.CertificateId); GiftCertificateService.UpdateCertificateById(certificate); } var coupon = shoppingCart.Coupon; if (coupon != null && shoppingCart.TotalPrice >= coupon.MinimalOrderPrice) { coupon.ActualUses += 1; CouponService.UpdateCoupon(coupon); CouponService.DeleteCustomerCoupon(coupon.CouponID); } ShoppingCartService.ClearShoppingCart(ShoppingCartType.ShoppingCart, PageData.OrderConfirmationData.Customer.Id); ShoppingCartService.ClearShoppingCart(ShoppingCartType.ShoppingCart, CustomerContext.CustomerId); ShippingManager.CurrentShippingRates.Clear(); OrderConfirmationService.Delete(CustomerContext.CustomerId); return(order); }
protected void grid_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "DeleteCertificate") { GiftCertificateService.DeleteCertificateById(SQLDataHelper.GetInt(e.CommandArgument)); } if (e.CommandName == "SendCertificate") { GiftCertificateService.SendCertificateMails( GiftCertificateService.GetCertificateByID(SQLDataHelper.GetInt(e.CommandArgument))); } }
protected void CreateCertificate() { if (!DataValidation()) { return; } MsgErr(true); try { var curCurrency = CurrencyService.CurrentCurrency; Certificate = new GiftCertificate { CertificateCode = lblCertificateCode.Text, FromName = txtFromName.Text, ToName = txtToName.Text, Paid = chkPaid.Checked, Used = chkUsed.Checked, Enable = chkEnable.Checked, Type = rbtnEmail.Checked ? CertificatePostType.Email : CertificatePostType.Mail, Sum = Convert.ToDecimal(txtSum.Text), CertificateMessage = txtMessage.Text, CurrencyCode = curCurrency.Symbol, CurrencyValue = curCurrency.Value, FromEmail = txtFromEmail.Text }; if (rbtnEmail.Checked) { Certificate.Email = txtEmail.Text; } else { Certificate.Country = cboCountry.SelectedItem.Text; Certificate.Zone = MultiViewRegion.ActiveViewIndex == 0 ? cboRegion.SelectedItem.Text : txtState.Text; Certificate.City = txtCity.Text; Certificate.Zip = txtZip.Text; Certificate.Address = txtAddress.Text; } if (Certificate.Paid && !CustomerSession.CurrentCustomer.IsVirtual) { GiftCertificateService.SendCertificateMails(Certificate); } GiftCertificateService.AddCertificate(Certificate); } catch (Exception ex) { MsgErr(ex.Message + " Create Certificate error"); Debug.LogError(ex); } }
protected void SaveCertificate() { if (!DataValidation()) { return; } try { // var certificate = GiftCertificateService.GetCertificateByID(CertificateId); bool isPaid = !Certificate.Paid && chkPaid.Checked; Certificate.CertificateId = CertificateId; Certificate.CertificateCode = lblCertificateCode.Text; Certificate.FromName = txtFromName.Text; Certificate.ToName = txtToName.Text; Certificate.Paid = chkPaid.Checked; Certificate.Used = chkUsed.Checked; Certificate.Enable = chkEnable.Checked; Certificate.Type = (rbtnEmail.Checked ? CertificatePostType.Email : CertificatePostType.Mail); Certificate.Sum = Convert.ToDecimal(txtSum.Text); Certificate.FromEmail = txtFromEmail.Text; if (rbtnEmail.Checked) { Certificate.Email = txtEmail.Text; } else { Certificate.Country = cboCountry.SelectedItem.Text; Certificate.Zone = MultiViewRegion.ActiveViewIndex == 0 ? cboRegion.SelectedItem.Text : txtState.Text; Certificate.City = txtCity.Text; Certificate.Zip = txtZip.Text; Certificate.Address = txtAddress.Text; } if (isPaid) { GiftCertificateService.SendCertificateMails(Certificate); } GiftCertificateService.UpdateCertificateById(Certificate); } catch (Exception ex) { MsgErr(ex.Message + " SaveSertificate error"); Debug.LogError(ex); } }
protected void LoadCertificateById(int certificateId) { Certificate = GiftCertificateService.GetCertificateByID(certificateId); if (Certificate == null) { MsgErr("Certificate with this ID does not exist"); return; } lblCertificateCode.Text = Certificate.CertificateCode; txtFromName.Text = Certificate.FromName; txtToName.Text = Certificate.ToName; txtSum.Text = Certificate.Sum.ToString("#0.00"); chkPaid.Checked = Certificate.Paid; chkUsed.Checked = Certificate.Used; rbtnEmail.Checked = Certificate.Type == CertificatePostType.Email; rbtnMail.Checked = Certificate.Type == CertificatePostType.Mail; chkEnable.Checked = Certificate.Enable; txtMessage.Text = Certificate.CertificateMessage; txtFromEmail.Text = Certificate.FromEmail; if (Certificate.Type == CertificatePostType.Mail) { rbtnMail.Checked = true; cboCountry.SelectedItem.Selected = false; cboCountry.Items.FindByText(Certificate.Country).Selected = true; var region = cboRegion.Items.FindByText(Certificate.Zone); if (region != null) { MultiViewRegion.ActiveViewIndex = 0; cboRegion.SelectedItem.Selected = false; region.Selected = true; } else { MultiViewRegion.ActiveViewIndex = 1; txtState.Text = Certificate.Zone; } txtCity.Text = Certificate.City; txtZip.Text = Certificate.Zip; txtAddress.Text = Certificate.Address; } else { rbtnEmail.Checked = true; txtEmail.Text = Certificate.Email; } }
protected void Page_Load(object sender, EventArgs e) { if (string.IsNullOrEmpty(Request["certificatecode"])) { Response.Redirect("default.aspx"); } try { if (!IsPostBack) { var certificate = GiftCertificateService.GetCertificateByCode(Request["certificatecode"]); if (certificate != null) { lblCertificateID.Text = certificate.CertificateId.ToString(); lblCertificateCode.Text = certificate.CertificateCode; // lblCertificateStatus.Text = certificate.Status.ToString(); lblOrderNumber.Text = certificate.OrderNumber; lblSum.Text = certificate.Sum.ToString(); lblFrom.Text = certificate.FromName; lblTo.Text = certificate.ToName; lblUserMessage.Text = certificate.CertificateMessage; if (certificate.Type == CertificatePostType.Email) { pnlMail.Visible = false; pnlEmail.Visible = true; lblEmail.Text = certificate.Email; } else { pnlMail.Visible = true; pnlEmail.Visible = false; lblAddress.Text = string.Format("{0}, {1}, {2}, {3}, {4}", certificate.Country, certificate.Zone, certificate.City, certificate.Address, certificate.Zip); } } } } catch (Exception ex) { Debug.LogError(ex); } }
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 LoadCertificateById(int certificateId) { Certificate = GiftCertificateService.GetCertificateByID(certificateId); if (Certificate == null) { MsgErr("Certificate with this ID does not exist"); return; } lblCertificateCode.Text = Certificate.CertificateCode; txtFromName.Text = Certificate.FromName; txtToName.Text = Certificate.ToName; txtSum.Text = Certificate.Sum.ToString("#0.00"); chkUsed.Checked = Certificate.Used; chkEnable.Checked = Certificate.Enable; txtMessage.Text = Certificate.CertificateMessage; txtEmail.Text = Certificate.ToEmail; chkPaid.Checked = OrderService.IsPaidOrder(Certificate.OrderId); }
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(); } }
public object GetGiftCertificateByClaimCode(string claimCode) { IGiftCertificateService giftCertificateService = new GiftCertificateService(new GiftCertificateRepository()); GiftCertificate giftCertificate = null; var message = string.Empty; var isSucess = false; try { giftCertificate = giftCertificateService.GetGiftCertificatebyClaimCode(claimCode); isSucess = true; } catch (Exception ex) { message = ex.Message; } return(new { Data = giftCertificate, Message = message, IsSuccess = isSucess }); }
protected void lbDeleteSelected_Click(object sender, EventArgs e) { if ((_selectionFilter != null) && (_selectionFilter.Values != null)) { if (!_inverseSelection) { foreach (var id in _selectionFilter.Values) { GiftCertificateService.DeleteCertificateById(Convert.ToInt32(id)); } } else { var itemsIds = _paging.ItemsIds <int>("CertificateID as ID"); foreach (var id in itemsIds.Where(certificateId => !_selectionFilter.Values.Contains(certificateId.ToString()))) { GiftCertificateService.DeleteCertificateById(id); } } } }
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 void btnSaveClick(object sender, EventArgs e) { MsgErr(true); try { var PaymentMethodsList = new List <int>(); foreach (ListViewItem item in lvPaymentMethods.Items) { int id; if (((CheckBox)item.FindControl("ckbActive")).Checked && Int32.TryParse(((HiddenField)item.FindControl("hfPaymentId")).Value, out id)) { PaymentMethodsList.Add(id); } } GiftCertificateService.SaveCertificatePaymentMethods(PaymentMethodsList); var TaxesList = new List <int>(); foreach (ListViewItem item in lvTaxes.Items) { int id; if (((CheckBox)item.FindControl("ckbActive")).Checked && Int32.TryParse(((HiddenField)item.FindControl("hfTaxId")).Value, out id)) { TaxesList.Add(id); } } TaxServices.SaveCertificateTaxes(TaxesList); MsgErr(Resources.Resource.Admin_Certificates_Save, true); } catch (Exception ex) { Debug.LogError(ex); MsgErr("Error: " + ex.Message, false); } }
public string Parse(int certificateId, int templateId) { IUnitOfWork repository = new UnitOfWork(); LetterTemplateService letterService = new LetterTemplateService(); GiftCertificateService giftService = new GiftCertificateService(repository); BLL.GiftCertificate gift = giftService.FindById(certificateId); BLL.LetterTemplate template = letterService.FindById(templateId); string raw = HttpContext.Current.Server.HtmlDecode(template.Template); string tableString = string.Empty; int startIndex = raw.IndexOf("<table id=\"detail\"");//("<table id=\"detail\" style=\"width:100%;\">") if (startIndex != -1) { int lastIndex = raw.IndexOf("</table>", startIndex) + 8; if (lastIndex != -1) { int length = lastIndex - startIndex; tableString = raw.Substring(startIndex, length); } } if (@tableString != "") { raw = raw.Replace(@tableString, "{tablePlaceHolder}"); } raw = PopulateCertificate(raw, gift); string populatedTable = string.Empty; if (@tableString != "") { populatedTable = PopulateTableData(gift.GiftCertificateDetails.ToList(), tableString.Replace(" ", "")); } string finalString = raw.Replace("{tablePlaceHolder}", populatedTable); return(finalString); }
protected void Page_Load(object sender, EventArgs e) { Logo.ImgSource = FoldersHelper.GetPath(FolderType.Pictures, SettingsMain.LogoImageName, false); if (Request["certificatecode"].IsNotEmpty()) { GiftCertificate certificate = GiftCertificateService.GetCertificateByCode(Request["certificatecode"]); if (certificate == null) { return; } lblCertificateCode.Text = certificate.CertificateCode; lblToName.Text = certificate.ToName; lblFromName.Text = certificate.FromName; lblMessage.Text = certificate.CertificateMessage; lblSum.Text = CatalogService.GetStringPrice(certificate.Sum); } else { lblCertificateCode.Text = "0000-0000-0000"; } }
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); }
private Order DoCreateOrder() { var shoppingCart = ShoppingCartService.CurrentShoppingCart; if (shoppingCart.GetHashCode() != PageData.OrderConfirmationData.CheckSum || !shoppingCart.HasItems) { Redirect("shoppingcart.aspx"); return(null); } if (PageData.OrderConfirmationData.UserType == EnUserType.JustRegistredUser) { RegistrationNow(); } var ord = CreateOrder(shoppingCart); var paymentMethod = PaymentService.GetPaymentMethod(ord.PaymentMethodId); string email = PageData.OrderConfirmationData.Customer.EMail; string htmlOrderTable = OrderService.GenerateHtmlOrderTable(ord.OrderItems, CurrencyService.CurrentCurrency, shoppingCart.TotalPrice, shoppingCart.DiscountPercentOnTotalPrice, ord.Coupon, ord.Certificate, shoppingCart.TotalDiscount, ord.ShippingCost, PageData.OrderConfirmationData.TaxesTotal, PageData.OrderConfirmationData.BillingContact, PageData.OrderConfirmationData.ShippingContact); // declare class to collect info about what was buy var googleAnalystic = new GoogleAnalyticsString(); var trans = new GoogleAnalyticsTrans { OrderId = ord.OrderID.ToString(), Affiliation = SettingsMain.ShopName, Total = shoppingCart.TotalPrice.ToString("F2", System.Globalization.CultureInfo.InvariantCulture), Tax = (PageData.OrderConfirmationData.TaxesTotal).ToString("F2", System.Globalization.CultureInfo.InvariantCulture), Shipping = ord.ShippingCost.ToString("F2", System.Globalization.CultureInfo.InvariantCulture), City = string.Empty, State = string.Empty, Country = string.Empty, }; googleAnalystic.Trans = trans; googleAnalystic.Items = GetListItemForGoogleAnalytics(shoppingCart, ord.OrderID.ToString()); ltGaECommerce.Text = googleAnalystic.GetGoogleAnalyticsEComerceString(); // Build a new mail var customerSb = new StringBuilder(); customerSb.AppendFormat(Resource.Client_Registration_Name + ": {0}<br/>", PageData.OrderConfirmationData.Customer.FirstName); customerSb.AppendFormat(Resource.Client_Registration_Surname + ": {0}<br/>", PageData.OrderConfirmationData.Customer.LastName); customerSb.AppendFormat(Resource.Client_Registration_Phone + ": {0}<br/>", PageData.OrderConfirmationData.Customer.Phone); customerSb.AppendFormat(Resource.Client_Registration_Country + ": {0}<br/>", PageData.OrderConfirmationData.ShippingContact.Country); customerSb.AppendFormat(Resource.Client_Registration_State + ": {0}<br/>", PageData.OrderConfirmationData.ShippingContact.RegionName); customerSb.AppendFormat(Resource.Client_Registration_City + ": {0}<br/>", PageData.OrderConfirmationData.ShippingContact.City); customerSb.AppendFormat(Resource.Client_Registration_Zip + ": {0}<br/>", PageData.OrderConfirmationData.ShippingContact.Zip); customerSb.AppendFormat(Resource.Client_Registration_Address + ": {0}<br/>", string.IsNullOrEmpty(PageData.OrderConfirmationData.ShippingContact.Address) ? Resource.Client_OrderConfirmation_NotDefined : PageData.OrderConfirmationData.ShippingContact.Address); customerSb.AppendFormat("Email: {0}<br/>", PageData.OrderConfirmationData.Customer.EMail); string htmlMessage = SendMail.BuildMail(new ClsMailParamOnNewOrder { CustomerContacts = customerSb.ToString(), PaymentType = PageData.OrderConfirmationData.SelectPaymentName, ShippingMethod = PageData.OrderConfirmationData.SelectShippingName, CurrentCurrencyCode = CurrencyService.CurrentCurrency.Iso3, TotalPrice = ord.Sum.ToString(), Comments = ord.CustomerComment, Email = email, OrderTable = htmlOrderTable, OrderID = ord.OrderID.ToString(), Number = ord.Number }); if (!CustomerSession.CurrentCustomer.IsVirtual) { if (paymentMethod != null) { SendMail.SendMailNow(email, Resource.Client_OrderConfirmation_ReceivedOrder + " " + ord.OrderID, htmlMessage, true); SendMail.SendMailNow(SettingsMail.EmailForOrders, Resource.Client_OrderConfirmation_ReceivedOrder + " " + ord.OrderID, htmlMessage, true); } else { htmlMessage += " ERROR: \'" + "\'"; SendMail.SendMailNow(SettingsMail.EmailForOrders, Resource.Client_OrderConfirmation_OrderError + " " + ord.OrderID, htmlMessage, true); } } var certificate = shoppingCart.Certificate; if (certificate != null) { certificate.OrderNumber = ord.Number; certificate.Used = true; certificate.Enable = true; GiftCertificateService.DeleteCustomerCertificate(certificate.CertificateId); GiftCertificateService.UpdateCertificateById(certificate); } var coupon = shoppingCart.Coupon; if (coupon != null && shoppingCart.TotalPrice >= coupon.MinimalOrderPrice) { coupon.ActualUses += 1; CouponService.UpdateCoupon(coupon); CouponService.DeleteCustomerCoupon(coupon.CouponID); } ShoppingCartService.ClearShoppingCart(ShoppingCartType.ShoppingCart, PageData.OrderConfirmationData.Customer.Id); ShoppingCartService.ClearShoppingCart(ShoppingCartType.ShoppingCart, CustomerSession.CustomerId); return(ord); }