public List <BillInfoDTO> getListBillInfoByIdBill(int idBillLoad) { List <BillInfoDTO> list = new List <BillInfoDTO>(); SqlConnection con = DBUtils.MakeConnection(); try { if (con != null) { string sql = "Select id, idBill, nameFood, quantity " + "From BillInfo Where idBill = @IdBill"; SqlCommand cmd = new SqlCommand(sql, con); cmd.Parameters.AddWithValue("@IdBill", idBillLoad); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dtTable = new DataTable(); da.Fill(dtTable); foreach (DataRow table in dtTable.Rows) { int id = (int)table["id"]; int idBill = (int)table["idBill"]; string nameFood = (string)table["nameFood"]; int quantity = (int)table["quantity"]; BillInfoDTO dto = new BillInfoDTO(id, idBill, nameFood, quantity); list.Add(dto); } } } catch (Exception e) { throw new Exception(e.Message); } finally { con.Close(); } return(list); }