Ejemplo n.º 1
0
    private void SendFax(BusinessEntities.Orders order)
    {
        StringBuilder Fax = new StringBuilder();

        Fax = Fax.Append(Core.Utility.ReadFile(PhysicalApplicationPath + HtmlFolder + "Fax.html"));
        Fax.Replace("{URL}", BaseSiteUrl);
        Fax.Replace("{ORDERNUMBER}", order.OrderID.ToString());
        Fax.Replace("{ORDERDATE}", GetStoreTime().ToString("MM/dd/yyyy HH:mm"));
        Fax.Replace("{FULLNAME}", txtFirstName.Text + " " + txtLastName.Text);
        Fax.Replace("{ADDRESS}", txtAddress.Text + " " + txtCity.Text + ", " + txtZipCode.Text + ", " + txtState.Text);
        Fax.Replace("{PHONE}", txtTelephone.Text);
        if (!String.IsNullOrEmpty(txtMobile.Text))
        {
            Fax.Replace("{MOBILE}", !String.IsNullOrEmpty(txtTelephone.Text) ? " - " + txtMobile.Text : txtMobile.Text);
        }
        else
        {
            Fax.Replace("{MOBILE}", "");
        }
        if (order.OrderTypeID == BusinessEntities.OrderType.Deliver)
        {
            Fax.Replace("{ORDERDELIVERY}", "Pizzaness Delivery");
        }
        else
        {
            Fax.Replace("{ORDERDELIVERY}", "Self Pickup");
        }

        if (order.PaymentMethod == BusinessEntities.PaymentType.OnlinePayment)
        {
            Fax.Replace("{PAYMENTMETHOD}", "Online Payment");
        }
        else
        {
            Fax.Replace("{PAYMENTMETHOD}", "Cash Payment");
        }
        StringBuilder finalTemplate = new StringBuilder();

        for (int i = 0; i < order.OrderDetailsList.Count; i++)
        {
            BusinessEntities.OrderDetails orderDetail = order.OrderDetailsList.ElementAt(i);
            StringBuilder newTemplate = new StringBuilder();
            newTemplate.Append(Core.Utility.ReadFile(PhysicalApplicationPath + HtmlFolder + "FaxOrderDetailTemplate.html"));
            newTemplate.Replace("{ITEMNUMBER}", (i + 1).ToString());
            newTemplate.Replace("{PRODUCTTYPE}", !String.IsNullOrEmpty(orderDetail.CategoryName) ? orderDetail.CategoryName : "");
            newTemplate.Replace("{PRODUCTNAME}", orderDetail.ProductName);
            newTemplate.Replace("{ITEMQUANTITY}", orderDetail.Quantity.ToString());
            newTemplate.Replace("{ITEMPRICE}", orderDetail.ItemTotal.ToString("C2"));
            newTemplate.Replace("{RECIPENTNAME}", orderDetail.RecipientName);
            newTemplate.Replace("{INSTRUCTION}", orderDetail.Comments);

            StringBuilder optionTemplate = new StringBuilder();

            foreach (BusinessEntities.OrderDetailOptions obj in SessionOrderDetailOptionList.ElementAt(i))
            {
                optionTemplate.Append(Core.Utility.ReadFile(PhysicalApplicationPath + HtmlFolder + "OptionTemplate.html"));
                optionTemplate.Replace("{OPTIONSTYPE}", obj.ProductOptionTypeName);
                optionTemplate.Replace("{OPTIONS}", obj.ProductOptionName);
            }
            StringBuilder toppings = new StringBuilder();
            String        previousAddonTypeName = String.Empty;
            StringBuilder toppingTemplate       = new StringBuilder();
            if (orderDetail.IsGroupProduct)
            {
                List <BusinessEntities.OrderDetailSubProduct> subProducts = orderDetail.OrderDetailSubProducts;
                StringBuilder finalSubProductTemplate = new StringBuilder();
                foreach (BusinessEntities.OrderDetailSubProduct subProduct in subProducts)
                {
                    StringBuilder subProductTemplate = new StringBuilder();
                    subProductTemplate.Append(Core.Utility.ReadFile(PhysicalApplicationPath + HtmlFolder + "SubProductTemplate.html"));
                    subProductTemplate.Replace("{PRODUCTNAME}", subProduct.ProductName);
                    subProductTemplate.Replace("{RECIPENTNAME}", subProduct.RecipientName);
                    subProductTemplate.Replace("{INSTRUCTION}", subProduct.Comments);

                    StringBuilder subProductOptionTemplate = new StringBuilder();

                    if (subProduct.OrderDetailSubProductOptions != null)
                    {
                        foreach (BusinessEntities.OrderDetailSubProductOption subProductOption in subProduct.OrderDetailSubProductOptions)
                        {
                            subProductOptionTemplate.Append(Core.Utility.ReadFile(PhysicalApplicationPath + HtmlFolder + "OptionTemplate.html"));
                            subProductOptionTemplate.Replace("{OPTIONSTYPE}", subProductOption.ProductOptionTypeName);
                            subProductOptionTemplate.Replace("{OPTIONS}", subProductOption.ProductOptionName);
                        }
                    }
                    toppings = new StringBuilder();
                    previousAddonTypeName = String.Empty;
                    toppingTemplate       = new StringBuilder();
                    int j = 1;
                    foreach (BusinessEntities.OrderDetailSubProductAdon obj in subProduct.OrderDetailSubProductAdons)
                    {
                        if (obj.SelectedAdonOption != 0)
                        {
                            if (!obj.AdonTypeName.Equals(previousAddonTypeName))
                            {
                                if (!String.IsNullOrEmpty(toppings.ToString()))
                                {
                                    String subString = Utility.GetSubString(toppingTemplate.ToString(),
                                                                            "<!-- Toppings-->", "<!-- End Topping-->",
                                                                            true);
                                    toppingTemplate.Replace(subString, toppings.ToString());
                                }
                                toppings = new StringBuilder();
                                toppingTemplate.Append(
                                    Core.Utility.ReadFile(PhysicalApplicationPath + HtmlFolder + "ToppingTemplate.html"));
                                toppingTemplate.Replace("{TOPPINGTYPE}", obj.AdonTypeName);
                                previousAddonTypeName = obj.AdonTypeName;
                            }
                            toppings.Append(Utility.GetSubString(toppingTemplate.ToString(), "<!-- Toppings-->",
                                                                 "<!-- End Topping-->", false));
                            if (obj.IsDoubleSelected)
                            {
                                toppings.Replace("{DOUBLE}", "Two times ");
                            }
                            else
                            {
                                toppings.Replace("{DOUBLE}", "");
                            }
                            toppings.Replace("{NAME}", obj.AdonName);
                            toppings.Replace("{OPTION}",
                                             ((BusinessEntities.SelectedOption)obj.SelectedAdonOption).ToString());
                        }
                    }

                    if (!String.IsNullOrEmpty(toppings.ToString()))
                    {
                        String subString = Utility.GetSubString(toppingTemplate.ToString(), "<!-- Toppings-->", "<!-- End Topping-->", true);
                        toppingTemplate.Replace(subString, toppings.ToString());
                    }
                    //if(!String.IsNullOrEmpty(subProduct.CrustType))
                    //    subProductTemplate.Replace("<!-- CrustType -->", subProduct.CrustType);
                    subProductTemplate.Replace("<!-- Options -->", subProductOptionTemplate.ToString());
                    subProductTemplate.Replace("<!-- Topping -->", toppingTemplate.ToString());
                    finalSubProductTemplate.Append(subProductTemplate.ToString());
                    if (j != subProduct.OrderDetailSubProductAdons.Count)
                    {
                        finalSubProductTemplate.Append("<tr><td colspan='2' style='border-top:1px solid black;'></td></tr>");
                    }
                }
                newTemplate.Replace("<!--SubProducts-->", finalSubProductTemplate.ToString());
                toppings        = new StringBuilder();
                toppingTemplate = new StringBuilder();
            }
            foreach (BusinessEntities.OrderDetailAdOns obj in SessionOrderAdonList.ElementAt(i))
            {
                if (obj.SelectedAdonOption != 0)
                {
                    if (!obj.AdonTypeName.Equals(previousAddonTypeName))
                    {
                        if (!String.IsNullOrEmpty(toppings.ToString()))
                        {
                            String subString = Utility.GetSubString(toppingTemplate.ToString(), "<!-- Toppings-->",
                                                                    "<!-- End Topping-->", true);
                            toppingTemplate.Replace(subString, toppings.ToString());
                        }
                        toppings = new StringBuilder();
                        toppingTemplate.Append(
                            Core.Utility.ReadFile(PhysicalApplicationPath + HtmlFolder + "FaxToppingTemplate.html"));
                        toppingTemplate.Replace("{TOPPINGTYPE}", obj.AdonTypeName);
                        previousAddonTypeName = obj.AdonTypeName;
                    }
                    toppings.Append(Utility.GetSubString(toppingTemplate.ToString(), "<!-- Toppings-->",
                                                         "<!-- End Topping-->", false));

                    if (obj.IsDoubleSelected)
                    {
                        toppings.Replace("{DOUBLE}", "Two times ");
                    }
                    else
                    {
                        toppings.Replace("{DOUBLE}", "");
                    }
                    toppings.Replace("{NAME}", obj.AdonName);
                    toppings.Replace("{OPTION}", ((BusinessEntities.SelectedOption)obj.SelectedAdonOption).ToString());
                }
            }
            if (!String.IsNullOrEmpty(toppings.ToString()))
            {
                String subString = Utility.GetSubString(toppingTemplate.ToString(), "<!-- Toppings-->", "<!-- End Topping-->", true);
                toppingTemplate.Replace(subString, toppings.ToString());
            }

            newTemplate.Replace("<!--OrderDetailOptions-->", optionTemplate.ToString());
            newTemplate.Replace("<!--OrderDetailToppings-->", toppingTemplate.ToString());

            finalTemplate.Append(newTemplate.ToString());
            //finalTemplate.Append(optionTemplate.ToString());
            //finalTemplate.Append(toppingTemplate.ToString());
        }
        String DetailTemplate = Utility.GetSubString(Fax.ToString(), "<!--DETAIL TEMPLATE-->", "<!--END DETAIL TEMPLATE-->", true);

        DetailTemplate = DetailTemplate.Replace("<!--DETAILTEMPLATE-->", finalTemplate.ToString());

        Fax.Replace(Utility.GetSubString(Fax.ToString(), "<!--DETAIL TEMPLATE-->", "<!--END DETAIL TEMPLATE-->", true), DetailTemplate.ToString());
        Fax.Replace("{TIP}", order.LineTip.ToString("C2"));
        Fax.Replace("{TOTALPRICE}", order.OrderTotal.ToString("C2"));
        if (order.PaymentMethod == BusinessEntities.PaymentType.CashPayment)
        {
            interfax.InterFax client = new InterFax();
            if (ConfigurationManager.AppSettings["AllowFax"].Equals("true"))
            {
                client.Sendfax(ConfigurationManager.AppSettings["FaxUsername"],
                               ConfigurationManager.AppSettings["FaxPassword"],
                               ConfigurationManager.AppSettings["FaxNumber"],
                               System.Text.Encoding.UTF8.GetBytes(Fax.ToString()), "HTML");
            }
            else
            {
                try
                {
                    Core.Utility.SendEmail(ConfigurationManager.AppSettings["DonotReplyEmail"], SessionUser.Username, String.Empty, ConfigurationManager.AppSettings["OrderReceiveEmail"], "New Order Fax", Fax.ToString(), true);
                }
                catch (Exception ex)
                {
                }
            }
        }
        else
        {
            SessionFax = Fax.ToString();
        }
    }
Ejemplo n.º 2
0
    private void SendMail(BusinessEntities.Orders order)
    {
        StringBuilder sb = new StringBuilder();

        sb = sb.Append(Core.Utility.ReadFile(PhysicalApplicationPath + HtmlFolder + "NewOrder.html"));

        sb.Replace("{URL}", BaseSiteUrl);
        sb.Replace("{ORDERNUMBER}", order.OrderID.ToString());
        sb.Replace("{ORDERDATE}", GetStoreTime().ToString("MM/dd/yyyy HH:mm"));
        sb.Replace("{FULLNAME}", txtFirstName.Text + " " + txtLastName.Text);
        sb.Replace("{ADDRESS}", txtAddress.Text);
        sb.Replace("{CITY}", txtCity.Text);
        sb.Replace("{STATE}", txtState.Text);
        sb.Replace("{ZIPCODE}", txtZipCode.Text);
        sb.Replace("{PHONE}", txtTelephone.Text);
        if (!String.IsNullOrEmpty(txtMobile.Text))
        {
            sb.Replace("{MOBILE}", !String.IsNullOrEmpty(txtTelephone.Text) ? " - " + txtMobile.Text : txtMobile.Text);
        }
        else
        {
            sb.Replace("{MOBILE}", "");
        }
        if (order.OrderTypeID == BusinessEntities.OrderType.Deliver)
        {
            sb.Replace("{ORDERDELIVERY}", "Pizzaness Delivery");
        }
        else
        {
            sb.Replace("{ORDERDELIVERY}", "Self Pickup");
        }

        if (order.PaymentMethod == BusinessEntities.PaymentType.OnlinePayment)
        {
            sb.Replace("{PAYMENTMETHOD}", "Online Payment");
        }
        else
        {
            sb.Replace("{PAYMENTMETHOD}", "Cash Payment");
        }
        StringBuilder finalTemplate = new StringBuilder();

        for (int i = 0; i < order.OrderDetailsList.Count; i++)
        {
            BusinessEntities.OrderDetails orderDetails = order.OrderDetailsList.ElementAt(i);
            StringBuilder newTemplate = new StringBuilder();
            newTemplate.Append(Core.Utility.ReadFile(PhysicalApplicationPath + HtmlFolder + "OrderDetailTemplate.html"));
            newTemplate.Replace("{ITEMQUANTITY}", orderDetails.Quantity.ToString());
            newTemplate.Replace("{PRODUCTNAME}", orderDetails.ProductName);
            newTemplate.Replace("{PRODUCTTYPE}", !String.IsNullOrEmpty(orderDetails.CategoryName) ? orderDetails.CategoryName : "");
            newTemplate.Replace("{PRICE}", orderDetails.Price.ToString());
            newTemplate.Replace("{RECIPENTNAME}", orderDetails.RecipientName);
            newTemplate.Replace("{INSTRUCTION}", orderDetails.Comments);

            StringBuilder optionTemplate = new StringBuilder();

            foreach (BusinessEntities.OrderDetailOptions obj in SessionOrderDetailOptionList.ElementAt(i))
            {
                //optionTemplate.Append(Core.Utility.ReadFile(PhysicalApplicationPath + HtmlFolder + "OptionTemplate.html"));
                //optionTemplate.Replace("{OPTIONSTYPE}", obj.ProductOptionTypeName);
                optionTemplate.Append(obj.ProductOptionName + ",");
            }

            StringBuilder toppings = new StringBuilder();
            String        previousAddonTypeName = String.Empty;
            StringBuilder toppingTemplate       = new StringBuilder();
            if (orderDetails.IsGroupProduct)
            {
                List <BusinessEntities.OrderDetailSubProduct> subProducts = orderDetails.OrderDetailSubProducts;
                StringBuilder finalSubProductTemplate = new StringBuilder();
                foreach (BusinessEntities.OrderDetailSubProduct subProduct in subProducts)
                {
                    StringBuilder subProductTemplate = new StringBuilder();
                    subProductTemplate.Append(Core.Utility.ReadFile(PhysicalApplicationPath + HtmlFolder + "SubProductTemplate.html"));
                    subProductTemplate.Replace("{PRODUCTNAME}", subProduct.ProductName);
                    subProductTemplate.Replace("{RECIPENTNAME}", subProduct.RecipientName);
                    subProductTemplate.Replace("{INSTRUCTION}", subProduct.Comments);

                    StringBuilder subProductOptionTemplate = new StringBuilder();

                    if (subProduct.OrderDetailSubProductOptions != null)
                    {
                        foreach (BusinessEntities.OrderDetailSubProductOption subProductOption in subProduct.OrderDetailSubProductOptions)
                        {
                            //subProductOptionTemplate.Append(Core.Utility.ReadFile(PhysicalApplicationPath + HtmlFolder + "OptionTemplate.html"));
                            //subProductOptionTemplate.Replace("{OPTIONSTYPE}", subProductOption.ProductOptionTypeName);
                            subProductOptionTemplate.Append(subProductOption.ProductOptionName + ",");
                        }
                    }
                    toppings = new StringBuilder();
                    previousAddonTypeName = String.Empty;
                    toppingTemplate       = new StringBuilder();
                    foreach (BusinessEntities.OrderDetailSubProductAdon obj in subProduct.OrderDetailSubProductAdons)
                    {
                        if (obj.SelectedAdonOption != 0)
                        {
                            if (!obj.AdonTypeName.Equals(previousAddonTypeName))
                            {
                                toppings.Append(" <b>" + obj.AdonTypeName + ":</b>");
                                previousAddonTypeName = obj.AdonTypeName;
                            }
                            toppings.Append(Utility.GetSubString(toppingTemplate.ToString(), "<!-- Toppings-->",
                                                                 "<!-- End Topping-->", false));
                            if (obj.IsDoubleSelected)
                            {
                                toppings.Replace("{DOUBLE}", "Two times ");
                            }
                            else
                            {
                                toppings.Replace("{DOUBLE}", "");
                            }
                            toppings.Replace("{NAME}", obj.AdonName);
                            toppings.Replace("{OPTION}",
                                             ((BusinessEntities.SelectedOption)obj.SelectedAdonOption).ToString());
                        }
                    }

                    if (!String.IsNullOrEmpty(toppings.ToString()))
                    {
                        String subString = Utility.GetSubString(toppingTemplate.ToString(), "<!-- Toppings-->", "<!-- End Topping-->", true);
                        toppingTemplate.Replace(subString, toppings.ToString());
                    }
                    subProductTemplate.Replace("<!-- Options -->", subProductOptionTemplate.ToString().TrimEnd(new char[] { ',' }));
                    subProductTemplate.Replace("<!-- Topping -->", toppingTemplate.ToString());
                    finalSubProductTemplate.Append(subProductTemplate.ToString());
                }
                newTemplate.Replace("<!--SubProducts-->", finalSubProductTemplate.ToString());
                toppings        = new StringBuilder();
                toppingTemplate = new StringBuilder();
            }
            foreach (BusinessEntities.OrderDetailAdOns obj in SessionOrderAdonList.ElementAt(i))
            {
                if (obj.SelectedAdonOption != 0)
                {
                    if (!obj.AdonTypeName.Equals(previousAddonTypeName))
                    {
                        toppings.Append(" <b>" + obj.AdonTypeName + ":</b>");
                        previousAddonTypeName = obj.AdonTypeName;
                    }


                    toppings.Append(obj.AdonName);
                    if (obj.SelectedAdonOption == SelectedOption.FirstHalf)
                    {
                        if (obj.IsDoubleSelected)
                        {
                            toppings.Append("(Left 2 Times),");
                        }
                        else
                        {
                            toppings.Append("(Left),");
                        }
                    }
                    else if (obj.SelectedAdonOption == SelectedOption.SecondHalf)
                    {
                        if (obj.IsDoubleSelected)
                        {
                            toppings.Append("(Right 2 Times),");
                        }
                        else
                        {
                            toppings.Append("(Right),");
                        }
                    }
                    else
                    {
                        toppings.Append(",");
                    }
                }
            }
            if (!String.IsNullOrEmpty(toppings.ToString()))
            {
                //String subString = Utility.GetSubString(toppingTemplate.ToString(), "<!-- Toppings-->", "<!-- End Topping-->", true);
                toppingTemplate.Append(toppings.ToString());
            }
            newTemplate.Replace("<!--OrderDetailOptions-->", optionTemplate.ToString().TrimEnd(new char[] { ',' }));
            newTemplate.Replace("<!--OrderDetailToppings-->", toppingTemplate.ToString().TrimEnd(new char[] { ',' }));
            finalTemplate.Append(newTemplate.ToString());
            //finalTemplate.Append(optionTemplate.ToString());
            //finalTemplate.Append(toppingTemplate.ToString());
        }
        String DetailTemplate = Utility.GetSubString(sb.ToString(), "<!--DETAIL TEMPLATE-->", "<!--END DETAIL TEMPLATE-->", true);

        DetailTemplate = DetailTemplate.Replace("<!--DETAILTEMPLATE-->", finalTemplate.ToString());

        sb.Replace(Utility.GetSubString(sb.ToString(), "<!--DETAIL TEMPLATE-->", "<!--END DETAIL TEMPLATE-->", true), DetailTemplate.ToString());
        sb.Replace("{TIP}", order.LineTip.ToString("C2"));
        sb.Replace("{TOTALPRICE}", order.OrderTotal.ToString("C2"));
        try
        {
            var mail = new Mail();
            mail.Subject       = "New Order";
            mail.Sender        = ConfigurationManager.AppSettings["DonotReplyEmail"];
            mail.Receiver      = SessionUser.Username;
            mail.MailCc        = string.Empty;
            mail.MailBcc       = ConfigurationManager.AppSettings["OrderReceiveEmail"];
            mail.MailBody      = sb.ToString();
            mail.IsHtml        = true;
            mail.ReferenceId   = order.OrderID;
            mail.ReferenceType = "Order";
            mailManager.AddMail(mail);
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
Ejemplo n.º 3
0
    protected void AddToCartButton_Click(object sender, EventArgs e)
    {
        Products comboproduct = _productManager.GetProductById(Convert.ToInt32(Request.QueryString["PID"]));

        if (comboproduct != null)
        {
            try
            {
                Orders order = SessionUserOrder;
                if (order == null)
                {
                    order = new BusinessEntities.Orders();
                }

                if (order.OrderDetailsList == null)
                {
                    order.OrderDetailsList       = new List <BusinessEntities.OrderDetails>();
                    SessionOrderAdonList         = new List <List <BusinessEntities.OrderDetailAdOns> >();
                    SessionOrderDetailOptionList = new List <List <BusinessEntities.OrderDetailOptions> >();
                    order.OrderStatusID          = BusinessEntities.OrderStatus.NewOrder;
                }

                #region Order Detail

                BusinessEntities.OrderDetails orderdetail = new BusinessEntities.OrderDetails();
                orderdetail.Price          = comboproduct.DefaultBranchProductPrice;
                orderdetail.CategoryName   = comboproduct.CategoryName;
                orderdetail.ProductName    = comboproduct.Name;
                orderdetail.ProductID      = comboproduct.ProductID;
                orderdetail.ProductImage   = comboproduct.Image;
                orderdetail.Quantity       = 1;
                orderdetail.IsGroupProduct = true;

                orderdetail.OrderDetailSubProducts = new List <OrderDetailSubProduct>();

                #endregion

                Double price = 0;
                foreach (RadPageView pageView in RadMultiPage1.PageViews)
                {
                    price += ((MyUserControl)pageView.Controls[0]).GetPrice();
                    var orderDetailObj = ((MyUserControl)pageView.Controls[0]).GetOrderDetailSubProduct();
                    orderdetail.OrderDetailSubProducts.Add(orderDetailObj);
                    orderdetail.RecipientName = orderDetailObj.RecipientName;
                }


                #region Code Commit

                /*RepeaterItemCollection gridItems = rptProducts.Items;
                 * foreach (RepeaterItem productItem in gridItems)
                 * {
                 *  Double productPrice = 0, toppingPrice = 0;
                 *  bool CalculateAdonPrice = false;
                 *  HiddenField ProductID = productItem.FindControl("hdProductId") as HiddenField;
                 *  RadTextBox RecipientName = productItem.FindControl("txtRecipientName") as RadTextBox;
                 *  RadTextBox Instruction = productItem.FindControl("txtInstruction") as RadTextBox;
                 *  Products product = products.Where(p => p.ProductID == Convert.ToInt32(ProductID.Value)).First();
                 *
                 #region Order Detail Sub Product
                 *
                 *  OrderDetailSubProduct orderDetailSubProduct = new OrderDetailSubProduct();
                 *  orderDetailSubProduct.ProductId = product.ProductID;
                 *  orderDetailSubProduct.Quantity = 1;
                 *  orderDetailSubProduct.RecipientName = RecipientName.Text;
                 *  orderDetailSubProduct.Comments = Instruction.Text;
                 *
                 #endregion
                 *
                 *
                 *  Repeater rptOptions = productItem.FindControl("rptOptions") as Repeater;
                 *
                 *  foreach (RepeaterItem optionItem in rptOptions.Items)
                 *  {
                 #region Order Detail Sub Product Option
                 *
                 #endregion
                 *      HiddenField OptionTypeID = optionItem.FindControl("hdOptionTypeId") as HiddenField;
                 *      OptionTypesInProduct optionTypeInProduct = product.OptionTypesInProductList.Where(ot => ot.OptionTypeID == Convert.ToInt16(OptionTypeID.Value)).FirstOrDefault();
                 *      if (optionTypeInProduct.IsMultiSelect)
                 *      {
                 *          CheckBoxList chklist = optionItem.FindControl("CheckBoxList") as CheckBoxList;
                 *          if (chklist != null)
                 *          {
                 *              bool changePrice = true;
                 *              foreach (ListItem checkBox in chklist.Items)
                 *              {
                 *                  if (checkBox.Selected)
                 *                  {
                 *                      ProductOptions productOption = optionTypeInProduct.ProductOptionsList[0];
                 *                      if (optionTypeInProduct.IsSamePrice && optionTypeInProduct.IsProductPriceChangeType)
                 *                      {
                 *                          if (changePrice)
                 *                          {
                 *                              if (productPrice == 0)
                 *                                  productPrice = productOption.Price;
                 *                              else
                 *                                  productPrice += productOption.Price;
                 *                              changePrice = false;
                 *                          }
                 *                      }
                 *                      else if (optionTypeInProduct.IsProductPriceChangeType)
                 *                      {
                 *                          productPrice += productOption.Price;
                 *                      }
                 *                      OrderDetailSubProductOption orderDetailSubProductOption = new OrderDetailSubProductOption();
                 *                      orderDetailSubProductOption.ProductOptionId = productOption.OptionID;
                 *                      orderDetailSubProductOption.ProductOptionName = productOption.OptionName;
                 *                      orderDetailSubProductOption.Price = productOption.Price;
                 *                  }
                 *              }
                 *          }
                 *      }
                 *      else
                 *      {
                 *          RadioButtonList radiolist = optionItem.FindControl("RadioButtonList") as RadioButtonList;
                 *          if (radiolist != null && !String.IsNullOrEmpty(radiolist.SelectedValue))
                 *          {
                 *              CalculateAdonPrice = true;
                 *              if (optionTypeInProduct.IsSamePrice)
                 *              {
                 *                  ProductOptions productOption = optionTypeInProduct.ProductOptionsList[0];
                 *                  productPrice = productOption.Price;
                 *              }
                 *              else
                 *              {
                 *                  ProductOptions productOption = optionTypeInProduct.ProductOptionsList.Where(po => po.OptionID == Convert.ToInt32(radiolist.SelectedValue)).FirstOrDefault();
                 *                  productPrice = productOption.Price;
                 *                  toppingPrice = productOption.ToppingPrice;
                 *              }
                 *          }
                 *          else
                 *          {
                 *              productPrice = product.UnitPrice;
                 *          }
                 *      }
                 *      if (CalculateAdonPrice)
                 *      {
                 *          Repeater rptAdonsType = productItem.FindControl("rptAdonsType") as Repeater;
                 *          Int16 freeToppingCount = 0;
                 *          foreach (RepeaterItem adonTypeItem in rptAdonsType.Items)
                 *          {
                 *              HiddenField hdAdonTypeId = adonTypeItem.FindControl("hdAdonTypeId") as HiddenField;
                 *              AdOnTypeInProduct adonType = product.AdOnTypeInProductList.Where(at => at.AdonTypeID == Convert.ToInt16(hdAdonTypeId.Value)).FirstOrDefault();
                 *
                 *              Repeater rptAdons = adonTypeItem.FindControl("rptAdons") as Repeater;
                 *              foreach (RepeaterItem adonItem in rptAdons.Items)
                 *              {
                 *                  Double adonPrice = 0;
                 *                  HiddenField hdAdonId = adonItem.FindControl("hdAdonId") as HiddenField;
                 *                  Adon adon = adonType.Adons.Where(a => a.AdOnID == Convert.ToInt32(hdAdonId.Value)).FirstOrDefault();
                 *                  RadioButtonList txtAdonOptions = adonItem.FindControl("AdonOptions") as RadioButtonList;
                 *                  CheckBox txtDouble = adonItem.FindControl("txtDouble") as CheckBox;
                 *                  short selectedoption = short.Parse(txtAdonOptions.SelectedValue);
                 *                  OrderDetailSubProductAdon orderDetailSubAdon = new OrderDetailSubProductAdon();
                 *                  orderDetailSubAdon.AdOnId = adon.AdOnID;
                 *                  orderDetailSubAdon.AdonName = adon.AdOnName;
                 *                  orderDetailSubAdon.SelectedAdonOption = selectedoption;
                 *                  orderDetailSubAdon.IsDoubleSelected = txtDouble.Checked;
                 *                  if (adon.DefaultSelected == 0 && (selectedoption == 1 || selectedoption == 2 || selectedoption == 3))
                 *                  {       // When None was default selected and user has changed default selected option
                 *                      if (!adonType.IsFreeAdonType)
                 *                      {
                 *                          if (txtDouble.Checked)
                 *                          {
                 *                              if (freeToppingCount == product.NumberOfFreeTopping)
                 *                              {
                 *                                  if (toppingPrice > 0)
                 *                                      adonPrice += 2 * toppingPrice;
                 *                                  else
                 *                                      adonPrice += (2 * Convert.ToDouble(adonType.Price));
                 *                              }
                 *                              else
                 *                              {
                 *                                  if (toppingPrice > 0)
                 *                                      productPrice += toppingPrice;
                 *                                  else
                 *                                      productPrice += Convert.ToDouble(adonType.Price);
                 *                                  freeToppingCount++;
                 *                              }
                 *                          }
                 *                          else
                 *                          {
                 *                              if (freeToppingCount == product.NumberOfFreeTopping)
                 *                              {
                 *                                  if (toppingPrice > 0)
                 *                                      productPrice += toppingPrice;
                 *                                  else
                 *                                      productPrice += Convert.ToDouble(adonType.Price);
                 *                              }
                 *                              else
                 *                                  freeToppingCount++;
                 *                          }
                 *                      }
                 *                  }
                 *                  else  // When other than None is pre selected and user has also selected Double check box
                 *                  {
                 *                      if (txtDouble.Checked && selectedoption != 0)
                 *                      {
                 *                          if (toppingPrice > 0)
                 *                              adonPrice += toppingPrice;
                 *                          else
                 *                              adonPrice += Convert.ToDouble(adonType.Price);
                 *                      }
                 *                      else
                 *                      {
                 *                          txtDouble.Checked = false;
                 *                      }
                 *                  }
                 *                  orderDetailSubAdon.Price = adonPrice;
                 *                  productPrice += adonPrice;
                 *              }
                 *          }
                 *      } // CalculateAdonPrice
                 *  }
                 *
                 *  netProductPrice += productPrice;
                 *  orderDetailSubProduct.Price = productPrice;
                 * }*/
                #endregion

                orderdetail.ItemTotal = orderdetail.Price = price;
                order.OrderDetailsList.Add(orderdetail);


                //Add order details to log table when added to cart

                // Prepare data for log
                string sessionID     = HttpContext.Current.Session.SessionID;
                string recepientName = orderdetail.RecipientName == "" ? null : orderdetail.RecipientName;
                string productDetail = string.Empty;
                string adons         = string.Empty;

                foreach (OrderDetailSubProduct product in orderdetail.OrderDetailSubProducts)
                {
                    productDetail += product.ProductName + ": ";
                    foreach (var p in product.OrderDetailSubProductOptions)
                    {
                        productDetail += p.ProductOptionName + ",";
                    }
                    foreach (OrderDetailSubProductAdon adon in product.OrderDetailSubProductAdons)
                    {
                        adons += adon.AdOnId + ",";
                    }
                }

                //productDetail = productDetail[productDetail.Length - 1] == ','
                //                    ? productDetail.Substring(0, productDetail.Length - 2)
                //                    : productDetail;

                //adons = adons[adons.Length - 1] == ','
                //                    ? adons.Substring(0, adons.Length - 2)
                //                    : adons;

                productDetail = productDetail.Trim(',');
                adons         = adons.TrimEnd(',');

                productDetail = productDetail == "" ? null : productDetail;
                adons         = adons == "" ? null : adons;
                // get log message to pass to db
                string message = Common.AddToCartLogMessage(orderdetail.CategoryName, orderdetail.Price,
                                                            adons, productDetail, SessionUserFullName);

                // Log order details
                LogManager log = new LogManager();
                log.SaveLogData(sessionID, LogLevel.INFO.ToString(), Logger.AddToCart.ToString(), message, null);

                List <BusinessEntities.OrderDetailAdOns> list = new List <BusinessEntities.OrderDetailAdOns>();
                SessionOrderAdonList.Add(list);
                List <BusinessEntities.OrderDetailOptions> list1 = new List <BusinessEntities.OrderDetailOptions>();
                SessionOrderDetailOptionList.Add(list1);

                double preOrderPromoValue = 0.0d;

                //if (SessionPreOrderPromo!=null)
                //{
                //    preOrderPromoValue = SessionPreOrderPromo.PreOrderPromoValue;
                //}
                order.OrderTotal      = order.OrderTotal + price;
                SessionUserOrder      = order;
                SessionUserOrderTotal = order.OrderTotal;

                this.ClientScript.RegisterClientScriptBlock(this.GetType(), "CloseWindow", "<script type='text/javascript'>CloseOnReload()</script>");
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
Ejemplo n.º 4
0
    protected void OrderNow_Click(object sender, EventArgs e)
    {
        if (SessionUserOrder != null)
        {
            Double deduction = 0, Tip = 0;
            BusinessEntities.PromotionCodes promotionCode = null;
            BusinessEntities.Orders         order         = SessionUserOrder;


            if (!String.IsNullOrEmpty(txtPromotionCode.Text))
            {
                if (SessionPreOrderPromo != null)
                {
                    deduction += SessionPreOrderPromo.PreOrderPromoValue;
                }

                promotionCode = promoManager.GetPromotionCodeByCode(txtPromotionCode.Text.Trim());
                if (promotionCode != null)
                {
                    if (promotionCode.TypeOfPromotion == BusinessEntities.PromotionType.Money)
                    {
                        deduction = promotionCode.PromotionValue;
                    }
                    else if (promotionCode.TypeOfPromotion == BusinessEntities.PromotionType.EGiftCard) // in case of E-Gift, keep track of PromotionValueUsed...
                    {
                        if ((promotionCode.PromotionValue - promotionCode.PromoValueUsed) > 0)
                        {
                            if (order.OrderTotal < (promotionCode.PromotionValue - promotionCode.PromoValueUsed))
                            {
                                promotionCode.PromoValueUsed += deduction = order.OrderTotal;
                            }
                            else
                            {
                                promotionCode.PromoValueUsed +=
                                    deduction = (promotionCode.PromotionValue - promotionCode.PromoValueUsed);
                            }
                        }
                    }
                    else
                    {
                        deduction = (SessionUserOrder.OrderTotal * promotionCode.PromotionValue) / 100;
                    }

                    order.PromotionCodeId = promotionCode.PromotionCodeId;

                    order.PromotionValueUsed = (promotionCode.PromoValueUsed == 0.0)
                                                   ? (double)0.0
                                                   : promotionCode.PromoValueUsed;
                }
            }

            if (order.ContactInfoId == 0)
            {
                order.ContactInfoId = SessionUserContactInfoId;
            }
            order.BranchID      = Convert.ToInt32(ConfigurationManager.AppSettings["BranchId"]);
            order.OrderTypeID   = (BusinessEntities.OrderType)Convert.ToInt16(txtDeliveryMethod.SelectedValue);
            order.PaymentMethod = (BusinessEntities.PaymentType)Convert.ToInt16(txtPaymentMethod.SelectedValue);
            order.TaxPercentage = Convert.ToDouble(txtTax.Text);
            if (!String.IsNullOrEmpty(txtTip.Text) && Double.TryParse(txtTip.Text, out Tip))
            {
                order.LineTip = Double.Parse(txtTip.Text);
            }
            if (order.OrderTypeID == BusinessEntities.OrderType.Deliver)
            {
                order.OrderTypeID     = BusinessEntities.OrderType.Deliver;
                order.DeliveryCharges = Convert.ToDouble(txtDeliveryCharges.Text);
                order.DeliveryAddress = txtAddress.Text + " <br /> " + txtCity.Text + " " + txtZipCode.Text + "<br /> " + txtState.Text;
                order.OrderTotal      = (order.OrderTotal + order.DeliveryCharges) + order.LineTip + (((order.OrderTotal + order.DeliveryCharges) * order.TaxPercentage) / 100);
                order.OrderTotal      = order.OrderTotal - deduction;
            }
            else
            {
                order.OrderTypeID = BusinessEntities.OrderType.SelfPickup;
                order.OrderTotal  = order.OrderTotal + order.LineTip + ((order.OrderTotal * order.TaxPercentage) / 100);
                order.OrderTotal  = order.OrderTotal - deduction;
            }
            Int64 result = orderManager.AddOrder(order, SessionOrderDetailOptionList, SessionOrderAdonList);

            string sessionID     = HttpContext.Current.Session.SessionID;
            string categoryName  = string.Empty;
            string sizes         = string.Empty;
            string adons         = string.Empty;
            double price         = order.OrderTotal;
            string recepientName = order.CustomerName;
            string userName      = SessionUserFullName;

            foreach (var currentOrder in order.OrderDetailsList)
            {
                if (!categoryName.Contains(currentOrder.CategoryName))
                {
                    categoryName += currentOrder.CategoryName;
                }
                if (currentOrder.OrderDetailSubProducts != null)
                {
                    foreach (var product in currentOrder.OrderDetailSubProducts)
                    {
                        sizes += product.ProductName + ": ";
                        foreach (var p in product.OrderDetailSubProductOptions)
                        {
                            sizes += p.ProductOptionName + ",";
                        }
                        foreach (var adon in product.OrderDetailSubProductAdons)
                        {
                            adons += adon.AdOnId + ",";
                        }
                    }
                }
            }

            sizes = sizes.Trim(',');
            adons = adons.TrimEnd(',');

            sizes = sizes == "" ? null : sizes;
            adons = adons == "" ? null : adons;
            // get log message to pass to db
            string message = Common.ConfirmOrderLogMessage(categoryName, price,
                                                           adons, sizes, recepientName, SessionUserFullName);

            // Log order details
            LogManager log = new LogManager();
            log.SaveLogData(sessionID, LogLevel.INFO.ToString(), Logger.ConfirmOrder.ToString(), message, null);


            if (result > 0)
            {
                order.OrderID = result;
                SendMail(order);
                SendFax(order);
                if (Tip > 0)
                {
                    message = Common.LineTipLogMessage(Tip.ToString(), result.ToString());
                    log.SaveLogData(sessionID, LogLevel.INFO.ToString(), Logger.ConfirmOrder.ToString(), message, null);
                }
                if (order.OrderTypeID == BusinessEntities.OrderType.Deliver)
                {
                    SessionMessage = "Thank you for ordering at pizzaness. Your order has been successfully placed. We will process and dispatch your order to you as soon as possible. An order detail email has been sent at your registered email.";
                }
                else
                {
                    SessionMessage = "Thank you for ordering at pizzaness. Your order has been successfully placed. An order detail email has been sent at your registered email.";
                }
                if (order.PaymentMethod == BusinessEntities.PaymentType.CashPayment)
                {
                    SessionUserOrder      = null;
                    SessionPreOrderPromo  = null;
                    SessionUserOrderTotal = 0;
                    Response.Redirect("~/Default.aspx");
                }
                SessionOrderId        = result;
                SessionUserOrderTotal = order.OrderTotal;

                Response.Redirect("~/ProcessPayment.aspx");
            }
        }
    }
Ejemplo n.º 5
0
    protected void AddToCartButton_Click(object sender, EventArgs e)
    {
        BusinessEntities.Orders order = SessionUserOrder;
        if (order == null)
        {
            order = new BusinessEntities.Orders();
        }


        try
        {
            long             branchproductid = long.Parse(Request.QueryString["BPID"]);
            ProductsInBranch bpObj           = (from bp in entities.ProductsInBranches
                                                where bp.BranchProductID == branchproductid
                                                select bp).FirstOrDefault();
            if (bpObj != null)
            {
                if (order.OrderDetailsList == null)
                {
                    order.OrderDetailsList       = new List <BusinessEntities.OrderDetails>();
                    SessionOrderAdonList         = new List <List <BusinessEntities.OrderDetailAdOns> >();
                    SessionOrderDetailOptionList = new List <List <BusinessEntities.OrderDetailOptions> >();
                    order.OrderStatusID          = BusinessEntities.OrderStatus.NewOrder;
                }
                BusinessEntities.OrderDetails orderdetail = new BusinessEntities.OrderDetails();

                if (bpObj.Product.CategoryID == PizzaCategoryId)
                {
                    string thinCrust = GetThinCrustValue();
                    orderdetail.CrustType = thinCrust;
                }
                orderdetail.Price        = Convert.ToDouble(bpObj.Price);
                orderdetail.CategoryName = bpObj.Product.ProductCategory.Name;
                orderdetail.ProductName  = txtProductName.Text;
                orderdetail.ProductID    = bpObj.ProductID;
                orderdetail.ProductImage = bpObj.Product.Image;
                orderdetail.Quantity     = Convert.ToInt32(txtQuantity.Value);
                if (!string.IsNullOrEmpty(txtRecipientName.Text))
                {
                    orderdetail.RecipientName = txtRecipientName.Text;
                }
                if (!string.IsNullOrEmpty(txtInstruction.Text))
                {
                    orderdetail.Comments = txtInstruction.Text;
                }
                decimal adonpricefromOptionType = 0;
                adonpricefromOptionType = GetOrderOptions(orderdetail, adonpricefromOptionType);

                GetOrderAdons(orderdetail, adonpricefromOptionType);

                orderdetail.ItemTotal     = orderdetail.Price * orderdetail.Quantity;
                orderdetail.OrderDetailID = order.OrderDetailsList.Count + 1;
                order.OrderDetailsList.Add(orderdetail);
                order.OrderTotal     += orderdetail.ItemTotal;
                SessionUserOrder      = order;
                SessionUserOrderTotal = order.OrderTotal;
                this.ClientScript.RegisterClientScriptBlock(this.GetType(), "CloseWindow", "<script type='text/javascript'>CloseOnReload()</script>");
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }