private void buttonSubmit_Click(object sender, EventArgs e)
{
if (this.isValidData())
{
Handler h = new Handler();
//Create new Lecturer object
Lecturer lecturer = new Lecturer(textBoxID.Text, textBoxFirstName_.Text, textBoxLastName_.Text, textBoxAddress.Text, textBoxEmail.Text, textBoxTel.Text, dateTimePicker_.Value, textBoxLogin.Text, textBoxPassword.Text, comboBoxDepartment.Text, comboBoxDegree_.Text, Int32.Parse(textBoxHoursPerWeek.Text != "" ? textBoxHoursPerWeek.Text : "0"));
if (lecturer != null)
{
//Insert into DataBase Lecturer table
if (h.Update <Lecturer>(lecturer))
{
if (this.parent != null)
{
this.parent.RefreshDataSource();
}
MessageBox.Show("Lecturer " + lecturer.FirstName + " " + lecturer.LastName + " was successful updated.");
this.Close();
}
else
{
MessageBox.Show("An error accrued when updating this lecturer, please try again.");
}
}
}
}