public List <ItemInINV> GetITEMINV(string ID) { List <ItemInINV> list = new List <ItemInINV>(); SqlConnection con; try { con = connect("igroup31_test1ConnectionString"); // create a connection to the database using the connection String defined in the web config file String selectSTR = "select II.SN,II.Price,II.Quant,IT.price from Item_Invoice II,Item IT where II.INV_ID='" + ID + "' AND II.SN=IT.SN AND II.Price!=IT.price group by II.SN,II.Price,II.Quant,IT.Price"; SqlCommand cmd = new SqlCommand(selectSTR, con); SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); while (dr.Read()) {// Read till the end of the data into a row string SN = dr[0].ToString(); int INV_P = Convert.ToInt32(dr[1]); int INV_Quant = Convert.ToInt32(dr[2]); int IT_P = Convert.ToInt32(dr[3]); ItemInINV It_Inv = new ItemInINV(SN, INV_P, INV_Quant, IT_P); list.Add(It_Inv); } return(list); } catch (Exception ex) { // write to log throw (ex); } }
public List<ItemInINV> GetITEMINV(string ID) { List<ItemInINV> list = new List<ItemInINV>(); SqlConnection con; try { con = connect("igroup31_test1ConnectionString"); // create a connection to the database using the connection String defined in the web config file String selectSTR = "select II.SN,II.Price,II.Quant,IT.price from Item_Invoice II,Item IT where II.INV_ID='2' AND II.SN=IT.SN AND II.Price!=IT.price group by II.SN,II.Price,II.Quant,IT.Price"; SqlCommand cmd = new SqlCommand(selectSTR, con); SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); while (dr.Read()) {// Read till the end of the data into a row string SN = dr[0].ToString(); int INV_P = Convert.ToInt32(dr[1]); int INV_Quant = Convert.ToInt32(dr[2]); int IT_P = Convert.ToInt32(dr[3]); ItemInINV It_Inv = new ItemInINV(SN, INV_P, INV_Quant, IT_P); list.Add(It_Inv); } return list; } catch (Exception ex) { // write to log throw (ex); } }