Beispiel #1
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     if (textBoxName.Text != "" && textBoxAddress.Text != "" && textBoxINN.Text != "" && textBoxKPP.Text != "" && comboBoxManagers.SelectedItem != null)
     {
         UL managers = new UL();
         managers.Name       = textBoxName.Text;
         managers.Address    = textBoxAddress.Text;
         managers.INN        = textBoxINN.Text;
         managers.KPP        = textBoxKPP.Text;
         managers.Id_manager = Convert.ToInt32(comboBoxManagers.SelectedItem.ToString().Split('.')[0]);
         Program.wtfDb.UL.Add(managers);
         Program.wtfDb.SaveChanges();
         ShowUL();
     }
     else
     {
         MessageBox.Show("Не все поля заполнены", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Beispiel #2
0
 private void listViewUL_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewUL.SelectedItems.Count == 1)
     {
         UL fl = listViewUL.SelectedItems[0].Tag as UL;
         textBoxName.Text               = fl.Name;
         textBoxINN.Text                = fl.INN;
         textBoxKPP.Text                = fl.KPP;
         textBoxAddress.Text            = fl.Address;
         comboBoxManagers.SelectedIndex = comboBoxManagers.FindString(fl.Id_manager.ToString());
     }
     else
     {
         textBoxName.Text              = "";
         textBoxINN.Text               = "";
         textBoxKPP.Text               = "";
         textBoxAddress.Text           = "";
         comboBoxManagers.SelectedItem = null;
     }
 }
Beispiel #3
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewUL.SelectedItems.Count == 1)
         {
             UL managers = listViewUL.SelectedItems[0].Tag as UL;
             Program.wtfDb.UL.Remove(managers);
             Program.wtfDb.SaveChanges();
             ShowUL();
         }
         textBoxName.Text              = "";
         textBoxINN.Text               = "";
         textBoxKPP.Text               = "";
         textBoxAddress.Text           = "";
         comboBoxManagers.SelectedItem = null;
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }