Пример #1
0
        protected void confirmbtb_Click(object sender, EventArgs e)
        {
            try
            {
                PizzaDbEntities db = new PizzaDbEntities();
                //Checking if user already exists
                User_Table exist = (from x in db.User_Table
                                    where x.UserName == nametxt.Text
                                    select x).FirstOrDefault();

                if (exist != null)
                {
                    alertlbl.Text = "username already exist";
                }
                //Getting the user information from the user
                else
                {
                    User_Table ob = new User_Table();
                    ob.UserName = nametxt.Text;
                    ob.Phono    = phonotxt.Text;
                    ob.Password = passwordtxt.Text;
                    ob.Address  = addtext.Text;
                    db.User_Table.Add(ob);
                    db.SaveChanges();
                    Response.Redirect("Login.aspx");
                }
            }
            catch (Exception)
            {
                Response.Redirect("UserError.aspx");
            }
        }
Пример #2
0
        /// <summary>
        /// Updating the delivered orders
        /// </summary>

        protected void confirmbtn_Click(object sender, EventArgs e)
        {
            PizzaDbEntities db   = new PizzaDbEntities();
            var             name = Session["name"].ToString();
            Cart_Table      c    = new Cart_Table();
            var             ob1  = (from a in db.Cart_Table where a.State == 1 && a.Username == name select a);

            foreach (var item in ob1)
            {
                item.State = 0;
            }

            db.SaveChanges();
            Response.Redirect("Final.aspx");
        }
Пример #3
0
        /// <summary>
        /// Adding the datas to the cart_table
        /// </summary>


        protected void addtochatrbtn_Click(object sender, EventArgs e)
        {
            var name = Session["name"].ToString();

            int id;


            int.TryParse(DropDownList1.SelectedValue, out id);//To know the id of selected pizza
            if (id == 0)
            {
                alertlbl.Text = "please select pizza name!!!";
            }
            else
            {
                var        pname = Session["pizzaname"].ToString();
                Cart_Table ob    = new Cart_Table();
                //Getting the details of the pizza
                Pizza_Table ob2 = (from y in db.Pizza_Table where y.PizzaName == pname select y).FirstOrDefault();
                //Getting the details if the pizza was earlier selected
                Cart_Table ob3 = (from z in db.Cart_Table where z.Pizza_Table.PizzaName == pname && z.Username == name && z.State == 1 select z).FirstOrDefault();

                //If pizza name already present
                if (ob3 != null)
                {
                    ob3.Quantity = Convert.ToInt32(quantitytxt.Text) + ob3.Quantity;
                    ob3.Amount   = ob3.Quantity * ob2.PizzaPrice;
                }
                //If same pizza does not exist
                else
                {
                    ob.Username = Session["name"].ToString();
                    ob.PizzaId  = ob2.PizzaId;
                    ob.Quantity = Convert.ToInt32(quantitytxt.Text);
                    ob.Amount   = ob.Quantity * ob2.PizzaPrice;
                    ob.State    = 1;
                    db.Cart_Table.Add(ob);
                }

                // adding the details to the cart

                db.SaveChanges();
                Response.Redirect("Confirm.aspx");
            }
        }