コード例 #1
0
        //CHANGE!!!!!
        public int deleteData(QueryType option, QueryData paramContainer, DataTable sourceDataTable)
        {
            MySqlCommand updateTableCommand = getCorrectSqlCommandForDataDisplay(option, paramContainer);
            int          executionResult    = DBConnectionManager.deleteData(updateTableCommand, sourceDataTable);

            return(executionResult);
        }
コード例 #2
0
        //Metoda ce executa comanda SQL de interogare a bazei de date cu privire la utilizatorul specificat
        private DataTable getUser(String sqlStatement, String userName)
        {
            MySqlCommand userExistenceCheckCommand = new MySqlCommand(sqlStatement);

            userExistenceCheckCommand.Parameters.AddWithValue("@paramUserName", userName);

            return(DBConnectionManager.getData(userExistenceCheckCommand));
        }
コード例 #3
0
        //The method returns a DataTable object using the provided arguments to decide the actual SQl query that will be executed(the query type(single/multiple months) and the data source that will be populated with data are taken into account for this decision)
        public DataTable getNewData(QueryType option, QueryData paramContainer, SelectedDataSource dataSource)
        {
            //Creates a MySqlCommand object tht will be populated with the actual command object selected after analyzing the previously mentioned arguments inside the if/else and switch block
            MySqlCommand command = null;

            //Single month query
            //The specific SQL query from which the command will be created  is selected based on the data source and the type of data that needs to be displayed
            if (option == QueryType.SINGLE_MONTH)
            {
                switch (dataSource)
                {
                case SelectedDataSource.DYNAMIC_DATASOURCE_1:
                    command = SQLCommandBuilder.getSingleMonthCommand(sqlStatementSingleMonthIncomes, paramContainer);
                    break;

                case SelectedDataSource.DYNAMIC_DATASOURCE_2:
                    command = SQLCommandBuilder.getSingleMonthCommand(sqlStatementIncomeTypeSumSingle, paramContainer);
                    break;

                case SelectedDataSource.STATIC_DATASOURCE:
                    command = SQLCommandBuilder.getMonthlyTotalsCommand(sqlStatementMonthlyTotalIncomes, paramContainer);
                    break;

                default:
                    break;
                }
                //Multiple months query
            }
            else if (option == QueryType.MULTIPLE_MONTHS)
            {
                switch (dataSource)
                {
                case SelectedDataSource.DYNAMIC_DATASOURCE_1:
                    command = SQLCommandBuilder.getMultipleMonthsCommand(sqlStatementMultipleMonthsIncomes, paramContainer);
                    break;

                case SelectedDataSource.DYNAMIC_DATASOURCE_2:
                    command = SQLCommandBuilder.getMultipleMonthsCommand(sqlStatementIncomeTypeSumMultiple, paramContainer);
                    break;

                case SelectedDataSource.STATIC_DATASOURCE:
                    command = SQLCommandBuilder.getMonthlyTotalsCommand(sqlStatementMonthlyTotalIncomes, paramContainer);
                    break;

                default:
                    break;
                }
                //Monthly totals query
            }
            else if (option == QueryType.MONTHLY_TOTALS)
            {
                command = SQLCommandBuilder.getMonthlyTotalsCommand(sqlStatementMonthlyTotalIncomes, paramContainer);
            }

            //The data is retrieved by passing the previously obtained command to the DBConnectionManger's getData() method
            return(DBConnectionManager.getData(command));
        }
コード例 #4
0
ファイル: ExpensesModel.cs プロジェクト: Oddo94/BudgetManager
        public DataTable getNewData(QueryType option, QueryData paramContainer, SelectedDataSource dataSource)
        {
            MySqlCommand command = null;

            if (option == QueryType.SINGLE_MONTH)
            {
                switch (dataSource)
                {
                //Grid view
                case SelectedDataSource.DYNAMIC_DATASOURCE_1:
                    command = SQLCommandBuilder.getSingleMonthCommand(sqlStatementSingleMonthExpenses, paramContainer);
                    break;

                //Pie chart
                case SelectedDataSource.DYNAMIC_DATASOURCE_2:
                    command = SQLCommandBuilder.getSingleMonthCommand(sqlStatementExpenseTypeSumSingle, paramContainer);
                    break;

                //Column chart
                case SelectedDataSource.STATIC_DATASOURCE:
                    command = SQLCommandBuilder.getMonthlyTotalsCommand(sqlStatementMonthlyTotalExpenses, paramContainer);
                    break;

                default:
                    break;
                }
            }
            else if (option == QueryType.MULTIPLE_MONTHS)
            {
                switch (dataSource)
                {
                //Grid view
                case SelectedDataSource.DYNAMIC_DATASOURCE_1:
                    command = SQLCommandBuilder.getMultipleMonthsCommand(sqlStatementMultipleMonthsExpenses, paramContainer);
                    break;

                //Pie chart
                case SelectedDataSource.DYNAMIC_DATASOURCE_2:
                    command = SQLCommandBuilder.getMultipleMonthsCommand(sqlStatementExpenseTypeSumMultiple, paramContainer);
                    break;

                //Column chart
                case SelectedDataSource.STATIC_DATASOURCE:
                    command = SQLCommandBuilder.getMonthlyTotalsCommand(sqlStatementMonthlyTotalExpenses, paramContainer);
                    break;

                default:
                    break;
                }
            }
            else if (option == QueryType.MONTHLY_TOTALS)
            {
                command = SQLCommandBuilder.getMonthlyTotalsCommand(sqlStatementMonthlyTotalExpenses, paramContainer);
            }

            return(DBConnectionManager.getData(command));
        }
コード例 #5
0
        //Creaza comanda SQL de actualizarea a datelor in baza de date utilizand ca parametri un sir de bytes, hashcode-ul parolei si id-ul usrrului care cere resetarea parolei
        private int updatePassword(byte[] inputSalt, String inputHash, int userID)
        {
            MySqlCommand updatePasswordCommand = SQLCommandBuilder.getUpdatePasswordCommand(sqlStatementUpdatePassword, inputSalt, inputHash, userID);

            //Trimite comanda pt a fi executata de metoda specializata a clasei DBConnectionManager
            int executionResult = DBConnectionManager.insertData(updatePasswordCommand);

            return(executionResult);
        }
コード例 #6
0
        private DataTable getData(int userID)
        {
            String       sqlStatementGetAuthenticationData = @"SELECT username, salt, password FROM users WHERE userID = @paramID";
            MySqlCommand command = new MySqlCommand(sqlStatementGetAuthenticationData);

            command.Parameters.AddWithValue("@paramID", userID);

            return(DBConnectionManager.getData(command));
        }
コード例 #7
0
        private void writeAuthenticationDataToDB(byte[] salt, String hashedPassword, int userID)
        {
            String       sqlStatementInsertAuthenticationData = @"UPDATE users SET users.salt = @paramSalt, users.password = @paramPassword WHERE users.userID = @paramID";
            MySqlCommand insertCommand = new MySqlCommand(sqlStatementInsertAuthenticationData);

            insertCommand.Parameters.AddWithValue("@paramSalt", salt);
            insertCommand.Parameters.AddWithValue("@paramPassword", hashedPassword);
            insertCommand.Parameters.AddWithValue("@paramID", userID);

            DBConnectionManager.insertData(insertCommand);
        }
コード例 #8
0
        //Method for creating the SQL statement that retrieves the data displayed by the yearly column chart
        public static MySqlCommand getMonthlyTotalsCommand(String sqlStatement, QueryData paramContainer)
        {
            Guard.notNull(sqlStatement, "SQL statement");
            Guard.notNull(paramContainer, "parameter container");

            MySqlCommand monthlyTotalsCommand = new MySqlCommand(sqlStatement, DBConnectionManager.getConnection(DBConnectionManager.BUDGET_MANAGER_CONN_STRING));//Nu e neaparata adaugarea conexiunii la crearea comenzii intrucat metoda getData a clasei DBConnectionmanager face deja asta in mod implicit

            monthlyTotalsCommand.Parameters.AddWithValue("@paramID", paramContainer.UserID);
            monthlyTotalsCommand.Parameters.AddWithValue("@paramYear", paramContainer.Year);

            return(monthlyTotalsCommand);
        }
コード例 #9
0
ファイル: SavingsModel.cs プロジェクト: Oddo94/BudgetManager
        public DataTable getNewData(QueryType option, QueryData paramContainer, SelectedDataSource dataSource)
        {
            MySqlCommand command = null;

            if (option == QueryType.SINGLE_MONTH)
            {
                switch (dataSource)
                {
                case SelectedDataSource.DYNAMIC_DATASOURCE_1:
                    command = SQLCommandBuilder.getSingleMonthCommand(sqlStatementSingleMonthSavings, paramContainer);
                    break;

                case SelectedDataSource.DYNAMIC_DATASOURCE_2:
                    command = SQLCommandBuilder.getSingleMonthCommand(sqlStatementSavingsValueSumSingle, paramContainer);
                    break;

                case SelectedDataSource.STATIC_DATASOURCE:
                    command = SQLCommandBuilder.getMonthlyTotalsCommand(sqlStatementMonthlyTotalSavings, paramContainer);
                    break;

                default:
                    break;
                }
            }
            else if (option == QueryType.MULTIPLE_MONTHS)
            {
                switch (dataSource)
                {
                case SelectedDataSource.DYNAMIC_DATASOURCE_1:
                    command = SQLCommandBuilder.getMultipleMonthsCommand(sqlStatementMultipleMonthsSavings, paramContainer);
                    break;

                case SelectedDataSource.DYNAMIC_DATASOURCE_2:
                    command = SQLCommandBuilder.getMultipleMonthsCommand(sqlStatementSavingsValueSumMultiple, paramContainer);
                    break;

                case SelectedDataSource.STATIC_DATASOURCE:
                    command = SQLCommandBuilder.getMonthlyTotalsCommand(sqlStatementMonthlyTotalSavings, paramContainer);
                    break;

                default:
                    break;
                }
                //Obtinere comanda pentru extragere date pentru fiecare luna a unui an
            }
            else if (option == QueryType.MONTHLY_TOTALS)
            {
                command = SQLCommandBuilder.getMonthlyTotalsCommand(sqlStatementMonthlyTotalSavings, paramContainer);
            }

            return(DBConnectionManager.getData(command));
        }
コード例 #10
0
        private void registerButton_Click(object sender, EventArgs e)
        {
            if (!DBConnectionManager.hasConnection())
            {
                MessageBox.Show(this, "No database connection! Unable to create new user/s.", "Register");
                return;
            }

            //Inchide formularul de autentificare
            this.Visible = false;
            //Afiseaza formularul de creare al unui nou utilizator
            new RegisterForm().Visible = true;
        }
コード例 #11
0
ファイル: DebtsModel.cs プロジェクト: Oddo94/BudgetManager
        public DataTable getNewData(QueryType option, QueryData paramContainer, SelectedDataSource dataSource)
        {
            MySqlCommand command = null;

            if (option == QueryType.SINGLE_MONTH)
            {
                switch (dataSource)
                {
                case SelectedDataSource.DYNAMIC_DATASOURCE_1:
                    command = SQLCommandBuilder.getSingleMonthCommand(sqlStatementSingleMonthDebts, paramContainer);
                    break;

                case SelectedDataSource.DYNAMIC_DATASOURCE_2:
                    command = SQLCommandBuilder.getSingleMonthCommand(sqlStatementDebtValueSumForCreditorSingle, paramContainer);
                    break;

                case SelectedDataSource.STATIC_DATASOURCE:
                    command = SQLCommandBuilder.getMonthlyTotalsCommand(sqlStatementMonthlyTotalDebts, paramContainer);
                    break;

                default:
                    break;
                }
            }
            else if (option == QueryType.MULTIPLE_MONTHS)
            {
                switch (dataSource)
                {
                case SelectedDataSource.DYNAMIC_DATASOURCE_1:
                    command = SQLCommandBuilder.getMultipleMonthsCommand(sqlStatementMultipleMonthsDebts, paramContainer);
                    break;

                case SelectedDataSource.DYNAMIC_DATASOURCE_2:
                    command = SQLCommandBuilder.getMultipleMonthsCommand(sqlStatementDebtValueSumForCreditorMultiple, paramContainer);
                    break;

                case SelectedDataSource.STATIC_DATASOURCE:
                    command = SQLCommandBuilder.getMonthlyTotalsCommand(sqlStatementMonthlyTotalDebts, paramContainer);
                    break;

                default:
                    break;
                }
            }
            else if (option == QueryType.MONTHLY_TOTALS)
            {
                command = SQLCommandBuilder.getMonthlyTotalsCommand(sqlStatementMonthlyTotalDebts, paramContainer);
            }

            return(DBConnectionManager.getData(command));
        }
コード例 #12
0
        //Metoda prin care modelul aduce date din DB
        public DataTable getNewData(QueryType option, QueryData paramContainer, SelectedDataSource dataSource)
        {
            MySqlCommand command = null;

            if (option == QueryType.SINGLE_MONTH)
            {
                switch (dataSource)
                {
                case SelectedDataSource.DYNAMIC_DATASOURCE_1:
                    command = SQLCommandBuilder.getSingleMonthCommand(sqlStatementSummarySingle, paramContainer);
                    break;

                case SelectedDataSource.DYNAMIC_DATASOURCE_2:
                    break;

                case SelectedDataSource.STATIC_DATASOURCE:
                    break;

                default:
                    break;
                }
            }
            else if (option == QueryType.MULTIPLE_MONTHS)
            {
                switch (dataSource)
                {
                case SelectedDataSource.DYNAMIC_DATASOURCE_1:
                    command = SQLCommandBuilder.getMultipleMonthsCommand(sqlStatementSummaryMultiple, paramContainer);
                    break;

                case SelectedDataSource.DYNAMIC_DATASOURCE_2:
                    break;

                case SelectedDataSource.STATIC_DATASOURCE:
                    break;

                default:
                    break;
                }
            }
            //In cazul modelelor care nu utilizeaza toate cele trei data tables definite in interfata IModel comanda SQL ramane cu valoarea null si
            //astfel nu se va mai executa metoda de extragere a datelor din DB
            if (command == null)
            {
                return(null);
            }

            return(DBConnectionManager.getData(command));
        }
コード例 #13
0
        public DataTable getNewData(QueryType option, QueryData paramContainer, SelectedDataSource dataSource)
        {
            MySqlCommand command = null;

            if (option == QueryType.SINGLE_MONTH)
            {
                switch (dataSource)
                {
                //Grid view
                case SelectedDataSource.DYNAMIC_DATASOURCE_1:
                    break;

                //Pie chart
                case SelectedDataSource.DYNAMIC_DATASOURCE_2:
                    break;

                //Column chart
                case SelectedDataSource.STATIC_DATASOURCE:
                    command = getCorrectSqlCommandForDataDisplay(option, paramContainer);
                    break;

                default:
                    break;
                }
            }
            else if (option == QueryType.FULL_YEAR)
            {
                switch (dataSource)
                {
                //Grid view
                case SelectedDataSource.DYNAMIC_DATASOURCE_1:
                    break;

                //Pie chart
                case SelectedDataSource.DYNAMIC_DATASOURCE_2:
                    break;

                //Column chart
                case SelectedDataSource.STATIC_DATASOURCE:
                    command = getCorrectSqlCommandForDataDisplay(option, paramContainer);
                    break;

                default:
                    break;
                }
            }

            return(DBConnectionManager.getData(command));
        }
コード例 #14
0
        public int updateData(QueryType option, QueryData paramContainer, DataTable sourceDataTable)
        {
            int executionResult = 0;

            //Recreating the command used for displaying the data in the table
            MySqlCommand updateTableCommand = getCorrectSqlCommandForDataDisplay(option, paramContainer);

            //Calling the method which updates the data
            executionResult = DBConnectionManager.updateData(updateTableCommand, sourceDataTable);

            if (executionResult > 0)
            {
                return(executionResult);
            }

            return(-1);
        }
コード例 #15
0
        //Aduce adresa de email a utilizatorului care cere resetarea parolei, din baza de date
        private String getUserEmail(String userName)
        {
            MySqlCommand retrieveUserEmailCommand = new MySqlCommand(sqlStatementRetrieveUserEmail);

            retrieveUserEmailCommand.Parameters.AddWithValue("@paramUserName", userName);

            DataTable userEmailTable = DBConnectionManager.getData(retrieveUserEmailCommand);

            String userEmail = "";

            if (userEmailTable != null && userEmailTable.Rows.Count == 1)
            {
                userEmail = userEmailTable.Rows[0].ItemArray[0].ToString();
            }

            return(userEmail);
        }
コード例 #16
0
        public static DataTable getData(MySqlCommand command)
        {
            //Creates a new connection
            MySqlConnection conn = DBConnectionManager.getConnection(DBConnectionManager.BUDGET_MANAGER_CONN_STRING);

            //Assigning the connection to the command object
            command.Connection = conn;

            //Creating a DataAdapter based on the command object
            MySqlDataAdapter adp = DBConnectionManager.getDataAdapter(command);

            //Creating an empty DataTable
            DataTable dataTable = new DataTable();

            try {
                //Se deschide conexiunea si se umple cu date obiectul DataTable
                //Opening the connection and populating the DataTable object with data
                conn.Open();
                adp.Fill(dataTable);
            } catch (MySqlException ex) {
                //If an exception is thrown then a MessageBox containing the execption or the custom message (for error code 1042) is displayed
                int    errorCode = ex.Number;
                String message;
                if (errorCode == 1042)
                {
                    message = "Unable to connect to the database! Please check the connection and try again.";
                }
                else
                {
                    message = ex.Message;
                }
                MessageBox.Show(message, "DBConnectionManager", MessageBoxButtons.OK, MessageBoxIcon.Error);
            } finally {
                //Closing the connection irrespective of the command execution result
                conn.Close();
            }

            return(dataTable);
        }
コード例 #17
0
        private void loginButton_Click(object sender, EventArgs e)
        {
            if (!DBConnectionManager.hasConnection())
            {
                //MessageBox.Show(this, "No database connection! Unable to login.", "Login");
                MessageBox.Show(this, "No database connection! Unable to login.", "Login", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            String userName = userNameTextBox.Text;
            String password = passwordTextBox.Text;


            MySqlCommand authenticationDataCommand = new MySqlCommand(sqlStatementGetAuthenticationData);

            authenticationDataCommand.Parameters.AddWithValue("@paramUserName", userName);

            //Aducere informatii din baza de date
            DataTable authenticationData = DBConnectionManager.getData(authenticationDataCommand);

            //Verificarea existentei utilizatorului si a corectitudinii datelor introduse
            if (userExists(authenticationData) && hasValidCredentials(authenticationData, password))
            {
                //Se extrage id-ul de utilizator
                int userID = getUserID(authenticationData);
                this.Visible = false;

                //Se trimite id-ul ca argument constructorului clasei UserDashboard pt a putea fi utilizat ulterior la interogarea bazei de date
                UserDashboard userDashboard = new UserDashboard(userID, userName);

                userDashboard.Visible = true;
            }
            else
            {
                //MessageBox.Show("Invalid username and/or password! Please try again", "Login");
                MessageBox.Show("Invalid username and/or password! Please try again", "Login", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #18
0
ファイル: ExpensesModel.cs プロジェクト: Oddo94/BudgetManager
 public bool hasDBConnection()
 {
     return(DBConnectionManager.hasConnection());
 }
コード例 #19
0
        private void registerButton_Click(object sender, EventArgs e)
        {
            string userName     = userNameTextBox.Text;
            string password     = passwordTextBox.Text;
            string emailAddress = emailTextBox.Text;

            if (!isValidUserName(userName))
            {
                MessageBox.Show("The username must have at least 3 characters and can contain only lowercase(a-z) and uppercase(A-Z) letters, digits(0-9) and underscores(_)!", "User registration", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }


            if (password.Length < minimumPasswordLength)
            {
                MessageBox.Show("Your password should be at least 10 characters long! Please try again.", "User registration", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (!isValidPassword(password))
            {
                MessageBox.Show("Invalid password! Your password must contain:\n1.Lowercase and uppercase letters (a-zA-z) \n2.Digits (0-9) \n3.Special characters (@#$%<>?)", "User registration", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }


            if (!isValidEmail(emailAddress))
            {
                MessageBox.Show("Invalid email address!", "User registration", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (userExists(getUser(sqlStatementCheckUserExistence, userName)))
            {
                MessageBox.Show("The selected username already exists! Please try again", "User registration", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            ConfirmationSender emailSender = new ConfirmationSender();

            string emailSubject     = "New user creation";
            string emailBody        = "A user creation request was made for an account that will associated to this email address.\nPlease enter the following code to finish user creation process and confirm your email: {0} \nIf you have not made such a request please ignore this email and delete it.";
            string onSuccessMessage = "An email containing the confirmation code for the new user creation was sent to the specified email address";
            string parentWindowName = "Register";

            string generatedConfirmationCode = emailSender.generateConfirmationCode();

            emailSender.sendConfirmationEmail(emailAddress, emailSubject, emailBody, generatedConfirmationCode, onSuccessMessage, parentWindowName);

            String userInputConfirmationCode = Interaction.InputBox("Enter the code received on your email to finish the user creation process:", "Confirmation Code", "Enter code", 200, 200);

            if (emailSender.confirmationCodesMatch(generatedConfirmationCode, userInputConfirmationCode))
            {
                PasswordSecurityManager securityManager = new PasswordSecurityManager();
                byte[]       salt                = securityManager.getSalt(16);
                string       hashCode            = securityManager.createPasswordHash(password, salt);
                MySqlCommand userCreationCommand = SQLCommandBuilder.getNewUserCreationCommand(sqlStatementCreateNewUser, userName, salt, hashCode, emailAddress);
                int          executionResult     = DBConnectionManager.insertData(userCreationCommand);

                if (executionResult == -1)
                {
                    MessageBox.Show("Could not create the requested user!", "Register", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                MessageBox.Show("Your user was succesfully created!", "Register", MessageBoxButtons.OK, MessageBoxIcon.Information);
                clearInputFields(textBoxes);
                registerButton.Enabled = false;
            }
            else
            {
                MessageBox.Show("Invalid confirmation code! Please try again.", "Register", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #20
0
        private void resetPasswordButton_Click(object sender, EventArgs e)
        {
            if (!DBConnectionManager.hasConnection())
            {
                //MessageBox.Show(this, "No database connection! Unable to reset your password.", "Password reset manager");
                MessageBox.Show(this, "No database connection! Unable to reset your password.", "Password reset manager", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            //Cere confirmarea utilizatorului pentru resetarea parolei si inregistreaza rezultatul
            //DialogResult userOption = MessageBox.Show(this, "Are you sure that you want to reset your password?", "Password reset manager", MessageBoxButtons.YesNo);
            DialogResult userOption = MessageBox.Show(this, "Are you sure that you want to reset your password?", "Password reset manager", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            //Daca se selecteaza optiunea "No" se iese din metoda si se opreste procesul de resetare
            if (userOption == DialogResult.No)
            {
                //Console.WriteLine("User selected NO option");
                return;
            }

            //Adunare date necesare resetarii parolei
            String userName             = userNameTextBox.Text;
            String newPassword          = newPasswordTextBox.Text;
            String confirmationPassword = confirmPasswordTextBox.Text;

            //Verifica daca noua parola si parola de confirmare sunt identice
            if (!newPassword.Equals(confirmationPassword))
            {
                //MessageBox.Show("The input passwords don't match! Please try again!", "Password reset manager");
                MessageBox.Show("The input passwords don't match! Please try again!", "Password reset manager", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                return;
            }

            //Verifica daca parola respecta regulile de complexitate
            if (newPassword.Length < minimumPasswordLength)
            {
                //MessageBox.Show("Your password should be at least 10 characters long! Please try again.", "Password reset manager");
                MessageBox.Show("Your password should be at least 10 characters long! Please try again.", "Password reset manager", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (!isValidPassword(newPassword))
            {
                //MessageBox.Show("Invalid password! Your password must contain:\n1.Lowercase and uppercase letters (a-zA-z) \n2.Digits (0-9) \n3.Special characters (@#$%<>?)", "Password reset manager");
                MessageBox.Show("Invalid password! Your password must contain:\n1.Lowercase and uppercase letters (a-zA-z) \n2.Digits (0-9) \n3.Special characters (@#$%<>?)", "Password reset manager", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }


            MySqlCommand retrieveResetPasswordDataCommand = new MySqlCommand(sqlStatementGetDataForPasswordReset);

            retrieveResetPasswordDataCommand.Parameters.AddWithValue("@paramUserName", userName);

            DataTable resetPasswordDataTable = DBConnectionManager.getData(retrieveResetPasswordDataCommand);

            //Se verifica daca exista utilizatorul
            if (userExists(resetPasswordDataTable))
            {
                Object emailData = resetPasswordDataTable.Rows[0].ItemArray[2];
                String userEmail = emailData != DBNull.Value ? emailData.ToString() : "";

                //Se verifica daca utilizatorul are setata o adresa de email
                if ("".Equals(userEmail))
                {
                    //MessageBox.Show("Unable to retrieve the email address for the selected user!", "Password reset manager");
                    MessageBox.Show("Unable to retrieve the email address for the selected user!", "Password reset manager", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                //Se creeaza obiectele necesare pt procesul de resetare doar daca sunt indeplinite toate conditiile anterioare
                //Obiectul pt resetarea efectiva a parolei
                PasswordResetManager passwordResetManager = new PasswordResetManager();

                //Obiectul pt trimiterea codului de confirmare
                ConfirmationSender confirmationSender = new ConfirmationSender();

                //Date necesare pt trimiterea emailului
                string emailSubject     = "Password reset";
                string emailBody        = "A password reset was requested for the account associated to this email address.\nPlease enter the following code to finish the password reset process: {0} \nIf you have not requested the password reset please ignore this email and delete it.";
                string onSuccessMessage = "An email containing the reset password procedure has been sent to your email address";
                string parentWindowName = "Password reset manager";

                string generatedConfirmationCode = confirmationSender.generateConfirmationCode();
                confirmationSender.sendConfirmationEmail(userEmail, emailSubject, emailBody, generatedConfirmationCode, onSuccessMessage, parentWindowName);

                String userInputConfirmationCode = Interaction.InputBox("Enter the code received on your email to finish the reset process:", "Confirmation Code", "Enter code", 200, 200);

                if (confirmationSender.confirmationCodesMatch(generatedConfirmationCode, userInputConfirmationCode))
                {
                    int userID          = Convert.ToInt32(resetPasswordDataTable.Rows[0].ItemArray[0]);
                    int executionResult = passwordResetManager.resetPassword(newPassword, userID);//Daca din diverse motive nu se pot insera in baza de date noile informatii(salt si hashcode) metoda returneaza -1

                    if (executionResult == -1)
                    {
                        //MessageBox.Show("Could not reset your password!", "Password reset manager");
                        MessageBox.Show("Could not reset your password!", "Password reset manager", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    //MessageBox.Show("Your password has been succesfully reset!", "Password reset manager");
                    MessageBox.Show("Your password has been succesfully reset!", "Password reset manager", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    //Se afiseaza mesajul doar daca codul introdus nu se potriveste cu cel generat nu si in situatia in care
                    //utilizatorul selecteaza optiunea Cancel sau inchide fereastra
                    if (!"".Equals(userInputConfirmationCode))
                    {
                        //MessageBox.Show("Invalid confirmation code! Please try again.", "Password reset manager");
                        MessageBox.Show("Invalid confirmation code! Please try again.", "Password reset manager", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            else
            {
                //MessageBox.Show("Invalid username!", "Password reset manager");
                MessageBox.Show("Invalid username!", "Password reset manager", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            TextBox[] textBoxes = new TextBox[] { newPasswordTextBox, confirmPasswordTextBox };
            clearInputFields(textBoxes);
            resetPasswordButton.Enabled = false;
        }