private void btnSave_Click(object sender, EventArgs e) { if (txtStudentNumber.Text == "Student Number" || string.IsNullOrEmpty(txtStudentNumber.Text)) { MessageBox.Show("Please indicate the student number.", "Add Student", MessageBoxButtons.OK, MessageBoxIcon.Error); txtStudentNumber.Text = ""; txtStudentNumber.Focus(); return; } else { if (txtFirstName.Text == "First Name" || string.IsNullOrEmpty(txtFirstName.Text)) { MessageBox.Show("Please indicate the first name.", "Add Student", MessageBoxButtons.OK, MessageBoxIcon.Error); txtFirstName.Text = ""; txtFirstName.Focus(); return; } else { if (txtLastName.Text == "Last Name" || string.IsNullOrEmpty(txtLastName.Text)) { MessageBox.Show("Please indicate the last name.", "Add Student", MessageBoxButtons.OK, MessageBoxIcon.Error); txtLastName.Text = ""; txtLastName.Focus(); return; } else { if (txtLastName.Text == "Last Name" || string.IsNullOrEmpty(txtLastName.Text)) { MessageBox.Show("Please indicate the last name.", "Add Student", MessageBoxButtons.OK, MessageBoxIcon.Error); txtLastName.Text = ""; txtLastName.Focus(); return; } else { if (cbCourse.SelectedIndex == 0 || cbCourse.SelectedIndex == -1) { MessageBox.Show("Please indicate the course.", "Add Student", MessageBoxButtons.OK, MessageBoxIcon.Error); cbCourse.Focus(); return; } else { if (cbYearLevel.SelectedIndex == 0 || cbYearLevel.SelectedIndex == -1) { MessageBox.Show("Please indicate the year level.", "Add Student", MessageBoxButtons.OK, MessageBoxIcon.Error); cbYearLevel.Focus(); return; } else { if (cbStatus.SelectedIndex == 0 || cbStatus.SelectedIndex == -1) { MessageBox.Show("Please indicate the status.", "Add Student", MessageBoxButtons.OK, MessageBoxIcon.Error); cbStatus.Focus(); return; } else { string student_number = txtStudentNumber.Text; string first_name = txtFirstName.Text; string middle_name = (txtMiddleName.Text == "Middle Name") ? string.Empty : txtMiddleName.Text; string last_name = txtLastName.Text; string contact_number = (txtContactNumber.Text == "Contact Number") ? string.Empty : txtContactNumber.Text; string email = (txtEmail.Text == "Email") ? string.Empty : txtEmail.Text; int course_id = Convert.ToInt32(cbCourse.SelectedValue); string year_level = cbYearLevel.Text; string status = cbStatus.Text; Byte[] profile_picture = classes.Configuration.ConvertScreenCaptureToByte(pbPreview.Image); personal_information = new classes.PersonalInformation(); if (personal_information.insert_personal_information(first_name, middle_name, last_name, contact_number, email, profile_picture)) { student = new classes.Student(); if (student.insert_student(student_number, course_id, year_level, status)) { account = new classes.Accounts(); if (account.insert_account(student_number, "Student")) { MessageBox.Show((first_name + " " + last_name).ToUpper() + " has been added!", "Add Student", MessageBoxButtons.OK, MessageBoxIcon.Information); includes.uc.frmDashboard.admin.mu.ucManageStudent.instance.display_student_data(); this.Close(); } else { return; } } else { return; } } else { return; } } } } } } } } }
private void btnSave_Click(object sender, EventArgs e) { if (txtEmployeeID.Text == "Employee ID" || string.IsNullOrEmpty(txtEmployeeID.Text)) { MessageBox.Show("Please indicate the employee id.", "Add Employee", MessageBoxButtons.OK, MessageBoxIcon.Error); txtEmployeeID.Text = ""; txtEmployeeID.Focus(); return; } else { if (txtFirstName.Text == "First Name" || string.IsNullOrEmpty(txtFirstName.Text)) { MessageBox.Show("Please indicate the first name.", "Add Employee", MessageBoxButtons.OK, MessageBoxIcon.Error); txtFirstName.Text = ""; txtFirstName.Focus(); return; } else { if (txtLastName.Text == "Last Name" || string.IsNullOrEmpty(txtLastName.Text)) { MessageBox.Show("Please indicate the last name.", "Add Employee", MessageBoxButtons.OK, MessageBoxIcon.Error); txtLastName.Text = ""; txtLastName.Focus(); return; } else { if (txtLastName.Text == "Last Name" || string.IsNullOrEmpty(txtLastName.Text)) { MessageBox.Show("Please indicate the last name.", "Add Employee", MessageBoxButtons.OK, MessageBoxIcon.Error); txtLastName.Text = ""; txtLastName.Focus(); return; } else { if (cbDepartment.SelectedIndex == 0 || cbDepartment.SelectedIndex == -1) { MessageBox.Show("Please indicate the department.", "Add Employee", MessageBoxButtons.OK, MessageBoxIcon.Error); cbDepartment.Focus(); return; } else { if (cbPosition.SelectedIndex == 0 || cbPosition.SelectedIndex == -1) { MessageBox.Show("Please indicate the position.", "Add Employee", MessageBoxButtons.OK, MessageBoxIcon.Error); cbPosition.Focus(); return; } else { string employee_id = txtEmployeeID.Text; string first_name = txtFirstName.Text; string middle_name = (txtMiddleName.Text == "Middle Name") ? string.Empty : txtMiddleName.Text; string last_name = txtLastName.Text; string contact_number = (txtContactNumber.Text == "Contact Number") ? string.Empty : txtContactNumber.Text; string email = (txtEmail.Text == "Email") ? string.Empty : txtEmail.Text; int department_id = Convert.ToInt32(cbDepartment.SelectedValue); int position_id = Convert.ToInt32(cbPosition.SelectedValue); Byte[] profile_picture = classes.Configuration.ConvertScreenCaptureToByte(pbPreview.Image); personal_information = new classes.PersonalInformation(); if (personal_information.insert_personal_information(first_name, middle_name, last_name, contact_number, email, profile_picture)) { employee = new classes.Employee(); if (employee.insert_employee(employee_id, department_id, position_id)) { account = new classes.Accounts(); if (account.insert_account(employee_id, "Employee")) { MessageBox.Show((first_name + " " + last_name).ToUpper() + " has been added!", "Add Employee", MessageBoxButtons.OK, MessageBoxIcon.Information); includes.uc.frmDashboard.admin.mu.ucManageEmployee.instance.display_employee_data(); this.Close(); } else { return; } } else { return; } } else { return; } } } } } } } }