Beispiel #1
0
        protected void Load_Shopping_Cart(MySqlConnection dbconn,
                                          Repeater lRepeater)
        {
            ShoppingCartClass.Create_Shopping_Cart(dbconn);
            gQuantity.Clear();
            string lUserId = null;

            if (ClaimsPrincipal.Current.Identity.IsAuthenticated == true)
            {
                lUserId = ClaimsPrincipal.Current.FindFirst("user_id").Value;
            }

            CommonClass.FetchRecordsAndBind("GET_SHOPPING_CART_DETAILS",
                                            new string[]
            {
                "P_SHOPPING_CART_ID",
                "P_EXTERNAL_USER_ID"
            },
                                            new string[]
            {
                Session["SHOPPING_CART_ID"].ToString(),
                lUserId
            },
                                            dbconn,
                                            lRepeater);
            double lTotal = 0.0;
            double lTotalShippingCharges = 0.0;
            double lShippingDiscounts    = 0.0;
            double lPromotionalDiscounts = 0.0;

            foreach (RepeaterItem lRepeaterItem in lRepeater.Items)
            {
                double lQuantity        = double.Parse((lRepeaterItem.FindControl("OLD_QUANTITY") as HiddenField).Value.ToString());
                double lOrderAmount     = double.Parse((lRepeaterItem.FindControl("PRICE") as HiddenField).Value.ToString());
                double lShippingCharges = double.Parse(Shipping_Charge.Value);
                double lSize            = double.Parse((lRepeaterItem.FindControl("MEASUREMENT_UNIT") as HiddenField).Value.ToString());
                lTotal += lOrderAmount * lQuantity;
                lTotalShippingCharges += lShippingCharges * lQuantity;
                string lMeasurementId = (lRepeaterItem.FindControl("MEASUREMENT_ID") as HiddenField).Value;
                if (gQuantity.ContainsKey(lMeasurementId))
                {
                    gQuantity[lMeasurementId] = gQuantity[lMeasurementId] + (lQuantity * lSize);
                }
                else
                {
                    gQuantity[lMeasurementId] = lQuantity * lSize;
                }
            }

            ViewState["COUNTER"]       = gQuantity;
            Shipping_Charges.Text      = lTotalShippingCharges.ToString();
            Shipping_Discounts.Text    = lShippingDiscounts.ToString();
            Promotional_Discounts.Text = lPromotionalDiscounts.ToString();
            Total_Amount.Text          = lTotal.ToString();
            if (Session["PROMOTION_CODE"] != null)
            {
                Coupon_Code.Text = Session["PROMOTION_CODE"].ToString();
            }
            Apply_Coupon_Button_Click(new object { }, EventArgs.Empty);
        }
Beispiel #2
0
        protected void Session_Start(object sender, EventArgs e)
        {
            MySqlConnection dbconn = new MySqlConnection(CommonClass.connectionstring);

            dbconn.Open();
            ShoppingCartClass.Create_Shopping_Cart(dbconn);
            dbconn.Close();
        }
Beispiel #3
0
        protected void Apply_Promotions(MySqlConnection dbconn)
        {
            ShoppingCartClass.Create_Shopping_Cart(dbconn);
            if (Is_COD(dbconn))
            {
                Shipping_Discounts.Text = Shipping_Charges.Text;
            }
            else
            {
                string[] lRecords = CommonClass.FetchRecords("GET_ACTIVE_PROMOTIONS",
                                                             new string[]
                {
                    "PROMOTION_TYPE"
                },
                                                             new string[]
                {
                    "GLOBAL"
                },
                                                             new string[]
                {
                    "P_PROMOTION_ID",
                    "P_TOTAL_QUANTITY",
                    "P_TOTAL_ORDER"
                },
                                                             dbconn);
                if (lRecords != null)
                {
                    gQuantity = ViewState["COUNTER"] as Dictionary <string, double>;
                    if (gQuantity.ContainsKey("4"))
                    {
                        if (gQuantity["4"] >= double.Parse(lRecords[1]))
                        {
                            Shipping_Discounts.Text = Shipping_Charges.Text;
                        }
                    }
                }
            }
            Surprise_Discount_PlaceHolder.Visible = false;

            if (Session["SURPRISE_DISCOUNT_PERCENTAGE"] != null && Surprise_Discount_Eligible.Value == "1")
            {
                double lSurpriseDiscount = Math.Round(((double.Parse(Total_Amount.Text) * double.Parse(Session["SURPRISE_DISCOUNT_PERCENTAGE"].ToString())) / 100));
                Promotional_Discounts.Text = (double.Parse(Promotional_Discounts.Text) +
                                              lSurpriseDiscount).ToString();
                Surprise_Discount.Text = lSurpriseDiscount.ToString();
                if (lSurpriseDiscount != 0)
                {
                    Surprise_Discount_PlaceHolder.Visible = true;
                }
            }

            Compute_Grand_Total();
        }
Beispiel #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         MySqlConnection dbconn = new MySqlConnection(CommonClass.connectionstring);
         dbconn.Open();
         ShoppingCartClass.Create_Shopping_Cart(dbconn);
         //Load_States(dbconn);
         Load_Shopping_Cart(dbconn,
                            Cart_Details_Repeater);
         AddressBook1.Load_Address(dbconn, true);
         dbconn.Close();
         Change_View("Order_Info");
     }
 }
Beispiel #5
0
        protected void Next_Address_Book_Button_Click(object sender, EventArgs e)
        {
            AddressBook_Message.Visible  = false;
            AddressBook_Message1.Visible = false;
            if (AddressBook1.GetDeliveryAddressId != "")
            {
                Change_View("Review_Order_Info");
                MultiView1.SetActiveView(Review_Order_View);
                Session["DELIVERY_ADDRESS_ID"] = AddressBook1.GetDeliveryAddressId.ToString();
                Session["SHIPPING_STATE"]      = AddressBook1.GetDeliveryState.ToString();
                Session["PIN_CODE"]            = AddressBook1.GetDeliveryPinCode.ToString();
                MySqlConnection dbconn = new MySqlConnection(CommonClass.connectionstring);
                dbconn.Open();
                ShoppingCartClass.Create_Shopping_Cart(dbconn);
                CommonClass.ExecuteQuery("UPDATE_SHOPPING_DELIVERY_ADDRESS",
                                         new string[]
                {
                    "P_SHOPPING_CART_ID",
                    "P_DELIVERY_ADDRESS_ID",
                    "P_PIN_CODE"
                },
                                         new string[]
                {
                    Session["SHOPPING_CART_ID"].ToString(),
                    AddressBook1.GetDeliveryAddressId.ToString(),
                    AddressBook1.GetDeliveryPinCode.ToString()
                },
                                         dbconn);
                Get_Shipping_Charge(dbconn);
                Load_Shopping_Cart(dbconn,
                                   Review_Order_Repeater);

                dbconn.Close();
            }
            else
            {
                AddressBook_Message.Visible    = true;
                AddressBook_Message1.Visible   = true;
                Session["SHIPPING_STATE"]      = null;
                Session["DELIVERY_ADDRESS_ID"] = null;
                Session["PIN_CODE"]            = null;
            }
        }