private void populateListView() { bookingsTable = (HTMLTable)timesheet.all.item("ContentPlaceHolder1_GridViewSessions", 0); foreach (var table in bookingsTable.all) { foreach (var row in table.all) { if (row is HTMLTableRow) { OvertimeBooking timesheetBooking = parseRow(row); if (timesheetBooking != null) { currentBookings.Add(timesheetBooking); string[] bookingArray = { timesheetBooking.date, timesheetBooking.projectNo, timesheetBooking.description, timesheetBooking.hours, timesheetBooking.multiplier }; ListViewItem item = new ListViewItem(bookingArray); listView1.Items.Add(item); } } } } AdjustDescColumnToFill(listView1); thisMonthButton.Enabled = true; lastMonthButton.Enabled = true; loadingText.Visible = false; }
private OvertimeBooking parseRow(HTMLTableRow row) { OvertimeBooking overtimeBooking = new OvertimeBooking(); List <string> cells = new List <string>(); foreach (var item in row.all) { cells.Add(item.innerText); } if (cells.Count > 9 && (cells[10] == "OT1" || cells[10] == "OT2" || cells[10] == "OT3")) { overtimeBooking.date = cells[0].Substring(4); overtimeBooking.projectNo = cells[1]; overtimeBooking.description = cells[6]; overtimeBooking.hours = cells[9]; if (cells[10] == "OT1") { overtimeBooking.multiplier = "1"; } if (cells[10] == "OT2") { overtimeBooking.multiplier = "1.5"; } if (cells[10] == "OT3") { overtimeBooking.multiplier = "2"; } return(overtimeBooking); } else { return(null); } }