Example #1
0
        protected void LogIn(object sender, EventArgs e)
        {
            Process_Executor exec = new Process_Executor();

            if (username.Text != null)
            {
                if (Password.Text != null)
                {
                    string response = exec.log_in(username.Text, Password.Text);

                    if (response.Contains("error"))
                    {
                        string[] res = response.Split(':');

                        FailureText.Text = res[1];
                    }
                    else
                    {
                        Response.Cookies["user_id"].Value = response;
                        Response.Redirect("~/Default.aspx");
                    }
                }
                else
                {
                    FailureText.Text = "Please Enter a Password";
                }
            }
            else
            {
                FailureText.Text = "Please Enter a Username";
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            HttpCookie cookie = Request.Cookies["user_id"];//getting the user_id
            List <System.Web.UI.HtmlControls.HtmlGenericControl> element_list = new List <System.Web.UI.HtmlControls.HtmlGenericControl>();

            if (cookie != null)//check if the cookie exists
            {
                //init the page builder
                PageElementGenerator peg = new PageElementGenerator();

                //adding each cart breakout element to the page
                Process_Executor exec = new Process_Executor();
                List <System.Web.UI.HtmlControls.HtmlGenericControl> all_prod_display = new List <System.Web.UI.HtmlControls.HtmlGenericControl>();
                List <CART_INFORMATION> data_list = exec.retrieve_cart_data("not_his", cookie.Value);

                int i = 0;
                foreach (CART_INFORMATION data in data_list)
                {
                    i++;
                    //init the page builder
                    PageElementGenerator pe1 = new PageElementGenerator();

                    maindiv.Controls.Add(pe1.generate_cart_summary_product_breakout(i, data));
                }


                //retrieving and updating the cart summary section
                PlaceHolder1.Controls.Add(peg.generate_cart_summary(cookie.Value));
                Total_Q.Text       = peg.generate_cart_summary_total_quantity(cookie.Value);
                Total_Balance.Text = peg.generate_cart_summary_total_balance(cookie.Value);
            }
        }
Example #3
0
        //handles the increase in quantity per item
        protected void increased_quantity(object sender, EventArgs e)
        {
            string[] result = ((Button)sender).ID.Split('_');//attempting to retrive the product id

            Process_Executor exec = new Process_Executor();

            //attempting to find the box that holds the quantity of the product customer wants to purchase
            TextBox box = (TextBox)maindiv.FindControl("box" + result[1]);

            if (box != null)
            {
                int amt = (int.Parse(box.Text) + 1);
                if (amt <= int.Parse(exec.item_purchase_limit(get_user_id(), result[1])))
                {
                    box.Text = (amt).ToString();

                    System.Web.UI.HtmlControls.HtmlGenericControl avail = (System.Web.UI.HtmlControls.HtmlGenericControl)maindiv.FindControl("amt_avail" + result[1]);

                    if (avail != null)
                    {
                        avail.InnerHtml = (int.Parse(avail.InnerHtml) - 1).ToString();
                    }
                }
            }
        }
        protected void clear_cart(object sender, EventArgs e)
        {
            HttpCookie cookie = Request.Cookies["user_id"];//getting the user_id

            Process_Executor exec = new Process_Executor();

            string response = exec.clear_cart(cookie.Value);

            if (response == "CART_EMPTY")
            {
                Response.Redirect("~/Default");
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            HttpCookie cookie = Request.Cookies["user_id"];//getting the user_id

            Process_Executor exec = new Process_Executor();

            if (cookie != null)
            {
                List <CART_INFO_SUMMARY> items = exec.get_cart_summary(cookie.Value);


                List <SessionLineItemOptions> transactions = new List <SessionLineItemOptions>();

                foreach (CART_INFO_SUMMARY transaction_summary in items)
                {
                    SessionLineItemOptions item_list = new SessionLineItemOptions
                    {
                        Name        = transaction_summary.get_product_name(),
                        Description = transaction_summary.get_prod_desc(),
                        Amount      = Convert.ToInt64(decimal.Round(transaction_summary.get_sub_total()).ToString()),
                        Currency    = transaction_summary.get_currecy(),
                        Quantity    = Convert.ToInt64(transaction_summary.get_quantity().ToString()),
                    };

                    transactions.Add(item_list);
                }

                StripeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

                var options = new SessionCreateOptions
                {
                    //todo: change routes to a success or failure page (both woudld be nice )
                    //test card numbers cn=an be found at https://stripe.com/docs/testing#cards
                    //also if error occurs remove above link

                    SuccessUrl         = "https://localhost:44324/CART_DATA/INSERT_HISTORY.aspx",
                    CancelUrl          = "https://localhost:44324/Default.aspx",
                    PaymentMethodTypes = new List <string> {
                        "card",
                    },

                    //line items stores the items that are being checkout to be sent to stripe server
                    LineItems = transactions,
                    Mode      = "payment",
                };

                var     service = new SessionService();
                Session session = service.Create(options);
                sessionId = session.Id;
            }
        }
Example #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            HttpCookie cookie = Request.Cookies["user_id"];//getting the user_id

            Database_Connection con = new Database_Connection();

            //checking if the cookie exists and if it doesn't to create it
            if (cookie == null)
            {
                Unnamed_LoggingOut();

                //creating a default user id
                cookie         = new HttpCookie("user_id");
                cookie.Value   = "0";
                cookie.Expires = DateTime.Now.AddDays(1);
                // cookie.Path = Request.ApplicationPath;
                Response.Cookies.Add(cookie);
            }

            //checking if the user is an default user or custom user and update the UI appropraitely
            if (cookie.Value == "0")
            {
                cart.Visible     = false;
                carts.HRef       = "";
                cart_amount.HRef = "";
                add_prod.Visible = false;
            }
            else
            {
                Process_Executor exec = new Process_Executor();
                cart.Visible          = true;
                carts.HRef            = "~/CART_DATA/CART_INFO.aspx";
                cart_amount.HRef      = "~/CART_DATA/CART_INFO.aspx";
                user.InnerText        = "Hello, " + exec.get_user_name(cookie.Value);
                login_state.Visible   = true;
                logout_state.Visible  = false;
                cart_amount.InnerText = exec.cart_items_count(cookie.Value);


                //checking if the user is an admin user to unlock the admin functionality appropriately
                if (exec.get_user_type(cookie.Value) == "ADMIN")
                {
                    add_prod.Visible = true;
                }
                else
                {
                    add_prod.Visible = false;
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            HttpCookie cookie = Request.Cookies["user_id"];//getting the user_id

            Process_Executor exec = new Process_Executor();

            if (cookie.Value != null)
            {
                string response = exec.complete_order(cookie.Value, "");

                if (response == "ORDER_COMPLETED")
                {
                    Response.Redirect("~/CART_DATA/CART_HIST");
                }
            }
        }
        protected void delete_from_cart(object sender, EventArgs e)
        {
            HttpCookie cookie = Request.Cookies["user_id"];//getting the user_id

            Process_Executor exec = new Process_Executor();

            string[] sub_id = ((Button)sender).ID.Split('_');


            string response = exec.delete_from_cart(cookie.Value, sub_id[1]);

            if (response == "CART_EMPTY")
            {
                Response.Redirect("~/Default");
            }
            else
            {
                Response.Redirect("~/CART_DATA/CART_INFO");
            }
        }
Example #9
0
        //handles the adding of products to the cart
        protected void add_to_cart(object sender, EventArgs e)
        {
            string[] result = ((Button)sender).ID.Split('_'); //attempting to retrive the product id

            HttpCookie cookie = Request.Cookies["user_id"];   //getting the user_id

            //attempting to find the box that holds the quantity of the product customer wants to purchase
            TextBox box = (TextBox)maindiv.FindControl("box" + result[1]);

            Process_Executor exec = new Process_Executor();

            string response = exec.insert_into_cart(cookie.Value, result[1], box.Text);

            //cehcking to see if the process of adding to cart is completed
            if (response == "SUCCESSFULLY_ADDED_TO_CART")
            {
                //System.Web.UI.HtmlControls.HtmlGenericControl temp = (System.Web.UI.HtmlControls.HtmlGenericControl)Master.FindControl("cart_amount");
                //temp.InnerText =''
                Response.Redirect("~/");
            }
        }
        protected void CreateUser_Click(object sender, EventArgs e)
        {
            Process_Executor exec = new Process_Executor();

            password = Password.Text;

            string response = exec.User_Creation(Email.Text, Username.Text, FirstName.Text, MiddleName.Text, LastName.Text, PhoneNo.Text, password);

            if (response == "User Creation Sucessful")
            {
                response = exec.User_Address_Insertion
                           (
                    (FirstName.Text + " " + MiddleName.Text + " " + LastName.Text), Username.Text, password,
                    Street_No.Text, City.Text, State_of_Business.Text, Country.Text, Zip.Text
                           );

                if (response == "COMPLETED")
                {
                    Response.Redirect("~/Account/Login");
                }
            }
        }
Example #11
0
        //function that loads when the page is loading
        protected void Page_Load(object sender, EventArgs e)
        {
            HttpCookie cookie = Request.Cookies["user_id"];//getting the user_id
            List <System.Web.UI.HtmlControls.HtmlGenericControl> element_list = new List <System.Web.UI.HtmlControls.HtmlGenericControl>();


            if (cookie != null)//check if the cookie exists
            {
                if (cookie.Value != "0")
                {
                    //retrieving all the elements
                    Process_Executor exec = new Process_Executor();
                    List <System.Web.UI.HtmlControls.HtmlGenericControl> all_prod_display = new List <System.Web.UI.HtmlControls.HtmlGenericControl>();
                    List <PRODUTCT_DATA> data_list = exec.retrieve_product("", cookie.Value);

                    foreach (PRODUTCT_DATA data in data_list)
                    {
                        //the page builder
                        PageElementGenerator peg = new PageElementGenerator();

                        //declaring default buttons
                        Button add_button     = peg.get_add_to_cart();
                        Button del_button     = peg.get_delete_from_cart();
                        Button clear_button   = new Button();
                        Button addq_button    = peg.get_add_qauntity();
                        Button lessenq_button = peg.get_lessen_quantity();


                        //adding the respective events to the specific button
                        addq_button.Click    += new EventHandler(increased_quantity);
                        lessenq_button.Click += new EventHandler(decreased_quantity);

                        peg.set_add_qauntity(addq_button);

                        peg.set_lessen_qauntity(lessenq_button);

                        //adding the respective events to the specific button
                        add_button.Click += new EventHandler(add_to_cart);

                        peg.set_add_to_cart(add_button);

                        maindiv.Controls.Add(peg.generate_product(data));//adding each product element to the list
                    }
                }
                else
                {
                    //getting page element the default way
                    Process_Executor exec = new Process_Executor();
                    List <System.Web.UI.HtmlControls.HtmlGenericControl> all_prod_display = new List <System.Web.UI.HtmlControls.HtmlGenericControl>();
                    List <PRODUTCT_DATA> data_list = exec.retrieve_product("", "");

                    foreach (PRODUTCT_DATA data in data_list)
                    {
                        //the page builder
                        PageElementGenerator peg = new PageElementGenerator();

                        Button addq_button    = peg.get_add_qauntity();
                        Button lessenq_button = peg.get_lessen_quantity();
                        Button add_button     = peg.get_add_to_cart();

                        //adding the respective events to the specific button
                        add_button.Click += new EventHandler(login_transfer);
                        //adding the respective events to the specific button
                        addq_button.Click    += new EventHandler(increased_quantity);
                        lessenq_button.Click += new EventHandler(decreased_quantity);

                        peg.set_add_qauntity(addq_button);

                        peg.set_lessen_qauntity(lessenq_button);
                        peg.set_add_to_cart(add_button);

                        maindiv.Controls.Add(peg.generate_product(data));//adding each product element to the list
                    }
                }
            }

            ////adding each element to the page
            //foreach(System.Web.UI.HtmlControls.HtmlGenericControl element in element_list)
            //{
            //    maindiv.Controls.Add(element);
            //}
        }