예제 #1
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     if (textBoxFamilia.Text != "" && textBoxImya.Text != "" && textBoxOtchestvo.Text != "" && textBoxDate.Text != "" && textBoxAddress.Text != "" && comboBoxManagers.SelectedItem != null && comboBoxPol.SelectedItem != null)
     {
         FL managers = new FL();
         managers.Familia    = textBoxFamilia.Text;
         managers.Imya       = textBoxImya.Text;
         managers.Otchestvo  = textBoxOtchestvo.Text;
         managers.Date       = Convert.ToDateTime(textBoxDate.Text);
         managers.Address    = textBoxAddress.Text;
         managers.Pol        = comboBoxPol.SelectedItem.ToString();
         managers.Id_manager = Convert.ToInt32(comboBoxManagers.SelectedItem.ToString().Split('.')[0]);
         Program.wtfDb.FL.Add(managers);
         Program.wtfDb.SaveChanges();
         ShowFL();
     }
     else
     {
         MessageBox.Show("Не все поля заполнены", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
예제 #2
0
 private void listViewFL_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewFL.SelectedItems.Count == 1)
     {
         FL fl = listViewFL.SelectedItems[0].Tag as FL;
         textBoxFamilia.Text            = fl.Familia;
         textBoxImya.Text               = fl.Imya;
         textBoxOtchestvo.Text          = fl.Otchestvo;
         textBoxDate.Text               = fl.Date.ToString().Substring(0, 10);
         comboBoxManagers.SelectedIndex = comboBoxManagers.FindString(fl.Id_manager.ToString());
         comboBoxPol.SelectedIndex      = comboBoxManagers.FindString(fl.Pol.ToString());
         textBoxAddress.Text            = fl.Address;
     }
     else
     {
         textBoxFamilia.Text           = "";
         textBoxImya.Text              = "";
         textBoxOtchestvo.Text         = "";
         textBoxDate.Text              = "";
         comboBoxManagers.SelectedItem = null;
         comboBoxPol.SelectedItem      = null;
         textBoxAddress.Text           = "";
     }
 }
예제 #3
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewFL.SelectedItems.Count == 1)
         {
             FL fl = listViewFL.SelectedItems[0].Tag as FL;
             Program.wtfDb.FL.Remove(fl);
             Program.wtfDb.SaveChanges();
             ShowFL();
         }
         textBoxFamilia.Text           = "";
         textBoxImya.Text              = "";
         textBoxOtchestvo.Text         = "";
         textBoxDate.Text              = "";
         comboBoxManagers.SelectedItem = null;
         comboBoxPol.SelectedItem      = null;
         textBoxAddress.Text           = "";
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }