Пример #1
0
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     if (listViewSupplier.SelectedItems.Count == 1)
     {
         SuppliersSet suppliersSet = listViewSupplier.SelectedItems[0].Tag as SuppliersSet;
         suppliersSet.IdProduct = Convert.ToInt32(comboBoxType.SelectedItem.ToString().Split('.')[0]);
         suppliersSet.Name      = textBoxName.Text;
         suppliersSet.Phone     = textBoxPhone.Text;
         suppliersSet.Email     = textBoxEmail.Text;
         Program.zooDb.SaveChanges();
         ShowSupplier();
     }
 }
Пример #2
0
 private void listViewSupplier_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewSupplier.SelectedItems.Count == 1)
     {
         SuppliersSet suppliersSet = listViewSupplier.SelectedItems[0].Tag as SuppliersSet;
         comboBoxType.SelectedIndex = comboBoxType.FindString(suppliersSet.IdProduct.ToString());
         textBoxName.Text           = suppliersSet.Name;
         textBoxPhone.Text          = suppliersSet.Phone;
         textBoxEmail.Text          = suppliersSet.Email;
     }
     else
     {
         comboBoxType.SelectedItem = null;
         textBoxName.Text          = "";
         textBoxPhone.Text         = "";
         textBoxEmail.Text         = "";
     }
 }
Пример #3
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     if (comboBoxType.SelectedItem != null)
     {
         SuppliersSet suppliersSet = new SuppliersSet();
         suppliersSet.IdProduct = Convert.ToInt32(comboBoxType.SelectedItem.ToString().Split('.')[0]);
         suppliersSet.Name      = textBoxName.Text;
         suppliersSet.Phone     = textBoxPhone.Text;
         suppliersSet.Email     = textBoxEmail.Text;
         Program.zooDb.SuppliersSet.Add(suppliersSet);
         Program.zooDb.SaveChanges();
         ShowSupplier();
     }
     else
     {
         MessageBox.Show("Данные не выбраны", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Пример #4
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewSupplier.SelectedItems.Count == 1)
         {
             SuppliersSet suppliersSet = listViewSupplier.SelectedItems[0].Tag as SuppliersSet;
             Program.zooDb.SuppliersSet.Remove(suppliersSet);
             Program.zooDb.SaveChanges();
             ShowSupplier();
         }
         comboBoxType.SelectedItem = null;
         textBoxName.Text          = "";
         textBoxPhone.Text         = "";
         textBoxEmail.Text         = "";
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }