Example #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            zakupchik zak = new zakupchik();

            zak.pok   = textBox1.Text;
            zak.kol   = Convert.ToInt32(textBox2.Text);
            zak.price = Convert.ToInt32(textBox3.Text);
            Program.kafe.zakupchik.Add(zak);
            Program.kafe.SaveChanges();
            ShowZak();
        }
Example #2
0
 private void button2_Click(object sender, EventArgs e)
 {
     try
     {
         if (listView1.SelectedItems.Count == 1)
         {
             zakupchik zak = listView1.SelectedItems[0].Tag as zakupchik;
             Program.kafe.zakupchik.Remove(zak);
             Program.kafe.SaveChanges();
             ShowZak();
         }
         textBox1.Text = "";
         textBox2.Text = "";
         textBox3.Text = "";
     }
     catch
     {
         MessageBox.Show("Невозможно удалить эту запись!", "ОШИБКА!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }