Exemplo n.º 1
0
        private void SigninButton_Click(object sender, EventArgs e)
        {
            try
            {
                /*when you type default, look for the link to the database you have made*/
                string ConnectionString = Properties.Settings.Default.UsersDBConnectionString;
                string MySQLString;
                int    MaxRows = 0;
                int    Counter = 0;

                /* this links to the database connection and calls it object connection */
                DatabaseConnection objConnect = new DatabaseConnection();
                DataSet            mydataset;
                DataRow            RecordFromADatabase;

                objConnect.connection_string = ConnectionString;


                //to do, test this validation routine for encryptedpassword
                ValidationRoutines CheckDataEntry = new ValidationRoutines();
                CheckDataEntry.GetPassword = PasswordTextBox.Text;
                MySQLString = "(((SELECT UserID, Firstname, Email FROM Users WHERE Username = '******' AND UserPassword = '******'";

                objConnect.SQL = MySQLString;
                objConnect.SQL = objConnect.PreventInjection();

                mydataset = objConnect.GetConnection;

                //if the record is found, get the data from the database that has been retrieved.
                MaxRows = mydataset.Tables[0].Rows.Count;
                if (MaxRows > 0)
                {
                    //this pulls out username firstname from the database, could pull more if necessary.
                    RecordFromADatabase = mydataset.Tables[0].Rows[Counter];

                    ProfileRoutines setupUserProfile = new ProfileRoutines();
                    setupUserProfile.GetUserID    = int.Parse(RecordFromADatabase.ItemArray.GetValue(0).ToString());
                    setupUserProfile.GetFirstname = RecordFromADatabase.ItemArray.GetValue(1).ToString();
                    setupUserProfile.GetUsername  = UsernameTextBox.Text;
                    setupUserProfile.GetEmail     = EmailTextBox.Text;

                    this.Hide();
                    SplashPage DisplaySplashForm = new SplashPage(setupUserProfile);
                    DisplaySplashForm.Show();
                }
                else
                {
                    //password error message
                    ErrorLabel.ForeColor = System.Drawing.Color.Red;
                    ErrorLabel.Text      = "Invalid Username/Password Combination, please try again";
                }
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message);
            }
        }
Exemplo n.º 2
0
        private void ConfirmSecurityCodeButton_Click(object sender, EventArgs e)
        {
            //remove this when fully tested
            MessageBox.Show(Securitycode);



            if (Securitycode == ConfirmSecurityTextBox.Text)
            {
                /* this links to the database connection and calls it object connection */
                DatabaseConnection objConnect;
                string             ConnectionString;
                string             MySQLString;

                objConnect = new DatabaseConnection();
                /*when you type default, look for the link to the database you have made*/
                ConnectionString = Properties.Settings.Default.UsersDBConnectionString;

                objConnect.connection_string = ConnectionString;

                //write code to get last userid and insert it into DB
                MySQLString = "INSERT INTO Users(Firstname, Username, UserPassword, Email) VALUES ('" + SingleUserProfile.GetFirstname + "' , '" + SingleUserProfile.GetUsername + "', ' " + SingleUserProfile.GetPW + "', ' " + SingleUserProfile.GetEmail + "')";

                objConnect.SQL = MySQLString;
                objConnect.SQL = objConnect.PreventInjection();

                MessageBox.Show(objConnect.InsertItem);

                //once they have entered the passcode, clear out the password value in their profile, security.
                SingleUserProfile.GetPW = "";


                this.Hide();
                SplashPage DisplaySplashForm = new SplashPage(SingleUserProfile);
                DisplaySplashForm.Show();
            }
            else
            {
                MessageBox.Show("please try again");
            }
        }