/// <summary> /// Adds incident to database via the IncidentDB's AddIncident method /// </summary> /// <param name="incident">Incident to be added</param> /// <returns>Returns incidentID of incident that was added</returns> public int AddIncidentToDB(Incident incident) { int incidentID; incidentID = IncidentDB.AddIncident(incident); return(incidentID); }
/// <summary> /// Retrieves list of incidents for a certain technician /// </summary> /// <param name="techID">Technician to show incidents for</param> /// <returns>Returns list of incidents for a certain technician</returns> public List <Incident> GetIncidentsForTech(int techID) { List <Incident> myIncidentList; myIncidentList = IncidentDB.GetIncidentsForTech(techID); return(myIncidentList); }
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 nameComboBox_SelectedIndexChanged(object sender, EventArgs e) { List <Incident> incidentsList; technicianBindingSource.Clear(); if (nameComboBox.SelectedIndex > -1) { int intTechID = technicianList[nameComboBox.SelectedIndex].TechID; Technician technician = TechnicianDB.GetTechnician(intTechID); technicianBindingSource.Add(technician); incidentsList = IncidentDB.GetOpenTechnicianIncidents(intTechID); incidentDataGridView.DataSource = incidentsList; } }
private void btnGetIncidents_Click(object sender, EventArgs e) { IncidentDB anIncidentDB = new IncidentDB(); try { dgrIncidentByTech.DataSource = anIncidentDB.GetOpenTechnicianIncidents(int.Parse(textBoxTechID.Text)); if (dgrIncidentByTech.RowCount < 1) { MessageBox.Show("No records found"); } } 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); } }
private void btnCreateIncident_Click(object sender, EventArgs e) { int intResult; if (this.IsValid()) { //Create the incident record if valid Incident incident = new Incident(); incident.CustomerID = (int)cboCustomers.SelectedValue; incident.ProductCode = (string)cboProducts.SelectedValue; incident.DateOpened = DateTime.Now; incident.Title = txtTitle.Text; incident.Description = txtDescription.Text; intResult = IncidentDB.AddIncident(incident); if (intResult == 1) { this.Close(); } } }
// gets all tech incidents by techID public List <Incident> GetOpenTechIncidents(int techID) { return(IncidentDB.GetOpenTechIncidents(techID)); }
// overload...passing default to get all records public List <Incident> GetCustomerIncidents() { return(IncidentDB.GetCustomerIncidents()); }
// gets incidents by customerID public List <Incident> GetCustomerIncidents(int customerID) { return(IncidentDB.GetCustomerIncidents(customerID)); }
/// <summary> /// Rtrieves the incident from the IncidentDB class based on provided incidentID /// </summary> /// <param name="incidentID"></param> /// <returns>Returns incident whose ID is the ID passed in</returns> public Incident GetIncident(int incidentID) { Incident incident = IncidentDB.GetIncident(incidentID); return(incident); }
/// <summary> /// Returns whether or not the incident was updated successfully /// </summary> /// <param name="oldIncident">Old incident as a reference</param> /// <param name="newIncident">new reference used to populate fields</param> /// <returns>Returns true or false depending on if the incident was properly updated</returns> public bool UpdateIncident(Incident oldIncident, Incident newIncident) { bool isIncidentUpdated = IncidentDB.UpdateIncident(oldIncident, newIncident); return(isIncidentUpdated); }
/// <summary> /// Closes incident /// </summary> /// <param name="incidentID"></param> /// <returns>Returns either true or false if the incident has been closed</returns> public bool CloseIncident(int incidentID) { return(IncidentDB.CloseIncident(incidentID)); }