Example #1
0
        //populate tester dashboard
        public void populatetesterdashboard(String username)
        {
            try
            {
                String sql = "select bug_id as id, summary as Summary,submittedby from tbl_bug where submittedby=@username";

                MySqlConnection conn = DBUtils.GetDBConnection();

                conn.Open();

                MySqlCommand cmd = new MySqlCommand();

                cmd.Connection = conn;

                cmd.CommandText = sql;

                MySqlDataAdapter MyAdapter = new MySqlDataAdapter();
                cmd.Parameters.AddWithValue("@username", username);
                MyAdapter.SelectCommand = cmd;

                DataTable dTable = new DataTable();
                MyAdapter.Fill(dTable);

                TesterDashboard tdash = new TesterDashboard();
                tdash.dataTable = dTable;

                tdash.Show();
                tdash.sessionusername = username;
                Debug.WriteLine("Logged in");
            }
            catch (Exception e)
            {
                Debug.WriteLine("Error Message: " + e);
                Debug.WriteLine(e.StackTrace);
            }
        }
Example #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            /*
             * string user = txtUser.Text;
             * string pass = txtPass.Text;
             * if (IsLogin(user, pass)){
             *
             *  MessageBox.Show($"Welcome{user}!");
             *  this.Hide();
             *  Dashboard ds = new Dashboard();
             *  ds.Show();
             *
             * }
             * else
             * {
             *  MessageBox.Show($"User Does not Exist");
             * }*/

            string username = txtUser.Text;
            string password = txtPass.Text;

            if (!string.IsNullOrEmpty(username))
            {
                if (!string.IsNullOrEmpty(password))
                {
                    MemberModel user = new MemberModel();

                    user.Email    = username;
                    user.Password = password;
                    MemberController userController = new MemberController();
                    Boolean          valid          = userController.Authenticate(user);
                    if (valid)
                    {
                        string role = userController.RetrieveRole(user);
                        //opening required user dashboard
                        if (role == "Admin")
                        {
                            this.Hide();
                            Dashboard Dash = new Dashboard(username);
                            Dash.ShowDialog();
                            this.Close();
                        }
                        else if (role == "Developer")
                        {
                            this.Hide();
                            DevDashboard devDash = new DevDashboard(username);
                            devDash.ShowDialog();
                            this.Close();
                        }
                        else
                        {
                            this.Hide();
                            TesterDashboard testDash = new TesterDashboard(username);
                            testDash.ShowDialog();
                            this.Close();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Invalid username or password!");
                        txtUser.Text = "";
                        txtPass.Focus();
                    }
                }
                else
                {
                    MessageBox.Show("Please enter your password!");
                    txtPass.Focus();
                }
            }
            else
            {
                MessageBox.Show("Please enter your username!");
                txtUser.Focus();
            }
        }