static public List <ProgramExe> ReadPrograms() { string query = "SELECT * FROM Programs"; SQLiteCommand command = new SQLiteCommand(query, con); List <ProgramExe> list = new List <ProgramExe>(); try { SQLiteDataReader reader = command.ExecuteReader(); while (reader.Read()) { int id = Convert.ToInt16(reader["id"]); string name = reader["name"].ToString(); string exe = reader["exe"].ToString(); bool filter = Convert.ToBoolean(reader["filter"]); ProgramExe prog = new ProgramExe(id, name, exe, filter); list.Add(prog); } reader.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } list = list.OrderBy(o => o._name).ToList(); return(list); }
public void CheckBoxFilter(DataGridView filterGrid) { List <ProgramExe> programList = new List <ProgramExe>(); try { foreach (DataGridViewRow row in filterGrid.Rows) { bool check = (bool)row.Cells["checkbox"].Value; int id = (int)row.Cells["id"].Value; ProgramExe program = new ProgramExe(id, check); programList.Add(program); } DBUtils.OpenConection(); foreach (var item in programList) { string query = string.Format("UPDATE Programs SET filter={0} WHERE Id={1} ", Convert.ToInt16(item._filter), item._id); DBUtils.ExecuteQueries(query); } DBUtils.CloseConnection(); // mistakes.MistakesHub(); JEIGU MISTAKES FILTRAS NEVEKIA BRING THIS BACK string connectionString = "Data Source=DatabaseLite.sqlite;Version=3;PRAGMA journal_mode=WAL;"; OrmLiteConnectionFactory dbFactory = new OrmLiteConnectionFactory(connectionString, SqliteDialect.Provider); //DateTime test = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); using (IDbConnection db = dbFactory.OpenDbConnection()) { //var filteredData = db.TABLE.Where(t => t.DATE > startDate && t.DATE < endDate); //var rows = db.From<Heatmap>().Where(x => x.date.CompareTo("2018-05-05 00:00:00") >= 0 && x.date.CompareTo("2018-06-21 23:59:59") <= 0); var rows = db.From <Heatmap>().Where <Heatmap>(x => x.program_id == 12); //db.From<Program>().Insert() } } catch (Exception xe) { MessageBox.Show(xe.ToString()); } }