protected void Button1_Click(object sender, EventArgs e)
        {
            changsiangfooddbEntities ctx = new changsiangfooddbEntities();
            decimal?foodPrice            = ctx.Food_Dishes.Where(x => x.dishName == DdlFoodChoice.SelectedValue).Select(x => x.price).First();
            decimal?sizePrice            = ctx.Sizes.Where(x => x.sizeOption == DddlSizeOption.SelectedValue).Select(x => x.price).First();
            double  price = Convert.ToDouble(foodPrice + sizePrice);

            LabelPrice.Text = string.Format("${0:.##}", price);
        }
Пример #2
0
        protected void BtnLogin_Click(object sender, EventArgs e)
        {
            OrderPage orderPage          = new OrderPage();
            changsiangfooddbEntities ctx = new changsiangfooddbEntities();

            try
            {
                User ur = ctx.Users.Where(x => x.userName == TextBoxUser.Text).First();
                if (ur.password == TextBoxPw.Text)
                {
                    Session["UserName"]   = ur.userName;
                    Session["PersonName"] = ur.personName;
                    Response.Redirect("OrderPage.aspx", true);
                }
            }
            catch (Exception ex)
            {
                LabelAlert.Text = string.Format("Invalid Login Username/Password. Please try again!/n{0}", ex.ToString());
            }
        }
 protected void BtnSubmit_Click(object sender, EventArgs e)
 {
     if (IsNotNull(txtBoxStreetName.Text) == true &&
         IsNotNull(TxtBoxUnit.Text) == true &&
         IsNotNull(TxtBoxPostal.Text) == true)
     {
         string spiceOption = "";
         foreach (ListItem o in CheckBoxSpice.Items)
         {
             if (o.Selected)
             {
                 spiceOption += " " + o.Value.ToString();
             }
         }
         changsiangfooddbEntities ctx = new changsiangfooddbEntities();
         try
         {
             Order newOrder = new Order();
             newOrder.orderUser        = userName;
             newOrder.orderDate        = DateTime.Now;
             newOrder.orderDish        = DdlFoodChoice.SelectedItem.ToString();
             newOrder.orderSize        = DddlSizeOption.SelectedItem.ToString();
             newOrder.orderSpices      = spiceOption;
             newOrder.deliveryLocation = txtBoxStreetName.Text + " " + TxtBoxUnit.Text + "Postal Code " + TxtBoxPostal.Text;
             newOrder.orderStatus      = "Pending";
             ctx.Orders.Add(newOrder);
             ctx.SaveChanges();
             LabelStatus.Text = "Order Submitted Successfully";
             ClearForm();
         }
         catch (Exception ex)
         {
             LabelStatus.Text = ex.ToString();
         }
     }
     else
     {
         LabelStatus.Text = "Error! Please enter the information for all fields.";
     }
 }
        protected void ButtonSubmit_Click(object sender, EventArgs e)
        {
            changsiangfooddbEntities ctx = new changsiangfooddbEntities();

            if (IsNotNull(TextBoxName.Text) == true &&
                IsNotNull(TextBoxPw.Text) == true &&
                IsNotNull(TextBoxName.Text) == true &&
                IsNotNull(TextBoxAddress.Text) == true)
            {
                try
                {
                    User newUser = new User();
                    newUser.userName      = TextBoxUsername.Text;
                    newUser.password      = TextBoxPw.Text;
                    newUser.personName    = TextBoxName.Text;
                    newUser.personAddress = TextBoxAddress.Text;
                    ctx.Users.Add(newUser);
                    ctx.SaveChanges();
                    LabelError.Text = "Account Created Successfully";
                    Response.Redirect("Default.aspx");
                }
                catch (Exception ex)
                {
                    if (ex is DbUpdateException)
                    {
                        LabelError.Text = string.Format("Username already taken.\n Please choose a different Username.");
                    }
                    else
                    {
                        LabelError.Text = string.Format("General Error!!\n {0}", ex.ToString());
                    }
                }
            }
            else
            {
                LabelError.Text = "Error! Please enter the information for all fields.";
            }
        }