Example #1
0
        public void fillUsernameAndPass(CreateNewUser newUser, UserInfo newInfo)
        {
            username = newInfo.getUsername();
            password = newInfo.getPassword();
            //NewUser.Close();

            //UserControl1 NewUser2 = new UserControl1();
        }
Example #2
0
        //Button for creating a new user
        //We should really rename these buttons into something more descriptive
        private void loginButton_Click(object sender, EventArgs e)
        {
            NpgsqlConnection conn = new NpgsqlConnection("Server=127.0.0.1;Port=5432;User Id=postgres;Password=useitlab;Database=UserData;");
            conn.Open();

            //create a UserInfo instance with the user input
            UserInfo loginInfo = new UserInfo(textBox1.Text, textBox2.Text);

            string sql = "select * from userinfo where username='******'";
            NpgsqlDataAdapter da = new NpgsqlDataAdapter(sql, conn);
            ds.Reset();
            da.Fill(ds);
            dt = ds.Tables[0];

            if (dt.Rows.Count != 0)
            {
                if (dt.Rows[0][2].ToString() == loginInfo.getPassword())
                {
                    WelcomeScreen MainMenu = new WelcomeScreen(loginInfo);
                    MainMenu.ShowDialog();
                    conn.Close();
                }
                else
                {
                    error.show("Error! Password is incorrect!");
                }
            }
            else
            {
                error.show("Error! User does not exist!");
            }
            /***
            //Insert check for username and password
            //Need to check user input to all existing UserInfo instances

            //If the user input matchs existing user information then open the user's welcomescreen and info
            if (storedusers.ContainsKey(loginInfo.getUsername()))
            {
                if(storedusers[loginInfo.getUsername()] == textBox2.Text)
                {
                    //MessageBox.Show("Yay! User exists");
                    //Create and show a main menu screen for the specific user
                    WelcomeScreen MainMenu = new WelcomeScreen(loginInfo);
                    MainMenu.ShowDialog();
                }
                else
                {
                    // If the login fails show a screen that will inform the user
                    // Should provide useful information to user
                     error.show("Error! Password is incorrect!");
                    // LoginFail failed = new LoginFail();
                }
            }
            else
            {
                // If the login fails show a screen that will inform the user
                // Should provide useful information to user
                error.show("Error! Invalid user name.");
               // LoginFail failed = new LoginFail();
            } ***/

            conn.Close();
        }