public void display_employee_data() { employee = new classes.Employee(); string search = cbSearchBy.Text; switch (search) { case "Employee ID": employee_table = employee.select_employee_table("a.employee_id", txtSearch.Text); break; case "Full Name": employee_table = employee.select_employee_table("b.first_name", txtSearch.Text); break; case "Contact Number": employee_table = employee.select_employee_table("b.contact_number", txtSearch.Text); break; case "Email": employee_table = employee.select_employee_table("b.email", txtSearch.Text); break; case "Department": employee_table = employee.select_employee_table("c.department_name", txtSearch.Text); break; case "Position": employee_table = employee.select_employee_table("d.position_name", txtSearch.Text); break; case "--Search by--": employee_table = employee.select_employee_table(); break; default: employee_table = employee.select_employee_table(); break; } dgvManageEmployee.DataSource = employee_table; dgvManageEmployee.AutoGenerateColumns = false; if (dgvManageEmployee.Columns.Contains("action") && dgvManageEmployee.Columns["action"].Visible) { } else { DataGridViewButtonColumn button = new DataGridViewButtonColumn(); { button.Name = "action"; button.HeaderText = "Action"; button.Text = "Update Employee"; button.UseColumnTextForButtonValue = true; this.dgvManageEmployee.Columns.Add(button); } } }
public void display_employee() { emp = new classes.Employee(); cbEmployee.DataSource = emp.select_employee_cb(); cbEmployee.DisplayMember = "full_name"; cbEmployee.ValueMember = "id"; cbEmployee.SelectedIndex = 0; }
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; } } } } } } } }