Example #1
0
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     if (listViewStaff.SelectedItems.Count == 1)
     {
         if (textBoxLastName.Text != "" && textBoxFirstName.Text != "" &&
             textBoxMiddleName.Text != "" && textBoxPhone.Text != "" &&
             textBoxEmail.Text != "" && textBoxPosition.Text != "")
         {
             StaffSet staffSet = listViewStaff.SelectedItems[0].Tag as StaffSet;
             staffSet.LastName   = textBoxLastName.Text;
             staffSet.FirstName  = textBoxFirstName.Text;
             staffSet.MiddleName = textBoxMiddleName.Text;
             staffSet.Phone      = textBoxPhone.Text;
             staffSet.Email      = textBoxEmail.Text;
             staffSet.Position   = textBoxPosition.Text;
             if (comboBoxDepartment.SelectedItem != null)
             {
                 staffSet.Id_Department = Convert.ToInt32(comboBoxDepartment.SelectedItem.ToString().Split('.')[0]);
             }
             else
             {
                 staffSet.Id_Department = null;
             }
             Program.RBS_Project.SaveChanges();
             ShowStaff();
         }
         else
         {
             MessageBox.Show("Заполнены не все поля!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
     }
 }
Example #2
0
 private void buttonRegistration_Click(object sender, EventArgs e)
 {
     if (listViewStaff.SelectedItems.Count == 1)
     {
         StaffSet staff = listViewStaff.SelectedItems[0].Tag as StaffSet;
         bool     found = false;
         Users    user  = new Users();
         foreach (Users users in Program.RBS_Project.Users)
         {
             if (staff.Id == users.Id_Staff)
             {
                 found = true; user = users;
             }
         }
         if (found)
         {
             Form formChangePassword = new FormChangePassword(user);
             formChangePassword.Show();
         }
         else
         {
             Form formRegistration = new FormRegistration(staff);
             formRegistration.Show();
         }
     }
 }
Example #3
0
 private void buttonDelete_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewStaff.SelectedItems.Count == 1)
         {
             StaffSet staff = listViewStaff.SelectedItems[0].Tag as StaffSet;
             bool     found = false;
             Users    user  = new Users();
             foreach (Users users in Program.RBS_Project.Users)
             {
                 if (staff.Id == users.Id_Staff)
                 {
                     found = true; user = users;
                 }
             }
             if (found)
             {
                 Program.RBS_Project.Users.Remove(user);
             }
             Program.RBS_Project.StaffSet.Remove(staff);
             Program.RBS_Project.SaveChanges();
             ShowStaff();
         }
         textBoxLastName.Text            = "";
         textBoxFirstName.Text           = "";
         textBoxMiddleName.Text          = "";
         textBoxPhone.Text               = "";
         textBoxEmail.Text               = "";
         textBoxPosition.Text            = "";
         comboBoxDepartment.SelectedItem = null;
     }
     catch { MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error); }
 }
Example #4
0
 private void listViewStaff_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewStaff.SelectedItems.Count == 1)
     {
         StaffSet staff = listViewStaff.SelectedItems[0].Tag as StaffSet;
         textBoxLastName.Text             = staff.LastName;
         textBoxFirstName.Text            = staff.FirstName;
         textBoxMiddleName.Text           = staff.MiddleName;
         textBoxPhone.Text                = staff.Phone;
         textBoxEmail.Text                = staff.Email;
         textBoxPosition.Text             = staff.Position;
         comboBoxDepartment.SelectedIndex = comboBoxDepartment.FindString(staff.Id_Department.ToString());
     }
     else
     {
         textBoxLastName.Text            = "";
         textBoxFirstName.Text           = "";
         textBoxMiddleName.Text          = "";
         textBoxPhone.Text               = "";
         textBoxEmail.Text               = "";
         textBoxPosition.Text            = "";
         comboBoxDepartment.SelectedItem = null;
     }
 }
 public FormRegistration(StaffSet staff)
 {
     InitializeComponent();
     user.Id_Staff = staff.Id;
 }