Ejemplo n.º 1
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            String username, password;
            int valid = 0;
                //TODO: new view here maybe the dashboard?
                //MessageBox.Show("Login Successful");

                //Potential resource leak here ask for better solution
                username = txtUsername.Text;
                password = txtPassword.Text;
                valid = (int)usersTableAdapter.LoginValidation(username, password);
            if (valid > 0)
            {
                MessageBox.Show("Login Successful.");
                
                frmDashboard Dashboard = new frmDashboard();
                this.Visible = false;
                
                Dashboard.ShowDialog();
                this.DestroyHandle();
                this.Close();
                
            }
            else
            {
                //TODO: error invalid user.
                MessageBox.Show("Login Failed.");
            }
        }
        private void btnLogin_Click(object sender, EventArgs e)
        {
            String username, password;
            int valid = 0;
                //TODO: new view here maybe the dashboard?
                //MessageBox.Show("Login Successful");

                //Potential resource leak here ask for better solution
                username = txtUsername.Text;
                password = txtPassword.Text;
                try { valid = (int)usersTableAdapter.LoginValidation(username, password); }
            catch(Exception ewan){
                
            }
            if (valid > 0)
            {
                MessageBox.Show("Login Successful.");

                String uName = (String)usersTableAdapter.getUserName(valid);
                
                frmDashboard Dashboard = new frmDashboard(valid, uName);
                this.Visible = false;
                
                Dashboard.ShowDialog();
                try
                {
                    this.txtPassword.Text = "";
                    this.txtUsername.Text = "";
                    this.Visible = true;
                }
                catch (Exception ex)
                {
                }
            }
            else
            {
                //TODO: error invalid user.
                MessageBox.Show("Login Failed.");
            }
        }