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));
        }
Exemple #2
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));
        }
Exemple #3
0
        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));
        }
Exemple #4
0
        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));
        }
        //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));
        }
Exemple #6
0
        private MySqlCommand getCorrectSqlCommandForDataDisplay(QueryType option, QueryData paramContainer)
        {
            //Retrieving data from the Querydata object(container object)
            int    userID        = paramContainer.UserID;
            String tableName     = paramContainer.TableName;
            int    selectedMonth = 0;

            //If single month data is requested then the value of the month from the QueryData object will be retrieved
            if (option == QueryType.SINGLE_MONTH)
            {
                selectedMonth = paramContainer.Month;
            }

            int selectedYear = paramContainer.Year;

            switch (tableName)
            {
            //Creates the correct SQL command based on the dateTimePicker selection(single month command/full year command)
            case "Incomes":
                if (option == QueryType.SINGLE_MONTH)
                {
                    return(SQLCommandBuilder.getSingleMonthCommand(sqlStatementSelectSingleMonthIncomes, new QueryData.Builder(userID).addMonth(selectedMonth).addYear(selectedYear).build()));
                }
                else if (option == QueryType.FULL_YEAR)
                {
                    return(SQLCommandBuilder.getFullYearRecordsCommand(sqlStatementSelectFullYearIncomes, new QueryData.Builder(userID).addYear(selectedYear).build()));    //CHANGE
                }
                else
                {
                    return(null);
                }

            case "General expenses":
                if (option == QueryType.SINGLE_MONTH)
                {
                    return(SQLCommandBuilder.getSingleMonthCommand(sqlStatementSelectSingleMonthGeneralExpenses, new QueryData.Builder(userID).addMonth(selectedMonth).addYear(selectedYear).build()));
                }
                else if (option == QueryType.FULL_YEAR)
                {
                    return(SQLCommandBuilder.getFullYearRecordsCommand(sqlStatementSelectFullYearGeneralExpenses, new QueryData.Builder(userID).addYear(selectedYear).build()));
                }
                else
                {
                    return(null);
                }

            case "Saving accounts expenses":
                if (option == QueryType.SINGLE_MONTH)
                {
                    return(SQLCommandBuilder.getSingleMonthCommand(sqlStatementSelectSingleMonthSavingAccountExpenses, new QueryData.Builder(userID).addMonth(selectedMonth).addYear(selectedYear).build()));
                }
                else if (option == QueryType.FULL_YEAR)
                {
                    return(SQLCommandBuilder.getFullYearRecordsCommand(sqlStatementSelectFullYearSavingAccountExpenses, new QueryData.Builder(userID).addYear(selectedYear).build()));
                }
                else
                {
                    return(null);
                }

            case "Debts":
                if (option == QueryType.SINGLE_MONTH)
                {
                    return(SQLCommandBuilder.getSingleMonthCommand(sqlStatementSelectSingleMonthDebts, new QueryData.Builder(userID).addMonth(selectedMonth).addYear(selectedYear).build()));
                }
                else if (option == QueryType.FULL_YEAR)
                {
                    return(SQLCommandBuilder.getFullYearRecordsCommand(sqlStatementSelectFullYearDebts, new QueryData.Builder(userID).addYear(selectedYear).build()));
                }
                else
                {
                    return(null);
                }

            case "Savings":
                if (option == QueryType.SINGLE_MONTH)
                {
                    return(SQLCommandBuilder.getSingleMonthCommand(sqlStatementSelectSingleMonthSavings, new QueryData.Builder(userID).addMonth(selectedMonth).addYear(selectedYear).build()));
                }
                else if (option == QueryType.FULL_YEAR)
                {
                    return(SQLCommandBuilder.getFullYearRecordsCommand(sqlStatementSelectFullYearSavings, new QueryData.Builder(userID).addYear(selectedYear).build()));
                }
                else
                {
                    return(null);
                }

            default:
                return(null);
            }
        }