private void btn_logout_Click(object sender, EventArgs e) { this.Hide(); Form1 showLogin = new Form1(); frm_dashboard showDashboard = new frm_dashboard(); showDashboard.dbCommandLogs(Session.FullName.ToString() + " signed out. "); showLogin.Show(); }
public docuForm() { InitializeComponent(); db = new frm_dashboard(); }
public Guest_frm() { InitializeComponent(); db = new frm_dashboard(); }
public void checkCredentials(string username, string password) { try { conn = new MySqlConnection(cs); conn.Open(); //Console.WriteLine("MySQL version : {0}", conn.ServerVersion); query = conn.CreateCommand(); query.CommandText = "select count(*) from account_table where username= '******' and password='******'"; adapt = new MySqlDataAdapter(query); dataTable = new DataTable(); adapt.Fill(dataTable); if (dataTable.Rows[0][0].ToString() == "1") { query.CommandText = "select type from account_table where username= '******' and password='******'"; adapt = new MySqlDataAdapter(query); dataTable = new DataTable(); adapt.Fill(dataTable); if (dataTable.Rows[0][0].ToString() == "admin") { //create session query.CommandText = "select * from account_table where username= '******' and password='******'"; adapt = new MySqlDataAdapter(query); dataTable = new DataTable(); adapt.Fill(dataTable); Session.Id = Convert.ToInt32(dataTable.Rows[0][0].ToString()); Session.Username = dataTable.Rows[0][1].ToString(); Session.FullName = dataTable.Rows[0][2].ToString(); Session.Type = dataTable.Rows[0][3].ToString(); this.Hide(); frm_dashboard showDashboard = new frm_dashboard(); showDashboard.dbCommandLogs(Session.FullName.ToString() + " logged in. "); showDashboard.Show(); } else if (dataTable.Rows[0][0].ToString() == "coordinator") { //create session query.CommandText = "select * from account_table where username= '******' and password='******'"; adapt = new MySqlDataAdapter(query); dataTable = new DataTable(); adapt.Fill(dataTable); Session.Id = Convert.ToInt32(dataTable.Rows[0][0].ToString()); Session.Username = dataTable.Rows[0][1].ToString(); Session.FullName = dataTable.Rows[0][2].ToString(); Session.Type = dataTable.Rows[0][3].ToString(); this.Hide(); frm_dashboard showDashboard = new frm_dashboard(); showDashboard.dbCommandLogs(Session.FullName.ToString() + " logged in. "); showDashboard.Show(); } } else if (dataTable.Rows[0][0].ToString() == "2") { MessageBox.Show("Error: Duplicated Account!"); } else { MessageBox.Show("Username or Password is incorrect!"); } } catch (Exception ex) { Console.WriteLine("Error:", ex.ToString()); // MessageBox.Show("Error:", ex.ToString()); MessageBox.Show("connection failed."); } finally { if (conn != null) { conn.Close(); } } }