Exemplo n.º 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);
         }
     }
 }
Exemplo n.º 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();
         }
     }
 }
Exemplo n.º 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); }
 }
Exemplo n.º 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;
     }
 }
Exemplo n.º 5
0
 public FormRegistration(StaffSet staff)
 {
     InitializeComponent();
     user.Id_Staff = staff.Id;
 }