Пример #1
0
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     if (listViewEmployes.SelectedItems.Count == 1)
     {
         if (textBoxFirstName.Text != "" && textBoxLastName.Text != "" && textBoxDoB.Text != "" && comboBoxProfession.SelectedItem != null &&
             textBoxLogin.Text != "" && textBoxPassword.Text != "")
         {
             DateTime temp;
             bool     date = DateTime.TryParse(textBoxDoB.Text, out temp);
             if (!date)
             {
                 MessageBox.Show("Введите дату в формате: ДД.ММ.ГГГГ", "Неверный формат даты", MessageBoxButtons.OK);
             }
             else
             {
                 EmployesSet employesSet = listViewEmployes.SelectedItems[0].Tag as EmployesSet;
                 employesSet.Name          = textBoxFirstName.Text;
                 employesSet.MiddleName    = textBoxMiddleName.Text;
                 employesSet.LastName      = textBoxLastName.Text;
                 employesSet.DateOfBirth   = Convert.ToDateTime(textBoxDoB.Text);
                 employesSet.Id_Profession = Convert.ToInt32(comboBoxProfession.SelectedItem.ToString().Split('.')[0]);
                 employesSet.Login         = textBoxLogin.Text;
                 employesSet.Password      = textBoxPassword.Text;
                 Program.vp.SaveChanges();
                 ShowEmployes();
             }
         }
         else
         {
             MessageBox.Show("Заполните все необходимые поля", "Невозможно внести данные!", MessageBoxButtons.OK);
         }
     }
 }
Пример #2
0
 private void listViewEmployes_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewEmployes.SelectedItems.Count == 1)
     {
         EmployesSet employesSet = listViewEmployes.SelectedItems[0].Tag as EmployesSet;
         textBoxFirstName.Text            = employesSet.Name;
         textBoxMiddleName.Text           = employesSet.MiddleName;
         textBoxLastName.Text             = employesSet.LastName;
         textBoxDoB.Text                  = employesSet.DateOfBirth.ToString().Substring(0, employesSet.DateOfBirth.ToString().Length - 8);
         comboBoxProfession.SelectedIndex = comboBoxProfession.FindString(employesSet.Id_Profession.ToString());
         textBoxLogin.Text                = employesSet.Login;
         textBoxPassword.Text             = employesSet.Password;
     }
     else
     {
         textBoxFirstName.Text           = "";
         textBoxMiddleName.Text          = "";
         textBoxLastName.Text            = "";
         textBoxDoB.Text                 = "";
         comboBoxProfession.SelectedItem = null;
         textBoxLogin.Text               = "";
         textBoxPassword.Text            = "";
     }
 }
Пример #3
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewEmployes.SelectedItems.Count == 1)
         {
             EmployesSet employesSet = listViewEmployes.SelectedItems[0].Tag as EmployesSet;
             Program.vp.EmployesSet.Remove(employesSet);
             Program.vp.SaveChanges();
             ShowEmployes();
         }
         textBoxFirstName.Text           = "";
         textBoxMiddleName.Text          = "";
         textBoxLastName.Text            = "";
         textBoxDoB.Text                 = "";
         comboBoxProfession.SelectedItem = null;
         textBoxLogin.Text               = "";
         textBoxPassword.Text            = "";
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }