コード例 #1
0
        private void button_cancel_Click(object sender, EventArgs e)
        {
            string type = LoginForm.usertype;

            if (type == "Admin")
            {
                //Admin Dashboard
                AdminPanel admin = new AdminPanel();
                admin.Show();
                this.Hide();
            }
            else
            {
                //User Dashboard
                UserPanel home = new UserPanel();
                home.Show();
                this.Close();
            }
        }
コード例 #2
0
ファイル: LoginForm.cs プロジェクト: Apocrypha007/MyHackSpace
        private void button1_Click(object sender, EventArgs e)
        {
            //Username
            string user = textBox_user.Text;
            //Password
            string pass = textBox_pwd.Text;
            //Usertype
            string uType = comboBox_utype.Text.Trim();

            //Database connection
            MySqlConnection conn = new MySqlConnection("server=localhost;user id=root;database=bugbase");

            try
            {
                MySqlDataAdapter adapter = new MySqlDataAdapter("Select count(*) from userdetails where username='******'and password='******' and usertype='" + comboBox_utype.Text + "'", conn);
                DataTable        dt      = new DataTable();
                adapter.Fill(dt);//

                if (user.Equals("") || pass.Equals("") || uType.Equals(""))
                {
                    MessageBox.Show("Fill all the forms", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (dt.Rows[0][0].ToString() == "1")
                {
                    // loggedIn = user;
                    // loggedIN_utype = uType;
                    userpasswor = pass;
                    uname       = user;

                    usertype = uType;
                    switch (uType)
                    {
                    case "Admin":
                    {
                        // Admin Panel
                        //  loggedIN_utype = uType;
                        AdminPanel admin = new AdminPanel();
                        MessageBox.Show("Login was succesful.");
                        admin.Show();
                        this.Hide();

                        break;
                    }

                    //user
                    case "User":
                    {
                        // User Dashboard is displayed
                        UserPanel umenu = new UserPanel();
                        MessageBox.Show("Login was succesful.");
                        umenu.Show();
                        this.Hide();
                        break;
                    }

                    case "Programmer":
                    {
                        //Programmer Dashboard is displayed
                        ProgrammerPanel pmenu = new ProgrammerPanel();
                        MessageBox.Show("Login was succesful.");
                        pmenu.Show();
                        this.Hide();
                        break;
                    }
                    }
                }
                else
                {
                    MessageBox.Show("Username or password is incorrect", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }
            finally
            {
                //Step :CLose Connection
                conn.Close();
            }
        }