public static List<Incident> GetOpenIncidents() { DBManager DB = TechSupportDB.GetDBManager(); List<Incident> incidentList = new List<Incident>(); SqlDataReader dr; string strSelect = "SELECT " + FldCustomerID + ", " + FldProductCode + ", " + FldTechID + ", " + FldDateOpened + ", " + FldTitle + " FROM " + TblIncidents + " WHERE " + FldDateClosed + " IS NULL"; dr = DB.SelectDirect(strSelect, CommandType.Text); while(dr.Read()) { Incident incident = new Incident(); incident.CustomerID = (int)dr[FldCustomerID]; incident.ProductCode = dr[FldProductCode].ToString(); if (dr[FldTechID].GetType().ToString() == "System.DBNull") incident.TechID = null; else incident.TechID = (int)dr[FldTechID]; incident.DateOpened = (DateTime)dr[FldDateOpened]; incident.Title = dr[FldTitle].ToString(); incidentList.Add(incident); } dr.Close(); return incidentList; }
public static int AddIncident(Incident incident) { DBManager DB = TechSupportDB.GetDBManager(); SortedList slParams = new SortedList(); int intResult = 0; slParams.Add(FldCustomerID, incident.CustomerID); slParams.Add(FldProductCode, incident.ProductCode); slParams.Add(FldDateOpened, incident.DateOpened); slParams.Add(FldTitle,incident.Title); slParams.Add(FldDescription, incident.Description); intResult = DB.InsertDirect(TblIncidents, CommandType.Text, slParams); return intResult; }
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(); } }
public static List<Incident> GetOpenTechnicianIncidents(int techID) { DBManager DB = TechSupportDB.GetDBManager(); SortedList slParams = new SortedList(); List<Incident> incidentList = new List<Incident>(); SqlDataReader dr; string strSelect = "SELECT " + FldCustomerID + ", " + FldProductCode + ", " + FldDateOpened + ", " + FldTitle + " FROM " + TblIncidents + " WHERE " + FldTechID + "=@" + FldTechID + " AND " + FldDateClosed + " IS NULL"; slParams.Add(FldTechID, techID); dr = DB.SelectDirect(strSelect, CommandType.Text, slParams); while (dr.Read()) { Incident incident = new Incident(); incident.CustomerID = (int)dr[FldCustomerID]; incident.ProductCode = dr[FldProductCode].ToString(); incident.DateOpened = (DateTime)dr[FldDateOpened]; incident.Title = dr[FldTitle].ToString(); incidentList.Add(incident); } dr.Close(); return incidentList; }