Ejemplo n.º 1
0
        private void buttonDel_Click(object sender, EventArgs e)
        {
            try
            {
                if (listViewFizLica.SelectedItems.Count == 1)
                {
                    FizLica flset = listViewFizLica.SelectedItems[0].Tag as FizLica;
                    Program.exdb.FizLica.Remove(flset);
                    Program.exdb.SaveChanges();
                    ShowFizLica();
                }

                comboBoxManager.SelectedItem = null;
                textBoxFirstName.Text        = "";
                comboBoxPol.SelectedItem     = null;
                textBoxMiddleName.Text       = "";
                textBoxLastName.Text         = "";
                textBoxEmail.Text            = "";
                textBoxInn.Text = "";
            }
            catch
            {
                MessageBox.Show("Невозможно удалить, эта запись используется", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 2
0
        private void buttonEdit_Click(object sender, EventArgs e)
        {
            if (listViewFizLica.SelectedItems.Count == 1)
            {
                FizLica flset = listViewFizLica.SelectedItems[0].Tag as FizLica;

                flset.FirstName  = textBoxFirstName.Text;
                flset.MiddleName = textBoxMiddleName.Text;
                flset.LastName   = textBoxLastName.Text;
                flset.Email      = textBoxEmail.Text;
                flset.Inn        = textBoxInn.Text;
                flset.Pol        = comboBoxPol.SelectedItem.ToString();
                flset.IdManager  = Convert.ToInt32(comboBoxManager.SelectedItem.ToString().Split('.')[0]);
                Program.exdb.SaveChanges();
                ShowFizLica();
            }
        }
Ejemplo n.º 3
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     if (comboBoxManager.SelectedItem != null && textBoxFirstName.Text != "" && comboBoxPol.SelectedItem != null && textBoxEmail.Text != "" &&
         textBoxMiddleName.Text != "" && textBoxLastName.Text != "" && textBoxInn.Text != "")
     {
         FizLica flset = new FizLica();
         flset.IdManager  = Convert.ToInt32(comboBoxManager.SelectedItem.ToString().Split('.')[0]);
         flset.FirstName  = (textBoxFirstName.Text);
         flset.Pol        = (comboBoxPol.SelectedItem.ToString());
         flset.MiddleName = textBoxMiddleName.Text;
         flset.LastName   = textBoxLastName.Text;
         flset.Email      = textBoxEmail.Text;
         flset.Inn        = textBoxInn.Text;
         flset.Id.ToString();
         Program.exdb.FizLica.Add(flset);
         Program.exdb.SaveChanges();
         ShowFizLica();
     }
     else
     {
         MessageBox.Show("Данные не выбраны", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Ejemplo n.º 4
0
 private void listViewManager_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewFizLica.SelectedItems.Count == 1)
     {
         FizLica flset = listViewFizLica.SelectedItems[0].Tag as FizLica;
         textBoxFirstName.Text         = flset.FirstName;
         textBoxMiddleName.Text        = flset.MiddleName;
         textBoxLastName.Text          = flset.LastName;
         textBoxEmail.Text             = flset.Email;
         textBoxInn.Text               = flset.Inn;
         comboBoxPol.SelectedIndex     = comboBoxPol.FindString(flset.Pol.ToString());
         comboBoxManager.SelectedIndex = comboBoxManager.FindString(flset.IdManager.ToString());
     }
     else
     {
         textBoxFirstName.Text        = "";
         textBoxMiddleName.Text       = "";
         textBoxLastName.Text         = "";
         textBoxEmail.Text            = "";
         comboBoxPol.SelectedItem     = null;
         comboBoxManager.SelectedItem = null;
         textBoxInn.Text = "";
     }
 }