public static Technician GetTechnician(int techID) { DBManager DB = TechSupportDB.GetDBManager(); SortedList slParams = new SortedList(); SqlDataReader dr; Technician technician = null; string strSelect = "SELECT " + FldTechID + ", " + FldName + ", " + FldEmail + ", " + FldPhone + " FROM " + TblTechnicians + " WHERE " + FldTechID + "=@" + FldTechID; slParams.Add(FldTechID, techID); dr = DB.SelectDirect(strSelect, CommandType.Text, slParams); if (dr.Read()) { technician = new Technician(); technician.TechID = (int)dr[FldTechID]; technician.Name = dr[FldName].ToString(); technician.Email = dr[FldEmail].ToString(); technician.Phone = dr[FldPhone].ToString(); } dr.Close(); return(technician); }
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); }
public static string GetTechnicianName(int techID) { DBManager DB = TechSupportDB.GetDBManager(); SortedList slParams = new SortedList(); string strResult; string strSelect = "SELECT " + FldName + " FROM " + TblTechnicians + " WHERE " + FldTechID + "=@" + FldTechID; slParams.Add(FldTechID, techID); strResult = (string)DB.GetScalar(strSelect, CommandType.Text, slParams); return(strResult); }
public static string GetProductName(string productCode) { DBManager DB = TechSupportDB.GetDBManager(); SortedList slParams = new SortedList(); string strResult; string strSelect = "SELECT " + FldName + " FROM " + TblProducts + " WHERE " + FldProductCode + "=@" + FldProductCode; slParams.Add(FldProductCode, productCode); strResult = (string)DB.GetScalar(strSelect, CommandType.Text, slParams); return(strResult); }
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); }
public static bool ProductRegistered(int customerID, string productCode) { DBManager DB = TechSupportDB.GetDBManager(); SortedList slParams = new SortedList(); bool blnResult; string strSelect = "SELECT COUNT(*) FROM " + TblRegistrations + " WHERE " + FldCustomerID + "=@" + FldCustomerID + " AND " + FldProductCode + "=@" + FldProductCode; slParams.Add(FldCustomerID, customerID); slParams.Add(FldProductCode, productCode); blnResult = ((int)DB.GetScalar(strSelect, CommandType.Text, slParams) > 0); return(blnResult); }
public static List <Technician> GetTechnicianList() { DBManager DB = TechSupportDB.GetDBManager(); List <Technician> technicianList = new List <Technician>(); SqlDataReader dr; string strSelect = "SELECT " + FldTechID + ", " + FldName + " FROM " + TblTechnicians + " ORDER BY " + FldName; dr = DB.SelectDirect(strSelect, CommandType.Text); while (dr.Read()) { Technician technician = new Technician(); technician.TechID = (int)dr[FldTechID]; technician.Name = dr[FldName].ToString(); technicianList.Add(technician); } dr.Close(); return(technicianList); }
public static List <Product> GetProductList() { DBManager DB = TechSupportDB.GetDBManager(); List <Product> productList = new List <Product>(); SqlDataReader dr; string strSelect = "SELECT " + FldProductCode + ", " + FldName + " FROM " + TblProducts + " ORDER BY " + FldName; dr = DB.SelectDirect(strSelect, CommandType.Text); while (dr.Read()) { Product product = new Product(); product.ProductCode = dr[FldProductCode].ToString(); product.Name = dr[FldName].ToString(); productList.Add(product); } dr.Close(); return(productList); }
public static List <Customer> GetCustomerList() { DBManager DB = TechSupportDB.GetDBManager(); List <Customer> customerList = new List <Customer>(); SqlDataReader dr; string strSelect = "SELECT " + FldCustomerID + ", " + FldName + " FROM " + TblCustomers + " ORDER BY " + FldName; dr = DB.SelectDirect(strSelect, CommandType.Text); while (dr.Read()) { Customer customer = new Customer(); customer.CustomerID = (int)dr[FldCustomerID]; customer.Name = dr[FldName].ToString(); customerList.Add(customer); } dr.Close(); return(customerList); }
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); }