private void btnBack_MouseClick(object sender, MouseEventArgs e)
 {
     if (type == 0)
     {
         this.Close();
         UniversityOfficerHome uoh = new UniversityOfficerHome();
         uoh.Show();
     }
     else if (type == 1)
     {
         this.Close();
         AdminHome uoh = new AdminHome();
         uoh.Show();
     }
 }
Beispiel #2
0
        // // // // // // //             End Basic Design             // // // // // // //



        // // // // // // //             Begining Admin Login             // // // // // // //



        private void btnALogin_MouseClick(object sender, MouseEventArgs e)
        {
            String adminUsername = txtAUser.Text;
            String adminPassword = txtAPass.Text;



            try
            {
                connect.Open();


                if (txtAUser.Text == "" || txtAPass.Text == "")
                {
                    MessageBox.Show("Fill All The Columns Username and Password...!");
                }
                else
                {
                    //Select USER_TYPE_ID and PASSWORD from USER table
                    String          selectQuery1 = "SELECT USER_TYPE_ID, PASSWORD, U_ID, S_STATE FROM USER WHERE USERNAME='******'";
                    MySqlCommand    command1     = new MySqlCommand(selectQuery1, connect);
                    MySqlDataReader myReader1    = command1.ExecuteReader();

                    while (myReader1.Read())
                    {
                        this.usertype = myReader1[0].ToString();
                        this.password = myReader1[1].ToString();
                        this.uid      = myReader1[2].ToString();
                        this.state    = myReader1[3].ToString();
                    }

                    intUsertype  = Int32.Parse(usertype);
                    Login.intUid = Int32.Parse(uid);
                    intState     = Int32.Parse(state);
                    myReader1.Close();

                    if (intUsertype == 1 && password == adminPassword && intState == 1)
                    {
                        txtAUser.Text = "";
                        txtAPass.Text = "";


                        this.Hide();
                        AdminHome soh = new AdminHome();
                        soh.Show();
                    }
                    else
                    {
                        MessageBox.Show("Login Failed.....!!");

                        txtAUser.Text = "";
                        txtAPass.Text = "";


                        this.usertype    = null;
                        this.intUsertype = 0;
                        this.password    = null;
                        this.uid         = null;
                        Login.intUid     = 0;
                        this.state       = null;
                        this.intState    = 0;
                    }
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            finally
            {
                connect.Close();
            }
        }