/// <summary> /// Search for tickets by customer. /// </summary> /// <param name="custT">A CustTick parameter</param> /// <returns></returns> public List <CustTick> SearchCustTicks(CustTick custT) { List <CustTick> searchTicks = new List <CustTick>(); SqlConnection corpcn = new SqlConnection(Settings.Default.cnHelpDesk); var sb = new StringBuilder(); sb.Append("Select CustID, TickID "); sb.Append("From CustTick "); sb.Append("Where CustID ='").Append(custT.CustID).Append("';"); using (corpcn) { //Needed this here to be able to use the variable towards the end. Some type of scope error. CustTick custTick = null; SqlCommand corpCmd = corpcn.CreateCommand(); corpCmd.CommandType = CommandType.Text; corpCmd.CommandText = sb.ToString(); corpcn.Open(); SqlDataReader corprdr = corpCmd.ExecuteReader(); while (corprdr.Read()) { custTick = CreateCustTick(corprdr); searchTicks.Add(custTick); } corprdr.Close(); return(searchTicks); } }
private CustTick CreateCustTick(SqlDataReader dr) { var c = new CustTick(); c.CustID = (int)dr["CustID"]; c.TickID = (int)dr["TickID"]; return(c); }
/// <summary> /// Searches for a list of tickets by customer /// </summary> /// <param name="cI">Customer ID</param> /// <returns></returns> public List <int> SearchCustTicks(int cI) { ListCustTicks(); List <int> custTickList = new List <int>(); CustTick c1 = new CustTick(); foreach (CustTick custT in ctsList) { if (custT.CustID == cI) { custTickList.Add(custT.TickID); } } //Returns the list of Tickets return(custTickList); }
/// <summary> /// Search for the customer of the ticket /// </summary> /// <param name="tI">Ticket ID</param> /// <returns></returns> public int SearchForCust(int tI) { int custID = 0; ListCustTicks(); CustTick c1 = new CustTick(); foreach (CustTick custT in ctsList) { if (custT.TickID == tI) { custID = custT.CustID; } } //Returns the list of Tickets return(custID); }
/// <summary> /// Adds a CustTick /// </summary> /// <param name="cust">A CustTick parameter</param> public void InsertCustTick(CustTick cust) { SqlConnection corpcn = new SqlConnection(Settings.Default.cnHelpDesk); var sb = new StringBuilder(); sb.Append("Insert Into [CustTick]"); sb.Append(" ([CustID], [TickID])"); sb.Append(" Values ("); sb.Append("'").Append(cust.CustID).Append("',"); sb.Append("'").Append(cust.TickID).Append("');"); using (corpcn) { SqlCommand corpCmd = corpcn.CreateCommand(); corpCmd.CommandType = CommandType.Text; corpCmd.CommandText = sb.ToString(); corpcn.Open(); corpCmd.ExecuteNonQuery(); } }