private void GetForm1() { connection conn = new connection(); if (conn.OpenConnection() == true) { string query = "select * FROM staff"; MySqlCommand cmd = new MySqlCommand(query, conn.con); MySqlDataReader DataReader = cmd.ExecuteReader(); conn.CloseConnection(); } }
private void GetStaff() { connection connect = new connection(); if (connect.OpenConnection() == true) { String query = "SELECT * FROM role ORDER BY Role_id ASC"; MySqlCommand cmd = new MySqlCommand(query, connect.con); MySqlDataReader dataReader = cmd.ExecuteReader(); //Read the data and store them in the list this.cboRole.Items.Clear(); while (dataReader.Read()) { if (dataReader["Role_Name"].ToString().Replace(" ", "") != "") { this.cboRole.Items.Add(dataReader["Role_Name"].ToString()); } } connect.CloseConnection(); } }
private void btnLgoin_Click(object sender, EventArgs e) { connection conn = new connection(); if (conn.OpenConnection()) { string querry = "SELECT * FROM staff WHERE Login_Name='" + this.txtUser.Text + "' and Passsword ='" + this.txtPasssword.Text + "'and Priviledges ='" + this.cboRole.Text + "' "; MySqlCommand cmd = new MySqlCommand(querry, conn.con); MySqlDataReader datareader = cmd.ExecuteReader(); int count = 0; while (datareader.Read()) { count = count + 1; } if (count == 1) { MessageBox.Show("Login successfull\n" + "You Are Welcome " + txtUser.Text + " Just click OK to have access of the system.", "CMS MESSAGE", MessageBoxButtons.OK, MessageBoxIcon.Information); // MDIParent1 mdi = new MDIParent1("WELCOME" + txtUser_Name.Text); //mdi.Visible = true; //this.Hide(); string x = txtUser.Text; string y = cboRole.Text; frmHome H = new frmHome(x, y); H.Visible = true; this.Hide(); // SchoolManagementSystem cat = new SchoolManagementSystem(); // cat.Visible = true; // this.Hide(); } else { MessageBox.Show("Login unsuccessfull", "FOMS MESSAGE", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }