示例#1
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            SecondCourseSet secondCourseSet = new SecondCourseSet();

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