private void FrmOpenIncidents_Load(object sender, EventArgs e) { IncidentDB anIncidentDB = new IncidentDB(); try { dgrOpenIncidents.DataSource = anIncidentDB.GetOpenIncidents(); } catch (SqlException ex) { MessageBox.Show(ex.Message, "SQL Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void PopulateIncidentsList() { try { List <Incident> incidentsList = IncidentDB.GetOpenIncidents(); ListViewItem lvwItem; foreach (Incident incident in incidentsList) { lvwItem = lvwIncidents.Items.Add(incident.ProductCode); lvwItem.SubItems.Add(incident.DateOpened.ToShortDateString()); lvwItem.SubItems.Add(incident.CustomerName); lvwItem.SubItems.Add(incident.TechnicianName); lvwItem.SubItems.Add(incident.Title); } } catch (SqlException ex) { MessageBox.Show(ex.Message, "SQL Exception " + ex.Number, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } }