public invoice search() { string q = "select * from table_invoice where in_id=" + in_id; SqlCommand cmd = new SqlCommand(q, connection.get()); SqlDataReader sdr = cmd.ExecuteReader(); invoice i = new invoice(); while (sdr.Read()) { i.in_id = (int)sdr[0]; i.in_date = (string)sdr[1]; i.in_fk_us_id = (int)sdr[2]; } sdr.Close(); return(i); }
public List <invoice> showall() { string q = "select * from table_invoice"; SqlCommand cmd = new SqlCommand(q, connection.get()); SqlDataReader sdr = cmd.ExecuteReader(); List <invoice> lst = new List <invoice>(); while (sdr.Read()) { invoice i = new invoice(); i.in_id = (int)sdr[0]; i.in_date = (string)sdr[1]; i.in_fk_us_id = (int)sdr[2]; lst.Add(i); } sdr.Close(); return(lst); }