Esempio n. 1
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            BakerySet bakery = new BakerySet();

            bakery.Name   = textBoxName.Text;
            bakery.Profit = Convert.ToInt32(textBoxProfit.Text);
            Program.bdSKI.BakerySet.Add(bakery);
            Program.bdSKI.SaveChanges();
            ShowBakery();
        }
Esempio n. 2
0
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     if (listView_Bakery.SelectedItems.Count == 1)
     {
         BakerySet bakery = listView_Bakery.SelectedItems[0].Tag as BakerySet;
         bakery.Name   = textBoxName.Text;
         bakery.Profit = Convert.ToInt32(textBoxProfit.Text);
         Program.bdSKI.SaveChanges();
         ShowBakery();
     }
 }
Esempio n. 3
0
 private void listView_Bakery_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listView_Bakery.SelectedItems.Count == 1)
     {
         BakerySet bakery = listView_Bakery.SelectedItems[0].Tag as BakerySet;
         textBoxName.Text   = bakery.Name;
         textBoxProfit.Text = Convert.ToString(bakery.Profit);
     }
     else
     {
         textBoxName.Text   = "";
         textBoxProfit.Text = "";
     }
 }
Esempio n. 4
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listView_Bakery.SelectedItems.Count == 1)
         {
             BakerySet bakery = listView_Bakery.SelectedItems[0].Tag as BakerySet;
             Program.bdSKI.BakerySet.Remove(bakery);
             Program.bdSKI.SaveChanges();
             ShowBakery();
         }
         textBoxName.Text   = "";
         textBoxProfit.Text = "";
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }