Exemplo n.º 1
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                SqlConnection cnn = new SqlConnection(Properties.Settings.Default.MenuConnString);
                cnn.Open();
                string        sqlQuery   = "Select * from Users where Username ='******'And Password='******'";
                SqlCommand    command    = new SqlCommand(sqlQuery, cnn);
                SqlDataReader dataReader = command.ExecuteReader();

                if (dataReader.HasRows)
                {
                    MessageBox.Show("Success");
                    Menu     form = new Menu(txtUsername.Text);
                    AddDrink add  = new AddDrink(txtUsername.Text);
                    AddFood  addf = new AddFood(txtUsername.Text);
                    txtUsername.Text = "";
                    txtPassword.Text = "";
                    this.Hide();
                    form.ShowDialog();
                    this.Show();
                }
                else
                {
                    MessageBox.Show("Invalid Credentials");
                }
                dataReader.Close();
                command.Dispose();
                cnn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Exemplo n.º 2
0
        // Passing the line to be updated to the respective form
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (lbMeals.SelectedItem != null || lbDrinks.SelectedItem != null)
            {
                try
                {
                    for (int i = 0; i < MenuWorker.foodList.Count; i++)
                    {
                        if (lbMeals.SelectedIndex == i)
                        {
                            FoodItem foodItem = new FoodItem(MenuWorker.foodList[i].Id, MenuWorker.foodList[i].ItemName, MenuWorker.foodList[i].Description,
                                                             MenuWorker.foodList[i].Price, MenuWorker.foodList[i].CostPrice, MenuWorker.foodList[i].FoodType,
                                                             MenuWorker.foodList[i].Cuisine, MenuWorker.foodList[i].UserName);

                            this.Hide();
                            AddFood add = new AddFood(foodItem, lbMeals.SelectedIndex, username);
                            add.ShowDialog();
                        }
                    }
                    for (int i = 0; i < MenuWorker.drinkList.Count; i++)
                    {
                        if (lbDrinks.SelectedIndex == i)
                        {
                            DrinkItem drinkItem = new DrinkItem(MenuWorker.drinkList[i].Id, MenuWorker.drinkList[i].ItemName, MenuWorker.drinkList[i].Description,
                                                                MenuWorker.drinkList[i].Price, MenuWorker.drinkList[i].CostPrice, MenuWorker.drinkList[i].Container,
                                                                MenuWorker.drinkList[i].DrinkType, MenuWorker.drinkList[i].UserName);

                            this.Hide();
                            AddDrink add = new AddDrink(drinkItem, lbDrinks.SelectedIndex, username);
                            add.ShowDialog();
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
            else
            {
                MessageBox.Show("Please Select an item you Wish to Update from the List");
            }
        }
Exemplo n.º 3
0
 // Validating which item needs to be added to the Menu
 private void btnAdd_Click(object sender, EventArgs e)
 {
     if (radFood.Checked)
     {
         this.Hide();
         AddFood add1 = new AddFood(username);
         add1.ShowDialog();
     }
     else if (radDrink.Checked)
     {
         this.Hide();
         AddDrink add2 = new AddDrink(username);
         add2.ShowDialog();
     }
     else if (radDrink.Checked == false && radFood.Checked == false)
     {
         MessageBox.Show("Please Select the item you would like to Add !");
     }
 }