public sales search() { string q = "select * from table_sales where sls_id=" + sls_id; SqlCommand cmd = new SqlCommand(q, connection.get()); SqlDataReader sdr = cmd.ExecuteReader(); sales s = new sales(); while (sdr.Read()) { s.sls_id = (int)sdr[0]; s.sls_qty = (int)sdr[1]; s.sls_fk_in_id = (int)sdr[2]; s.sls_fk_prd_id = (int)sdr[3]; } sdr.Close(); return(s); }
public List <sales> showall() { string q = "select * from table_sales"; SqlCommand cmd = new SqlCommand(q, connection.get()); SqlDataReader sdr = cmd.ExecuteReader(); List <sales> lst = new List <sales>(); while (sdr.Read()) { sales s = new sales(); s.sls_id = (int)sdr[0]; s.sls_qty = (int)sdr[1]; s.sls_fk_in_id = (int)sdr[2]; s.sls_fk_prd_id = (int)sdr[3]; lst.Add(s); } sdr.Close(); return(lst); }