Example #1
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            SoupsSet soupsSet = new SoupsSet();

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