public static void SendCertificateMails(GiftCertificate certificate)
        {
            var certificateMailTemplate = new CertificateMailTemplate(certificate.CertificateCode, certificate.FromName,
                                                                      certificate.ToName,
                                                                      CatalogService.GetStringPrice(certificate.Sum),
                                                                      certificate.CertificateMessage);

            certificateMailTemplate.BuildMail();

            SendMail.SendMailNow(certificate.ToEmail, certificateMailTemplate.Subject, certificateMailTemplate.Body, true);
            SendMail.SendMailNow(SettingsMail.EmailForOrders, certificateMailTemplate.Subject, certificateMailTemplate.Body, true);
        }
Пример #2
0
 public static int AddCertificate(GiftCertificate certificate)
 {
     return SQLDataAccess.ExecuteScalar<int>("[Order].[sp_AddCertificate]", CommandType.StoredProcedure,
                                               new SqlParameter("@CertificateCode", certificate.CertificateCode),
                                               new SqlParameter("@ApplyOrderNumber", String.IsNullOrEmpty(certificate.ApplyOrderNumber) ? (object)DBNull.Value : certificate.ApplyOrderNumber),
                                               new SqlParameter("@OrderID", certificate.OrderId),
                                               new SqlParameter("@FromName", certificate.FromName),
                                               new SqlParameter("@ToName", certificate.ToName),
                                               new SqlParameter("@Used", certificate.Used),
                                               new SqlParameter("@Enable", certificate.Enable),
                                               new SqlParameter("@Sum", certificate.Sum),
                                               new SqlParameter("@Message", certificate.CertificateMessage),
                                               new SqlParameter("@ToEmail", certificate.ToEmail)
         );
 }
 public static void UpdateCertificateById(GiftCertificate certificate)
 {
     SQLDataAccess.ExecuteNonQuery("[Order].[sp_UpdateCertificateById]", CommandType.StoredProcedure,
                                   new SqlParameter("@CertificateId", certificate.CertificateId),
                                   new SqlParameter("@CertificateCode", certificate.CertificateCode),
                                   new SqlParameter("@OrderID", certificate.OrderId),
                                   new SqlParameter("@ApplyOrderNumber", certificate.ApplyOrderNumber),
                                   new SqlParameter("@FromName", certificate.FromName),
                                   new SqlParameter("@ToName", certificate.ToName),
                                   new SqlParameter("@Used", certificate.Used),
                                   new SqlParameter("@Enable", certificate.Enable),
                                   new SqlParameter("@Sum", certificate.Sum),
                                   new SqlParameter("@Message", certificate.CertificateMessage),
                                   new SqlParameter("@ToEmail", certificate.ToEmail));
 }
 public static int AddCertificate(GiftCertificate certificate)
 {
     return(SQLDataAccess.ExecuteScalar <int>("[Order].[sp_AddCertificate]", CommandType.StoredProcedure,
                                              new SqlParameter("@CertificateCode", certificate.CertificateCode),
                                              new SqlParameter("@ApplyOrderNumber", String.IsNullOrEmpty(certificate.ApplyOrderNumber) ? (object)DBNull.Value : certificate.ApplyOrderNumber),
                                              new SqlParameter("@OrderID", certificate.OrderId),
                                              new SqlParameter("@FromName", certificate.FromName),
                                              new SqlParameter("@ToName", certificate.ToName),
                                              new SqlParameter("@Used", certificate.Used),
                                              new SqlParameter("@Enable", certificate.Enable),
                                              new SqlParameter("@Sum", certificate.Sum),
                                              new SqlParameter("@Message", certificate.CertificateMessage),
                                              new SqlParameter("@ToEmail", certificate.ToEmail)
                                              ));
 }
Пример #5
0
        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);
        }
Пример #6
0
        protected bool CreateCertificateOrder()
        {
            var certificate = new GiftCertificate
                {
                    CertificateCode = GiftCertificateService.GenerateCertificateCode(),
                    ToName = txtTo.Text,
                    FromName = txtFrom.Text,
                    Sum = Convert.ToSingle(txtSum.Text.Trim()) * CurrencyService.CurrentCurrency.Value,
                    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
                };

            float taxTotalPrice = 0;
            var orderTaxes = new List<TaxValue>();
            foreach (var taxId in GiftCertificateService.GetCertificateTaxesId())
            {
                var tax = TaxServices.GetTax(taxId);
                orderTaxes.Add(new TaxValue
                    {
                        TaxID = tax.TaxId,
                        TaxName = tax.Name,
                        TaxShowInPrice = tax.ShowInPrice,
                        TaxSum = tax.FederalRate
                    });
                taxTotalPrice += TaxServices.CalculateTax(certificate.Sum, tax);
            }

            float orderSum = certificate.Sum + taxTotalPrice;

            var payment = PaymentService.GetPaymentMethod(hfPaymentMethod.Value.TryParseInt());
            float paymentPrice = payment.Extracharge == 0 ? 0 : (payment.ExtrachargeType == ExtrachargeType.Fixed ? payment.Extracharge : payment.Extracharge / 100 * certificate.Sum + taxTotalPrice);

            var order = new Order
                {
                    OrderDate = DateTime.Now,
                    OrderCustomer = new OrderCustomer
                        {
                            CustomerID = CustomerSession.CurrentCustomer.Id,
                            Email = txtEmailFrom.Text,
                            FirstName = CustomerSession.CurrentCustomer.FirstName,
                            LastName = CustomerSession.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
                        },
                    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 = taxTotalPrice,
                    Taxes = orderTaxes,
                    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);

            string htmlMessage = SendMail.BuildMail(new ClsMailParamOnNewOrder
            {
                CustomerContacts = string.Empty,
                PaymentType = order.ArchivedPaymentName,
                ShippingMethod = order.ArchivedShippingName,
                CurrentCurrencyCode = CurrencyService.CurrentCurrency.Iso3,
                TotalPrice = order.Sum.ToString(),
                Comments = order.CustomerComment,
                Email = email,
                OrderTable = htmlOrderTable,
                OrderID = order.OrderID.ToString(),
                Number = order.Number
            });

            SendMail.SendMailNow(email, Resource.Client_OrderConfirmation_ReceivedOrder + " " + order.OrderID, htmlMessage, true);
            SendMail.SendMailNow(SettingsMail.EmailForOrders, Resource.Client_OrderConfirmation_ReceivedOrder + " " + order.OrderID, htmlMessage, true);

            return OrderId != 0;
        }
Пример #7
0
 public static void UpdateCertificateById(GiftCertificate certificate)
 {
     SQLDataAccess.ExecuteNonQuery("[Order].[sp_UpdateCertificateById]", CommandType.StoredProcedure,
         new SqlParameter("@CertificateId", certificate.CertificateId),
         new SqlParameter("@CertificateCode", certificate.CertificateCode),
         new SqlParameter("@OrderID", certificate.OrderId),
         new SqlParameter("@ApplyOrderNumber", certificate.ApplyOrderNumber),
         new SqlParameter("@FromName", certificate.FromName),
         new SqlParameter("@ToName", certificate.ToName),
         new SqlParameter("@Used", certificate.Used),
         new SqlParameter("@Enable", certificate.Enable),
         new SqlParameter("@Sum", certificate.Sum),
         new SqlParameter("@Message", certificate.CertificateMessage),
         new SqlParameter("@ToEmail", certificate.ToEmail));
 }
Пример #8
0
        public static void SendCertificateMails(GiftCertificate certificate)
        {
            string htmlMessage = SendMail.BuildMail(new ClsMailParamOnSendCertificate
            {
                CertificateCode = certificate.CertificateCode,
                FromName = certificate.FromName,
                ToName = certificate.ToName,
                Message = certificate.CertificateMessage,
                Sum = CatalogService.GetStringPrice(certificate.Sum)
            });

            SendMail.SendMailNow(certificate.ToEmail, Resources.Resource.Admin_GiftCertificate_Certificate,
                                 htmlMessage, true);
        }