public void update_sessions() { try { string tmp = string.Format(sql, user_id); dataGridView1.Columns[1].DefaultCellStyle.Format = "yyyy-MM-dd HH:mm"; con.open(); this.dataGridView1.DataSource = con.select(tmp).Tables[0]; con.close(); dataGridView1.Columns[1].DefaultCellStyle.Format = "yyyy-MM-dd HH:mm"; } catch { } }
private void MainMenu_Load(object sender, EventArgs e) { string sql = @" select username from users where id_user={0} "; con = new sqlite_connector(); con.open(); string title = con.select(string.Format(sql, id_user.ToString())).Tables[0].Rows[0].ItemArray[0].ToString(); con.close(); this.Text += ": Logged in as " + title; if (id_user == ROOT_ID) { mod_users = new ToolStripMenuItem("Users", null, userToolStripMenuItem); menuStrip1.Items.Add(mod_users); } }
private void button1_Click(object sender, EventArgs e) { if (!check_valid_values()) { MessageBox.Show("One or more fields are empty!"); } else { string username = textBox1.Text; string password = textBox2.Text; string sql = @"select id_user from users where username='******' and password='******'"; string id = ""; con.open(); try { id = con.select(string.Format(sql, username, password)). Tables[0].Rows[0].ItemArray[0].ToString(); con.close(); }catch (System.IndexOutOfRangeException ex) { try { con.close(); } catch { } id = ""; } if (id == "") { MessageBox.Show("Entered credentials are incorrect."); } else { login_ok = true; login_id = Convert.ToInt32(id); this.Close(); } } }
private void Modify_Users_Load(object sender, EventArgs e) { con.open(); this.dataGridView1.DataSource = con.select(sql_main).Tables[0]; con.close(); }