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

            ob.Name  = textBoxName.Text;
            ob.Price = textBoxPrice.Text;
            ob.ColOb = textBoxColOb.Text;
            Program.KPDB.Oborud.Add(ob);
            Program.KPDB.SaveChanges();
            ShowOborud();
        }
Esempio n. 2
0
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     if (listViewOborud.SelectedItems.Count == 1)
     {
         Oborud ob = listViewOborud.SelectedItems[0].Tag as Oborud;
         ob.Name  = textBoxName.Text;
         ob.Price = textBoxPrice.Text;
         ob.ColOb = textBoxColOb.Text;
         Program.KPDB.SaveChanges();
         ShowOborud();
     }
 }
Esempio n. 3
0
 private void listViewOborud_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewOborud.SelectedItems.Count == 1)
     {
         Oborud ob = listViewOborud.SelectedItems[0].Tag as Oborud;
         textBoxName.Text  = ob.Name;
         textBoxPrice.Text = ob.Price;
         textBoxColOb.Text = ob.ColOb;
     }
     else
     {
         textBoxName.Text  = "";
         textBoxPrice.Text = "";
         textBoxColOb.Text = "";
     }
 }
Esempio n. 4
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewOborud.SelectedItems.Count == 1)
         {
             Oborud ob = listViewOborud.SelectedItems[0].Tag as Oborud;
             Program.KPDB.Oborud.Remove(ob);
             Program.KPDB.SaveChanges();
             ShowOborud();
         }
         textBoxName.Text  = "";
         textBoxPrice.Text = "";
         textBoxColOb.Text = "";
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }