コード例 #1
0
        protected void AddToCart_Click(object sender, EventArgs e)
        {
            PizzaDBEntity db            = new PizzaDBEntity();
            PizzaSelected pizzaSelected = new PizzaSelected();
            var           currentUser   = db.UserDetails.Where(Obj => Obj.UserStatus == "Active").FirstOrDefault();;
            var           PizzaExists   = db.PizzaSelecteds.Where(obje => obje.PizzaDetail.PizzaName == PizzaNameDropDown.SelectedValue && obje.UserName == currentUser.Username).FirstOrDefault();

            if (PizzaExists != null)
            {
                var tempNumber = PizzaExists.NumberOfPizza;
                PizzaExists.NumberOfPizza = tempNumber + Convert.ToInt32(NumofPizzas.Text);
                PizzaExists.Amount        = PizzaExists.NumberOfPizza * PizzaExists.PizzaDetail.Amount;
                db.SaveChanges();
            }
            else
            {
                var Object = db.PizzaDetails.Where(Obj => Obj.PizzaName == PizzaNameDropDown.SelectedValue).FirstOrDefault();
                pizzaSelected.PizzaID       = Object.PizzaID;
                pizzaSelected.NumberOfPizza = Convert.ToInt32(NumofPizzas.Text);
                pizzaSelected.Amount        = pizzaSelected.NumberOfPizza * Object.Amount;
                pizzaSelected.UserName      = Session["UserName"].ToString();
                db.PizzaSelecteds.Add(pizzaSelected);
                db.SaveChanges();
            }
            Response.Redirect("Cart.aspx");
        }
コード例 #2
0
ファイル: Login.aspx.cs プロジェクト: sooraj-ks/OnlinePizza
        protected void LoginButton_Click(object sender, EventArgs e)
        {
            PizzaDBEntity db    = new PizzaDBEntity();
            UserDetail    User  = new UserDetail();
            var           check = db.UserDetails.Where(Obj => Obj.Username == Username.Text).FirstOrDefault();

            if (check != null)
            {
                if (check.Password == Password.Text)
                {
                    Session["User"]     = check.Name;
                    Session["UserName"] = check.Username;
                    check.UserStatus    = "Active";
                    db.SaveChanges();
                    FormsAuthentication.RedirectFromLoginPage(Username.Text, CheckBox1.Checked);
                }
                else
                {
                    Alert.Text = "Password is Incorrect!";
                }
            }
            else
            {
                Alert.Text = "Username is Incorrect!";
            }
        }
コード例 #3
0
        protected void RegButton_Click(object sender, EventArgs e)
        {
            PizzaDBEntity db   = new PizzaDBEntity();
            UserDetail    User = new UserDetail();

            if (Username.Text != null)
            {
                var check = db.UserDetails.Where(Obj => Obj.Username == Username.Text).FirstOrDefault();
                if (check == null)
                {
                    User.Name        = InputName.Text;
                    User.Username    = Username.Text;
                    User.Password    = Password.Text;
                    User.PhoneNumber = PhoneNumber.Text;
                    User.Address     = Address.Text;
                    db.UserDetails.Add(User);
                    db.SaveChanges();
                    Response.Redirect("~/Pages/Login.aspx");
                }
                else
                {
                    Alert.Text = "Username already exists!";
                }
            }
        }
コード例 #4
0
        protected void LogoutMethod(object sender, EventArgs e)
        {
            PizzaDBEntity db          = new PizzaDBEntity();
            var           CurrentUser = db.UserDetails.Where(Current => Current.UserStatus == "Active").FirstOrDefault();

            CurrentUser.UserStatus = null;
            db.SaveChanges();
            FormsAuthentication.SignOut();
            Response.Redirect("~/Pages/Login.aspx");
        }