private void button_decline_req_Click(object sender, EventArgs e) { int selected_emp_email = int.Parse(Holiday_dataGrid.CurrentCell.Value.ToString()); try { HolidayModel hm = new HolidayModel(); hm.reject_holiday(selected_emp_email); // Update table with new results Holiday_dataGrid.Refresh(); } catch (Exception es) { Console.WriteLine(es); MessageBox.Show("Action failed whilst trying to alter the status of this holiday", "Action failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void view_holidays_button_Click(object sender, EventArgs e) { HolidayModel hm = new HolidayModel(); // Clear rows to avoid duplicates upon button click Holiday_dataGrid.Rows.Clear(); Holiday_dataGrid.Refresh(); // Fetch results from database List <Holidays> outstanding_holidays = hm.get_outstanding_holiday_requests(); // Append results row by row foreach (var hol in outstanding_holidays) { Holiday_dataGrid.Rows.Add(hol.holiday_id, hol.Holiday_start, hol.Holiday_end, hol.Holiday_status, hol.Days_exceeded ? "Yes" : "No", hol.Head_depHead_absent ? "Yes" : "No", hol.SeniorStaff_absent ? "Yes" : "No", hol.department_Absent ? "Yes" : "No"); } // Hide any other panels and show clicked one main_Panel.Hide(); holiday_Panel.Show(); }