void update_user() { string sql_command = @"update users set username = '******', password='******' where id_user = {2};"; try { con.open(); con.command(string.Format(sql_command, this.textBox1.Text, this.textBox2.Text, this.user_id)); con.close(); MessageBox.Show("User has been updated succesfully!"); if (Modu != null) { Modu.update_dfv(true); } this.Close(); }catch (Exception ex) { try { con.close(); } catch { } if (ex.Message.Contains("UNIQUE") && ex.Message.Contains("user")) { MessageBox.Show("Username already registered!"); } else { MessageBox.Show(ex.Message); } Application.DoEvents(); } }
private void deleteToolStripMenuItem_Click(object sender, EventArgs e) { string sql_del = @"delete from users where id_user = {0}; delete from session where id_user={0}; delete from solve where solve.id_session in (select id_session from session where id_user = {0} and solve.id_session=session.id_Session);; "; string userid = dataGridView1.CurrentRow.Cells[0].Value.ToString(); if (userid == "0") { MessageBox.Show("Cannot delete Root!"); return; } try { con.open(); con.command(string.Format(sql_del, userid)); con.close(); MessageBox.Show("User has been deleted."); update_dfv(true); }catch (Exception ex) { /*MessageBox.Show(ex.Message)*/; try { con.close(); } catch { } } finally { update_dfv(true); } }
private void button1_Click(object sender, EventArgs e) { string sql; if (isModding) { sql = @"update session set time_date='{0}',comment='{1}' where id_session={2}"; con.open(); con.command(string.Format(sql, dateTimePicker1.Value.ToString("yyyy-MM-dd hh:mm"), this.textBox1.Text, this.session_id)); con.close(); ss.update_sessions(); this.Close(); } else { sql = @"insert into session(id_user,time_date,comment) values({0},'{2}','{1}')"; con.open(); con.command(string.Format(sql, this.session_user, this.textBox1.Text, dateTimePicker1.Value.ToString("yyyy-MM-dd hh:mm"))); con.close(); ss.update_sessions(); this.Close(); } }
private void deleteSessionToolStripMenuItem_Click(object sender, EventArgs e) { try { string sql = @"delete from session where id_session = {0}"; string datetime = dataGridView1.SelectedRows[0].Cells[1].Value.ToString(); string comment = dataGridView1.SelectedRows[0].Cells[2].Value.ToString(); string session = dataGridView1.SelectedRows[0].Cells[0].Value.ToString(); con.open(); con.command(string.Format(sql, session)); con.close(); MessageBox.Show("Session Deleted."); update_sessions(); } catch (System.ArgumentOutOfRangeException ex) { } }