Exemplo n.º 1
0
        private void btnexit_Click(object sender, EventArgs e)
        {
            studes sd = new studes();

            sd.Show();
            this.Hide();
        }
Exemplo n.º 2
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            string query = "SELECT userid,password FROM studentregister WHERE userid= '" + txtuserid.Text + "' AND password = '******'";

            if ((txtuserid.Text.Length > 0) && (txtpass.Text.Length > 0))
            {
                try
                {
                    if (this.OpenConnection() == true)
                    {
                        MySqlCommand    cmd = new MySqlCommand(query, connection);
                        MySqlDataReader rd  = cmd.ExecuteReader();
                        if (rd.Read())
                        {
                            MessageBox.Show("Login details confirmed!. Click OK to proceed. Thank you.", "LOGIN CONFIRMED!!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                            rd.Close();
                            this.closeConnection();
                            txtuserid.Text = "";
                            txtpass.Text   = "";
                            studes rs = new studes();
                            rs.Show();
                            this.Hide();
                        }
                        else
                        {
                            MessageBox.Show("login details not found.Register and try again.", "NOT REGISTERED", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                            this.closeConnection();
                            rd.Close();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Check the connection and try again.", "CONNECTION ERROR", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    this.closeConnection();
                }
            }
            else
            {
                MessageBox.Show("Make your entries valid!");
            }
        }