public static List <Cogs> List(string query) { s = new List <Cogs>(); SQLiteDataReader Reader = DBConnect.ReadingLite(query); while (Reader.Read()) { Cogs p = new Cogs(Reader["id"].ToString(), Reader["date"].ToString(), Convert.ToInt32(Convert.ToInt32(Reader["week"])), Reader["starting"].ToString(), Convert.ToDateTime(Reader["ending"]).ToString("dd-MMM-yy"), Reader["category"].ToString(), Convert.ToDouble(Reader["beginningInventory"]), Convert.ToDouble(Reader["endingInventory"].ToString()), Convert.ToDouble(Reader["cost"].ToString()), Reader["month"].ToString()); s.Add(p); } Reader.Close(); return(s); }
public static List <Inventory> List(string query) { s = new List <Inventory>(); SQLiteDataReader Reader = DBConnect.ReadingLite(query); while (Reader.Read()) { double begining = Cogs.List("SELECT * from cogs WHERE category= '" + Reader["category"].ToString() + "' AND week = '" + Convert.ToInt32(Reader["week"]) + "' AND date ='" + Helper.CurrentYear + "'").Sum(t => t.BeginningInventory); double ending = Cogs.List("SELECT * from cogs WHERE category= '" + Reader["category"].ToString() + "' AND week = '" + Convert.ToInt32(Reader["week"]) + "' AND date ='" + Helper.CurrentYear + "'").Sum(t => t.EndingInventory); double cg = Cogs.List("SELECT * from cogs WHERE category= '" + Reader["category"].ToString() + "' AND week = '" + Convert.ToInt32(Reader["week"]) + "' AND date ='" + Helper.CurrentYear + "'").Sum(t => t.Cost); Inventory p = new Inventory(Reader["id"].ToString(), Reader["date"].ToString(), Convert.ToInt32(Reader["week"]), Reader["starting"].ToString(), Convert.ToDateTime(Reader["ending"]).ToString("dd-MMM-yy"), Reader["name"].ToString(), Reader["category"].ToString(), Convert.ToDouble(Reader["amount"]), begining, ending, cg, Reader["month"].ToString(), Reader["dop"].ToString()); s.Add(p); } Reader.Close(); return(s); }