public void UpdateGUI() { firingRequests = null; controls.Clear(); flpRequests.Controls.Clear(); firingRequests = FiringRequests.GetAllFiringRequests(); hiringRequests = HiringRequests.GetAllHiringRequests(); promotionrequests = PromotionRequests.GetAllPromotionRequests(); foreach (FiringRequests fr in firingRequests) { controls.Add(new RequestControl(fr.PersonId, fr.CreatedById, fr.DepartmentId, fr.Description, fr.FirstName, fr.LastName, fr.Username, this)); } foreach (PromotionRequests pr in promotionrequests) { controls.Add(new RequestControl(pr.PersonId, pr.CreatedById, pr.Username, pr.FirstName, pr.LastName, pr.HourlyWage, pr.DepartmentId, this)); } foreach (HiringRequests hr in hiringRequests) { controls.Add(new RequestControl(hr.PersonId, hr.CreatedById, hr.Username, hr.FirstName, hr.LastName, hr.HourlyWage, hr.DepartmentId, hr.ContractStartDate, hr.PhoneNumber, hr.Email, this)); } foreach (RequestControl request in controls) { flpRequests.Controls.Add(request); } }
private void btnDelete_Click(object sender, EventArgs e) { if (this.email != null) { foreach (HiringRequests hr in HiringRequests.GetAllHiringRequests()) { if (hr.PersonId == personId) { hr.DeclineHiringRequest(); } } form.UpdateGUI(); } else { foreach (FiringRequests fr in FiringRequests.GetAllFiringRequests()) { if (fr.PersonId == personId) { fr.DeclineFiringRequest(); } } form.UpdateGUI(); } }
private void BtnSendFiringRequest_Click(object sender, EventArgs e) { MySqlConnection conn = Utils.GetConnection(); if (cmbDepartment.Text == "Department" || cmbDepartment.Text == "") { MessageBox.Show("Please select a department from the menu!"); } else if (cmbEmployees.Text == "Employees" || cmbEmployees.Text == "") { MessageBox.Show("Please select an employee from the menu!"); } else if (rtbReason.Text == "") { MessageBox.Show("Please fill in all the fields in the table!"); } else if (rtbReason.Text == "Reason for firing") { MessageBox.Show("Please change the initial information in the fields!"); } else { string description = rtbReason.Text; int departmentId = ((DepartmentComboBoxItem)cmbDepartment.SelectedItem).Id; int employeeId = ((EmployeeComboBoxItem)cmbEmployees.SelectedItem).Id; string employeeUsername = ((EmployeeComboBoxItem)cmbEmployees.SelectedItem).Username; string employeeFirstName = ((EmployeeComboBoxItem)cmbEmployees.SelectedItem).FirstName; string employeeLastName = ((EmployeeComboBoxItem)cmbEmployees.SelectedItem).LastName; if (MessageBox.Show("Do you really want to send this firing request?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { try { FiringRequests fr = new FiringRequests(employeeId, this.loggedUserId, employeeUsername, description, employeeFirstName, employeeLastName, departmentId); FiringRequests fr1 = new FiringRequests(employeeId, this.loggedUserId, description); if (!fr1.FrExists) { MessageBox.Show("Firing request already exists!"); } else { MessageBox.Show("Request sent successfully!"); } } catch (Exception ex) { string epra = ex.Message; } finally { conn.Close(); cmbEmployees.Enabled = false; cmbEmployees.Text = "Employees"; cmbDepartment.Text = "Department"; tbxFirstName.Text = "First name"; tbxLastName.Text = "Last name"; } } } }
private void btnApprove_Click_1(object sender, EventArgs e) { if (MessageBox.Show("Do you really want to approve this request?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { if (lblRequest.Text.Contains("Hiring")) { foreach (HiringRequests hr in HiringRequests.GetAllHiringRequests()) { if (hr.PersonId == personId) { hr.ApproveHiringRequest(); } } form.UpdateGUI(); } else if (lblRequest.Text.Contains("firing")) { foreach (FiringRequests fr in FiringRequests.GetAllFiringRequests()) { if (fr.PersonId == personId) { fr.ApproveFiringRequest(); } } form.UpdateGUI(); } else if (lblRequest.Text.Contains("Promotion")) { foreach (PromotionRequests pr in PromotionRequests.GetAllPromotionRequests()) { if (pr.PersonId == personId) { pr.ApprovePromotionRequest(); } } form.UpdateGUI(); } } }