コード例 #1
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));
        }
コード例 #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));
        }
コード例 #3
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));
        }
コード例 #4
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));
        }
コード例 #5
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));
        }