Example #1
0
        /// <summary>
        /// Displaying the details of the user
        /// </summary>



        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (Session["name"] != null)
                {
                    PizzaDbEntities db   = new PizzaDbEntities();
                    string          name = Session["name"].ToString();
                    //Fetching the details
                    User_Table exist = (from x in db.User_Table
                                        where x.UserName == name
                                        select x).FirstOrDefault();
                    phone.Text   = exist.Phono;
                    address.Text = exist.Address;
                }
                else
                {
                    FormsAuthentication.SignOut();
                }
            }
            catch (Exception)
            {
                Response.Redirect("UserError.aspx");
            }
        }
Example #2
0
        /// <summary>
        /// Checking for username and password
        /// </summary>

        protected void loginbtb_Click(object sender, EventArgs e)
        {
            try
            {
                PizzaDbEntities db = new PizzaDbEntities();

                User_Table exist = (from x in db.User_Table where x.UserName == nametxt.Text select x).FirstOrDefault();
                //checking if username is correct
                if (exist != null)
                {
                    //cheching if password is correct
                    if (exist.Password == passwordtxt.Text)
                    {
                        Session["name"] = nametxt.Text;
                        FormsAuthentication.RedirectFromLoginPage(nametxt.Text, true);
                    }
                    //when the password is wrong
                    else
                    {
                        alertlbl.Text = "Invalid password!!";
                    }
                }


                //when user name is wrong
                else
                {
                    alertlbl.Text = "Invalid Username!!";
                }
            }
            catch (Exception)
            {
                Response.Redirect("UserError.aspx");
            }
        }
Example #3
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");
            }
        }
Example #4
0
        public void cartcalc()
        {
            using (PizzaDbEntities db = new PizzaDbEntities())
            {
                var name       = Convert.ToString(Session["name"]);
                int?listincart = (from a in db.Cart_Table
                                  where a.Username == name && a.State == 1
                                  select a.Quantity).Sum();
                string count = string.Format("Cart {0}", listincart);

                Label countlbl = (Label)(LoginView1.FindControl("Label1"));

                countlbl.Text = count;
            }
        }
Example #5
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");
        }
Example #6
0
        public void calculation()
        {
            PizzaDbEntities db = new PizzaDbEntities();

            // Response.Redirect(Request.RawUrl);
            Label2.Text = 0.ToString();
            var name       = Session["name"].ToString();
            var listincart = from a in db.Cart_Table
                             where a.Username == name && a.State == 1
                             select a;
            //calculating the total price
            var total = listincart.AsEnumerable().Sum(obj => obj.Amount);

            if (total == 0)
            {
                Response.Redirect("Empty.aspx");
            }
            Label2.Text = total.ToString();
        }