public List <EntitieCompraItem> GetItems(int idCompra) { List <EntitieCompraItem> items = new List <EntitieCompraItem>(); String query = "SELECT CI.* " + "FROM Compra_Items CI " + "JOIN Compras C " + "ON C.ID_Compra = CI.ID_Compra "; Boolean whereAdded = false; if (idCompra > 0) { query += "WHERE CI.ID_Compra = " + idCompra + " "; whereAdded = true; } DataTable dt = ManagerDatabase.Instance.ExecuteQuery(query); for (int i = 0; i < dt.Rows.Count; i++) { EntitieCompraItem item = new EntitieCompraItem( Convert.ToInt32(dt.Rows[i][0]), Convert.ToInt32(dt.Rows[i][1]), Convert.ToInt32(dt.Rows[i][2]), dt.Rows[i][3].ToString(), Convert.ToInt32(dt.Rows[i][4]), Convert.ToDecimal(dt.Rows[i][5])); items.Add(item); } return(items); }
public List <EntitieCompraItem> GetItemsByIdCompra(int idCompra) { List <EntitieCompraItem> items = new List <EntitieCompraItem>(); DataTable dt = ManagerDatabase.Instance.ExecuteQuery("SELECT * FROM Compra_Items WHERE ID_Compra = " + idCompra); for (int i = 0; i < dt.Rows.Count; i++) { EntitieCompraItem item = new EntitieCompraItem( Convert.ToInt32(dt.Rows[i][0]), Convert.ToInt32(dt.Rows[i][1]), Convert.ToInt32(dt.Rows[i][2]), dt.Rows[i][3].ToString(), Convert.ToInt32(dt.Rows[i][4]), Convert.ToDecimal(dt.Rows[i][5])); items.Add(item); } return(items); }