Ejemplo n.º 1
0
        /*****************************************************************************/
        //UTILITY METHODS SECTION

        //private void fillDataGridView(DataGridView gridView, DataTable inputDataTable) {
        //    //Null check and row count check(the condition for row count is set to >= 0 so that if a user selects an item with no available records,
        //    //an empty table will be displayed and it will be easier to understand the current status of that item for the selected month)
        //    if (inputDataTable != null && inputDataTable.Rows.Count >= 0) {
        //        //Sets the data source for the table
        //        gridView.DataSource = inputDataTable;
        //        //Deactivates the editing for the first table column because it will always contain the primary keys of the records and modifying these values would alter the DB structure
        //        dataGridViewTableDisplay.Columns[0].ReadOnly = true;
        //    }
        //}

        private void sendDataToController(DataUpdateControl pickerType, ComboBox itemComboBox, DateTimePicker datePicker)
        {
            //Single month data selection
            if (pickerType == DataUpdateControl.MONTHLY_PICKER)
            {
                QueryType option = QueryType.SINGLE_MONTH;

                int    selectedMonth = datePicker.Value.Month;
                int    selectedYear  = datePicker.Value.Year;
                String tableName     = itemComboBox.Text;
                //Creating the storage object for the data that will be passed to the controller
                QueryData paramContainer = new QueryData.Builder(userID).addMonth(selectedMonth).addYear(selectedYear).addTableName(tableName).build(); //CHANGE

                controller.requestData(option, paramContainer);

                //Multiple months data selection
            }
            else if (pickerType == DataUpdateControl.YEARLY_PICKER)
            {
                QueryType option = QueryType.FULL_YEAR;

                int    selectedYear = datePicker.Value.Year;
                String tableName    = itemComboBox.Text;

                QueryData paramContainer = new QueryData.Builder(userID).addYear(selectedYear).addTableName(tableName).build(); //CHANGE

                controller.requestData(option, paramContainer);
            }
        }
Ejemplo n.º 2
0
        //Method for sending the correct data to the controller acording to user timespan selection
        private void sendDataToController(DataUpdateControl pickerType, DateTimePicker dateTimePicker, bool hasClickedCell)
        {
            QueryData paramContainer = null;

            //If the month records checkbox is selected then the month and year is retrieved from the provided dateTimePicker and the QueryData object is created
            if (pickerType == DataUpdateControl.MONTHLY_PICKER)
            {
                //paramContainer = new QueryData.Builder(userID).addMonth(dateTimePicker.Value.Month).addYear(dateTimePicker.Value.Year).build();
                if (hasClickedCell)
                {
                    //string[] selectedPlanDates = getDatesFromSelectedRow(selectedRowIndex, dataGridViewBPManagement);
                    //CHANGE-DGW MANAGEMENT
                    string[] selectedPlanDates = gridViewManager.getDatesFromSelectedRow(selectedRowIndex, START_DATE_COLUMN_INDEX, END_DATE_COLUMN_INDEX);

                    if (selectedPlanDates == null)
                    {
                        return;
                    }

                    paramContainer = new QueryData.Builder(userID).addStartDate(selectedPlanDates[0]).addEndDate(selectedPlanDates[1]).build();
                }
                else
                {
                    //ParamContainer object created when the user has not selected a DataGridView cell(e.g the user just changes the DateTimePicker control value)
                    paramContainer = new QueryData.Builder(userID).addMonth(dateTimePicker.Value.Month).addYear(dateTimePicker.Value.Year).build();
                }
                //If the year record checkbox is selected then only the year is retrieved from the prvided dateTimePicker and the QueryData object is created
            }
            else if (pickerType == DataUpdateControl.YEARLY_PICKER)
            {
                //If a DataGridView cell was clicked  then it means that the start and end dates of the selected budget plan have to be retrieved in order to create the paramContainer object
                if (hasClickedCell)
                {
                    //string[] selectedPlanDates = getDatesFromSelectedRow(selectedRowIndex, dataGridViewBPManagement);
                    //CHANGE-DGW MANAGEMENT
                    string[] selectedPlanDates = gridViewManager.getDatesFromSelectedRow(selectedRowIndex, START_DATE_COLUMN_INDEX, END_DATE_COLUMN_INDEX);

                    if (selectedPlanDates == null)
                    {
                        return;
                    }

                    paramContainer = new QueryData.Builder(userID).addStartDate(selectedPlanDates[0]).addEndDate(selectedPlanDates[1]).build();
                }
                else
                {
                    //ParamContainer object created when the user has not selected a DataGridView cell(e.g the user just changes the DateTimePicker control value)
                    paramContainer = new QueryData.Builder(userID).addYear(dateTimePicker.Value.Year).build();
                }
            }

            QueryType option = getQueryTypeOption(hasClickedCell);

            //If there is no data in the paramContainer or the option is UNDEFINED then the control will return from the method and no data will be sent to the controller
            if (paramContainer == null || option == QueryType.UNDEFINED)
            {
                return;
            }

            controller.requestData(option, paramContainer);
        }