コード例 #1
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            DrinkSet drinkSet = new DrinkSet();

            drinkSet.Dish        = textBoxDish.Text;
            drinkSet.Сomposition = richTextBoxСomposition.Text;
            drinkSet.Prise       = textBoxPrise.Text;
            Program.des.DrinkSet.Add(drinkSet);
            Program.des.SaveChanges();
            ShowDrink();
        }
コード例 #2
0
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     if (listViewDrink.SelectedItems.Count == 1)
     {
         DrinkSet drinkSet = listViewDrink.SelectedItems[0].Tag as DrinkSet;
         drinkSet.Dish        = textBoxDish.Text;
         drinkSet.Сomposition = richTextBoxСomposition.Text;
         drinkSet.Prise       = textBoxPrise.Text;
         Program.des.SaveChanges();
         ShowDrink();
     }
 }
コード例 #3
0
 private void listViewDrink_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewDrink.SelectedItems.Count == 1)
     {
         DrinkSet drinkSet = listViewDrink.SelectedItems[0].Tag as DrinkSet;
         textBoxDish.Text            = drinkSet.Dish;
         richTextBoxСomposition.Text = drinkSet.Сomposition;
         textBoxPrise.Text           = drinkSet.Prise;
     }
     else
     {
         textBoxDish.Text            = "";
         richTextBoxСomposition.Text = "";
         textBoxPrise.Text           = "";
     }
 }
コード例 #4
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewDrink.SelectedItems.Count == 1)
         {
             DrinkSet drinkSet = listViewDrink.SelectedItems[0].Tag as DrinkSet;
             Program.des.DrinkSet.Remove(drinkSet);
             Program.des.SaveChanges();
             ShowDrink();
         }
         textBoxDish.Text            = "";
         richTextBoxСomposition.Text = "";
         textBoxPrise.Text           = "";
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }