Ejemplo n.º 1
0
        private void button_reg_Click(object sender, EventArgs e)
        {
            string oldpwd = txt_oldpwd.Text;
            string newpwd = txt_newPwd.Text;
            //Database Connection
            string pas  = Form1.userpasswor;
            string type = Form1.usertype;

            if (pas.Equals(txt_oldpwd.Text))
            {
                MySqlConnection conn = new MySqlConnection("server = localhost; user id = root; database = bugtrack");
                // MessageBox.Show("password matched");
                MySqlCommand sda = new MySqlCommand("update userdetails set password='******', confirmPassword='******' where username='******'", conn);
                //Open Connection
                conn.Open();
                int rows = sda.ExecuteNonQuery();

                //if Inserted rows is greater is greater than 0
                //Else set isSuccess to false, Save Failed


                if (rows > 0)
                {
                    MessageBox.Show("Password changed. Please click ok to continue");
                    //Dashboard page
                    if (type == "user")
                    {
                        userPanel dash = new userPanel();
                        dash.Show();
                        this.Hide();
                    }
                    else
                    {
                        //Dashboard page
                        ProgrammerPanel pdash = new ProgrammerPanel();
                        pdash.Show();
                        this.Hide();
                    }
                }
                else
                {
                    //Display message
                    MessageBox.Show("Password failed to changed. click ok to continue");
                }
            }
            else
            {
                //Display message
                MessageBox.Show("Old password didnot mathed");
            }
        }
Ejemplo n.º 2
0
        private void button_cancel_Click(object sender, EventArgs e)
        {
            string type = Form1.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();
            }
        }
Ejemplo n.º 3
0
        private void btn_login_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=bugtrack");

            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(null) || pass.Equals(null) || uType.Equals(null))
                {
                    MessageBox.Show("U must 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();
            }
        }