Пример #1
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            ManagerSet managerSet = new ManagerSet();

            managerSet.FIO   = textBoxFIO.Text;
            managerSet.Adres = textBoxAdres.Text;
            managerSet.Phone = textBoxPhone.Text;
            Program.shDb.ManagerSet.Add(managerSet);
            Program.shDb.SaveChanges();
            ShowManager();
        }
Пример #2
0
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     if (listViewManager.SelectedItems.Count == 1)
     {
         ManagerSet managerSet = listViewManager.SelectedItems[0].Tag as ManagerSet;
         managerSet.FIO   = textBoxFIO.Text;
         managerSet.Adres = textBoxAdres.Text;
         managerSet.Phone = textBoxPhone.Text;
         Program.shDb.SaveChanges();
         ShowManager();
     }
 }
Пример #3
0
 private void listViewManager_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewManager.SelectedItems.Count == 1)
     {
         ManagerSet managerSet = listViewManager.SelectedItems[0].Tag as ManagerSet;
         textBoxFIO.Text   = managerSet.FIO;
         textBoxAdres.Text = managerSet.Adres;
         textBoxPhone.Text = managerSet.Phone;
     }
     else
     {
         textBoxFIO.Text   = "";
         textBoxAdres.Text = "";
         textBoxPhone.Text = "";
     }
 }
Пример #4
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewManager.SelectedItems.Count == 1)
         {
             ManagerSet managerSet = listViewManager.SelectedItems[0].Tag as ManagerSet;
             Program.shDb.ManagerSet.Remove(managerSet);
             Program.shDb.SaveChanges();
             ShowManager();
         }
         textBoxFIO.Text   = "";
         textBoxAdres.Text = "";
         textBoxPhone.Text = "";
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }