コード例 #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");
        }
コード例 #5
0
        protected void UpdateFields(object sender, EventArgs e)
        {
            PizzaDBEntity db         = new PizzaDBEntity();
            var           name       = PizzaNameDropDown.SelectedValue;
            PizzaDetail   PizzaObj   = new PizzaDetail();
            var           CurrentObj = db.PizzaDetails.Where(p => p.PizzaName == name).FirstOrDefault();

            if (CurrentObj != null)
            {
                desc.Text  = CurrentObj.Description;
                price.Text = CurrentObj.Amount.ToString();
            }
        }
コード例 #6
0
ファイル: Cart.aspx.cs プロジェクト: sooraj-ks/OnlinePizza
        protected void Page_Load(object sender, EventArgs e)
        {
            PizzaDBEntity db     = new PizzaDBEntity();
            var           Object = db.PizzaSelecteds.Where(Obj => Obj.UserDetail.UserStatus == "Active").FirstOrDefault();

            if (Object != null)
            {
                var Amount = from ps in db.PizzaSelecteds
                             where ps.UserName == ps.UserDetail.Username
                             select ps.Amount;
                var sum = Amount.Select(c => c.Value).Sum();
                TotalAmount.Text = Convert.ToString(sum);
            }
            else
            {
                EmptyCart.Text   = "Your cart is Empty!";
                TotalAmount.Text = "";
            }
        }