示例#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);
        }
示例#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();
        }
示例#3
0
        protected void Cart_Modified(object sender, CommandEventArgs e)
        {
            string[] lCommandArgs = e.CommandArgument.ToString().Split(new char[] { ',' });

            this.Master.Shopping_Cart_Amount = ShoppingCartClass.Add_To_Shopping_Cart(int.Parse(lCommandArgs[0]),
                                                                                      double.Parse(lCommandArgs[1]),
                                                                                      int.Parse(lCommandArgs[2]),
                                                                                      double.Parse(lCommandArgs[3]));
        }
示例#4
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();
        }
示例#5
0
        protected void CheckOut_Button_Click(object sender, EventArgs e)
        {
            //Check_Out_Message.Visible = false;
            Checkout_Message_PlaceHolder.Visible = false;
            if (Cart_Details_Repeater.Items.Count != 0)
            {
                MySqlConnection dbconn = new MySqlConnection(CommonClass.connectionstring);
                dbconn.Open();
                if (ClaimsPrincipal.Current.Identity.IsAuthenticated == false)
                {
                    dbconn.Close();
                    Response.Redirect("~/Account/Login.aspx");
                }
                else
                {
                    UserModel lUserModel;
                    lUserModel = CommonClass.Get_External_User_Profile(dbconn);
                    bool lRedirect = false;
                    if (lUserModel.Email_Address_Validated == 0 || lUserModel.Mobile_Validated == 0)
                    {
                        lRedirect = true;
                    }
                    if (lRedirect)
                    {
                        dbconn.Close();
                        Response.Redirect("~/Account/Validate.aspx");
                    }
                }
                foreach (RepeaterItem lRepeaterItem in Cart_Details_Repeater.Items)
                {
                    ShoppingCartClass.Update_Shopping_Cart(dbconn,
                                                           int.Parse((lRepeaterItem.FindControl("PRODUCT_ID") as HiddenField).Value),
                                                           double.Parse((lRepeaterItem.FindControl("MEASUREMENT_UNIT") as HiddenField).Value),
                                                           int.Parse((lRepeaterItem.FindControl("OLD_QUANTITY") as HiddenField).Value),
                                                           int.Parse((lRepeaterItem.FindControl("Quantity") as TextBox).Text),
                                                           double.Parse((lRepeaterItem.FindControl("PRICE") as HiddenField).Value));
                }


                AddressBook1.Load_Address(dbconn, true);
                dbconn.Close();
                Change_View("Personal_Info");
                MultiView1.SetActiveView(AddressBook_View);
            }
            else
            {
                Checkout_Message_PlaceHolder.Visible = true;
                //Check_Out_Message.Visible = true;
            }
        }
示例#6
0
        protected void Close_Button_Command(object sender, CommandEventArgs e)
        {
            MySqlConnection dbconn = new MySqlConnection(CommonClass.connectionstring);

            dbconn.Open();
            string[] lArgs = e.CommandArgument.ToString().Split(new char[] { ',' });


            this.Master.Shopping_Cart_Amount = ShoppingCartClass.Remove_From_Shopping_Cart(int.Parse(lArgs[0]),
                                                                                           double.Parse(lArgs[1]),
                                                                                           int.Parse(lArgs[2]),
                                                                                           double.Parse(lArgs[3]));
            Response.Redirect("~/View_Cart.aspx");
            dbconn.Close();
        }
示例#7
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");
     }
 }
示例#8
0
        protected void Update_Cart_Button_Click(object sender, EventArgs e)
        {
            MySqlConnection dbconn = new MySqlConnection(CommonClass.connectionstring);

            dbconn.Open();
            foreach (RepeaterItem lRepeaterItem in Cart_Details_Repeater.Items)
            {
                ShoppingCartClass.Update_Shopping_Cart(dbconn,
                                                       int.Parse((lRepeaterItem.FindControl("PRODUCT_ID") as HiddenField).Value),
                                                       double.Parse((lRepeaterItem.FindControl("MEASUREMENT_UNIT") as HiddenField).Value),
                                                       int.Parse((lRepeaterItem.FindControl("OLD_QUANTITY") as HiddenField).Value),
                                                       int.Parse((lRepeaterItem.FindControl("Quantity") as TextBox).Text),
                                                       double.Parse((lRepeaterItem.FindControl("PRICE") as HiddenField).Value));
            }

            dbconn.Close();
            Response.Redirect("~/View_Cart.aspx");
        }
示例#9
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;
            }
        }
        public void TestMethod1()
        {
            ShoppingCartClass mainClass = new ShoppingCartClass();

            Category food        = new Category("food");
            Category electronics = new Category("electronics");

            Product apple   = new Product("Apple", 10.25, food);
            Product almonds = new Product("Almonds", 15.40, food);
            Product macbook = new Product("MacBook", 4990.50, electronics);
            Product iPad    = new Product("iPad", 2999.90, electronics);

            ShoppingCartItem item1 = new ShoppingCartItem(apple, 2);
            ShoppingCartItem item2 = new ShoppingCartItem(almonds, 3);
            ShoppingCartItem item3 = new ShoppingCartItem(macbook, 1);
            ShoppingCartItem item4 = new ShoppingCartItem(iPad, 1);

            ShoppingCart.ShoppingCart cart = new ShoppingCart.ShoppingCart();

            cart.Items = new List <ShoppingCartItem>();
            cart.Items.Add(item1);
            cart.Items.Add(item2);
            cart.Items.Add(item3);
            cart.Items.Add(item4);

            Campaign discount1 = new Campaign(food, 20.00, 3, DiscountType.Rate);
            Campaign discount2 = new Campaign(food, 50.00, 5, DiscountType.Rate);
            Campaign discount3 = new Campaign(electronics, 50.00, 2, DiscountType.Amount);

            Coupon coupon1 = new Coupon(100.00, 10, DiscountType.Rate);

            List <Campaign> discounts = new List <Campaign>();

            discounts.Add(discount1);
            discounts.Add(discount2);
            discounts.Add(discount3);

            List <Coupon> coupons = new List <Coupon>();

            coupons.Add(coupon1);

            mainClass.Shopping(ref cart, ref discounts, ref coupons);
        }
示例#11
0
        protected void Add_To_Cart_Button_Click(object sender, EventArgs e)
        {
            LinkButton lLinkButton = (LinkButton)sender;
            Repeater   lRepeater   = lLinkButton.Parent.FindControl("Product_Price_List") as Repeater;

            for (int lCounter = 0; lCounter < lRepeater.Items.Count; lCounter++)
            {
                DropDownList lQuantity = lRepeater.Items[lCounter].FindControl("Quantity") as DropDownList;
                if (lQuantity.SelectedValue != "0")
                {
                    HiddenField lProduct_Id       = lRepeater.Items[lCounter].FindControl("Product_Id") as HiddenField;
                    HiddenField lMeasurement_Unit = lRepeater.Items[lCounter].FindControl("Measurement_Unit") as HiddenField;
                    HiddenField lPrice            = lRepeater.Items[lCounter].FindControl("Price") as HiddenField;
                    this.Master.Shopping_Cart_Amount = ShoppingCartClass.Add_To_Shopping_Cart(int.Parse(lProduct_Id.Value),
                                                                                              double.Parse(lMeasurement_Unit.Value),
                                                                                              int.Parse(lQuantity.SelectedValue),
                                                                                              double.Parse(lPrice.Value));
                }
            }
            Populate_Products();
        }
示例#12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //   navlogo.ImageUrl = "~/img/" + Application["COMPANY_LOGO"].ToString();
            //  navlogo.ToolTip = Application["COMPANY_NAME"].ToString();
            // navlogo.AlternateText = Application["COMPANY_NAME"].ToString();
            if (Request.ServerVariables["HTTPS"].ToString() != "on" && !Request.ServerVariables["HTTP_HOST"].ToString().Contains("localhost"))
            {
                Response.Redirect("https://" + Request.ServerVariables["HTTP_HOST"].ToString());
            }

            MySqlConnection dbconn = new MySqlConnection(CommonClass.connectionstring);

            dbconn.Open();
            if (Session["USER_TYPE"] == null)
            {
                UserModel lUserModel = CommonClass.Get_External_User_Profile(dbconn);
                if (lUserModel != null)
                {
                    Session["USER_TYPE"] = lUserModel.User_Type_Id.ToString();
                }
            }

            CommonClass.ExecuteQuery("ADD_SESSION",
                                     new string[]
            {
                "P_SESSION_ID"
            },
                                     new string[]
            {
                Session.SessionID
            },
                                     dbconn);
            dbconn.Close();

            if (!IsPostBack)
            {
                Shopping_Cart_Amount = ShoppingCartClass.Get_Shopping_Cart_Item_Count();
            }
        }
示例#13
0
        public override async Task ProcessRequestAsync(HttpContext context)
        {
            AuthenticationApiClient client = new AuthenticationApiClient(
                new Uri(string.Format("https://{0}", ConfigurationManager.AppSettings["auth0:Domain"])));

            var token = await client.ExchangeCodeForAccessTokenAsync(new ExchangeCodeRequest
            {
                ClientId          = ConfigurationManager.AppSettings["auth0:ClientId"],
                ClientSecret      = ConfigurationManager.AppSettings["auth0:ClientSecret"],
                AuthorizationCode = context.Request.QueryString["code"],
                RedirectUri       = context.Request.Url.ToString()
            });

            var profile = await client.GetUserInfoAsync(token.AccessToken);

            string lEmail = "";

            if (profile.Email != null)
            {
                lEmail = profile.Email;
            }

            var user = new List <KeyValuePair <string, object> >
            {
                new KeyValuePair <string, object>("name", profile.UserName ?? lEmail),
                new KeyValuePair <string, object>("email", lEmail),
                new KeyValuePair <string, object>("family_name", profile.LastName),
                new KeyValuePair <string, object>("given_name", profile.FirstName),
                new KeyValuePair <string, object>("nickname", profile.NickName),
                new KeyValuePair <string, object>("picture", profile.Picture),
                new KeyValuePair <string, object>("user_id", profile.UserId),
                new KeyValuePair <string, object>("id_token", token.IdToken),
                new KeyValuePair <string, object>("access_token", token.AccessToken),
                new KeyValuePair <string, object>("refresh_token", token.RefreshToken),
                new KeyValuePair <string, object>("connection", profile.Identities.First().Connection),
                new KeyValuePair <string, object>("provider", profile.Identities.First().Provider)
            };

            // NOTE: Uncomment the following code in order to include claims from associated identities
            //profile.Identities.ToList().ForEach(i =>
            //{
            //    user.Add(new KeyValuePair<string, object>(i.Connection + ".access_token", i.AccessToken));
            //    user.Add(new KeyValuePair<string, object>(i.Connection + ".provider", i.Provider));
            //    user.Add(new KeyValuePair<string, object>(i.Connection + ".user_id", i.UserId));
            //});

            // NOTE: uncomment this if you send roles
            // user.Add(new KeyValuePair<string, object>(ClaimTypes.Role, profile.ExtraProperties["roles"]));

            // NOTE: this will set a cookie with all the user claims that will be converted
            //       to a ClaimsPrincipal for each request using the SessionAuthenticationModule HttpModule.
            //       You can choose your own mechanism to keep the user authenticated (FormsAuthentication, Session, etc.)
            FederatedAuthentication.SessionAuthenticationModule.CreateSessionCookie(user);
            MySqlConnection dbconn = new MySqlConnection(CommonClass.connectionstring);

            dbconn.Open();


            string lEmailValidated = "0";

            if (profile.EmailVerified == true)
            {
                lEmailValidated = "1";
            }

            UserClass.MigrateUser(dbconn,
                                  profile.UserId,
                                  profile.FullName,
                                  profile.Email,
                                  lEmailValidated
                                  );

            ShoppingCartClass.Swap_Shopping_Cart(dbconn,
                                                 profile.UserId);


            dbconn.Close();


            context.Response.Redirect("~/Account/Validate.aspx");

            //if (lRecords[3] == "3")
            //{
            //   if (lRecords[1] == "1")
            //  {
            //     context.Response.Redirect("~/Account/Manage.aspx");
            //}
            //if (context.Request.QueryString["r_url"] != null)
            //{
            //  if (context.Request.QueryString["r_url"] == "order")
            //{
            //   context.Response.Redirect("~/order_form.aspx");
            //}
            //}
            //context.Response.Redirect("/");
            //}
            //else
            //{
            //    context.Response.Redirect("~/Account/dashboard.aspx");
            //}
        }