private void Button_register_Click(object sender, EventArgs e) { if (button_register.Text.Equals("ADD")) { foreach (TextBox box in textBoxes) { if (box.Text.Trim().Equals("")) { MessageBox.Show("Please do not leave any empty fields."); return; } } currentEmployee = new Employee(controller.GetRoleId(comboBox_role.Text), textbox_name.Text, textbox_surname.Text, Char.Parse(comboBox_gender.Text.Substring(0, 1)), Int32.Parse(textbox_age.Text), textbox_email.Text, long.Parse(textbox_phone_number.Text), textbox_address.Text, DateTime.Parse(date_birth.Text), DateTime.Parse(date_joined.Text)); controller.AddEmployee(currentEmployee); MessageBox.Show("Employee " + currentEmployee.Name + " registered."); EmployeeChanged(comboBox.Items.Count); } else { Employee currentEmployee = controller.GetEmployee(int.Parse(comboBox.Text.Split(' ')[0])); Employee newEmployee = new Employee(controller.GetRoleId(comboBox_role.Text), textbox_name.Text, textbox_surname.Text, Char.Parse(comboBox_gender.Text.Substring(0, 1)), Int32.Parse(textbox_age.Text), textbox_email.Text, long.Parse(textbox_phone_number.Text), textbox_address.Text, DateTime.Parse(date_birth.Text), DateTime.Parse(date_joined.Text)); if (currentEmployee.GetDifferences(newEmployee).Equals("")) { MessageBox.Show("Nothing has changed."); return; } controller.ChangeEmployee(currentEmployee, newEmployee); MessageBox.Show("Employee " + currentEmployee.Name + " changed."); EmployeeChanged(comboBox.SelectedIndex); } }