private void button3_Click(object sender, EventArgs e) { this.Hide(); CashierMainform hackers = new CashierMainform(); hackers.Show(); }
private void simpleButton1_Click(object sender, EventArgs e) { db_connection(); string user = username.Text; string pass = password.Text; string x = Convert.ToString(DateTime.Now); if (tryLogin(username.Text, password.Text) == true) { conn = "Server=localhost;Database=Management;Uid=root;Pwd=;"; MySqlCommand cmd2 = new MySqlCommand("SELECT userlevel,AccountName,Account_ID FROM Account WHERE Username = '******';", connect); cmd2.Connection = connect; object accessCode = cmd2.ExecuteScalar(); if (accessCode != null && accessCode != DBNull.Value) { if (accessCode.ToString() == "Admin") { MySqlDataReader reader = cmd2.ExecuteReader(); if (reader.Read() == true) { labelname.Text = reader["AccountName"].ToString(); reader.Read(); // reader.Close(); labelid.Text = reader["Account_ID"].ToString(); reader.Read(); reader.Close(); } //string level = "Cashier"; //string namex = labelname.Text; string id = labelid.Text; string level1 = "Admin"; string name = labelname.Text; MySqlConnectionStringBuilder builder = new MySqlConnectionStringBuilder(); builder.Server = "127.0.0.1"; builder.UserID = "root"; builder.Password = ""; builder.Database = "Management"; MySqlConnection connection = new MySqlConnection(builder.ToString()); connection.Open(); string newbook_sql = "INSERT INTO LOGIN(AccountName,login_username,login_pass,userlevel,DateTimeIn,StaffID) values ('" + name + "','" + user + "','" + pass + "','" + level1 + "','" + x + "','" + id + "');"; MySqlCommand newbook = new MySqlCommand(newbook_sql, connect); MySqlDataReader myReader; try { myReader = newbook.ExecuteReader(); while (myReader.Read()) { } } catch (Exception ex) { MessageBox.Show(ex.Message); connect.Close(); } this.Hide(); AdminButtons admins = new AdminButtons(); toastNotificationsManager1.ShowNotification(toastNotificationsManager2.Notifications[0]); admins.Show(); username.Text = ""; password.Text = ""; } if (accessCode.ToString() == "Cashier") { MySqlDataReader reader = cmd2.ExecuteReader(); if (reader.Read() == true) { labelname.Text = reader["AccountName"].ToString(); reader.Read(); labelid.Text = reader["Account_ID"].ToString(); reader.Read(); reader.Close(); } string level = "Cashier"; string namex = labelname.Text; string id = labelid.Text; username.Text = ""; password.Text = ""; string newbook_sql = "INSERT INTO LOGIN(AccountName,login_username,login_pass,userlevel,DateTimeIn,StaffID) values ('" + namex + "','" + user + "','" + pass + "','" + level + "','" + x + "','" + id + "');"; MySqlCommand newbook = new MySqlCommand(newbook_sql, connect); MySqlDataReader myReader; try { myReader = newbook.ExecuteReader(); while (myReader.Read()) { } } catch (Exception ex) { MessageBox.Show(ex.Message); connect.Close(); } this.Hide(); POSFORM gg = new POSFORM(); toastNotificationsManager1.ShowNotification(toastNotificationsManager1.Notifications[0]); gg.Show(); } if (accessCode.ToString() == "Receptionist") { MySqlDataReader reader = cmd2.ExecuteReader(); if (reader.Read() == true) { labelname.Text = reader["AccountName"].ToString(); reader.Read(); labelid.Text = reader["Account_ID"].ToString(); reader.Read(); reader.Close(); } string level = "Receptionist"; string namex = labelname.Text; string id = labelid.Text; username.Text = ""; password.Text = ""; string newbook_sql = "INSERT INTO LOGIN(AccountName,login_username,login_pass,userlevel,DateTimeIn,StaffID) values ('" + namex + "','" + user + "','" + pass + "','" + level + "','" + x + "','" + id + "');"; MySqlCommand newbook = new MySqlCommand(newbook_sql, connect); MySqlDataReader myReader; try { myReader = newbook.ExecuteReader(); while (myReader.Read()) { } } catch (Exception ex) { MessageBox.Show(ex.Message); connect.Close(); } this.Hide(); CashierMainform gg = new CashierMainform(); toastNotificationsManager1.ShowNotification(toastNotificationsManager1.Notifications[0]); gg.Show(); } } i = 0; } else { DevExpress.XtraEditors.XtraMessageBox.Show("Invalid Login Credential"); i++; username.Text = ""; password.Text = ""; } if (i == 3) { panelControl1.Visible = true; timer2.Start(); username.Enabled = false; password.Enabled = false; connect.Close(); i = 0; } }