示例#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);
            }
        }
示例#2
0
        //The method that activates the delete button when a cell from the dataGridView is clicked
        //ADD METHOD FOR BUDGET PLAN DETAILS GRID VIEW FILLING
        private void dataGridViewBPManagement_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            //selectedRowIndex = dataGridViewBPManagement.CurrentCell.RowIndex; //Gets the index of the selected cell's parent row
            deleteButtonBPManagement.Enabled = true;

            DataUpdateControl pickerType = getDateTimePickerType(dateTimePickerBPManagement);

            bool hasClickedCell = true;

            sendDataToController(pickerType, dateTimePickerBPManagement, hasClickedCell);
        }
示例#3
0
        private void dateTimePickerBPManagement_ValueChanged(object sender, EventArgs e)
        {
            DataUpdateControl pickerType = getDateTimePickerType(dateTimePickerBPManagement);

            //If the returned value is UNDEFINED it means that something went wrong and the control returns from the method meaning and as a result no data is sent to the controller
            if (pickerType == DataUpdateControl.UNDEFINED)
            {
                return;
            }

            bool hasClickedCell = false;

            sendDataToController(pickerType, dateTimePickerBPManagement, hasClickedCell);
        }
示例#4
0
        //UTIL METHODS
        private DataUpdateControl getDateTimePickerType(DateTimePicker dateTimePicker)
        {
            //Sets the default value for the picker type
            DataUpdateControl pickerType = DataUpdateControl.UNDEFINED;

            if ("MM/yyyy".Equals(dateTimePicker.CustomFormat))
            {
                pickerType = DataUpdateControl.MONTHLY_PICKER;
            }
            else if ("yyyy".Equals(dateTimePicker.CustomFormat))
            {
                pickerType = DataUpdateControl.YEARLY_PICKER;
            }

            return(pickerType);
        }
示例#5
0
        private void tableSelectionComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            //Creating the object that will hold the DateTimePicker selector type
            DataUpdateControl pickerType = 0;

            //If the checkbox for getting data for a single month is selected then the previously created object is assigned the MONTHLY_PICKER value
            //else it is assigned the YEARLY_PICKER value
            if (monthRecordsCheckBox.Checked == true)
            {
                pickerType = DataUpdateControl.MONTHLY_PICKER;
            }
            else if (yearRecordsCheckBox.Checked == true)
            {
                pickerType = DataUpdateControl.YEARLY_PICKER;
            }

            //Sending data to the specialized method for communicating with the controller
            sendDataToController(pickerType, tableSelectionComboBox, dateTimePickerTimeSpanSelection);
        }
示例#6
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);
        }
示例#7
0
 private void InitMapUpdateControl()
 {
     _dataUpdateControl = new DataUpdateControl();
     tabPage4.Controls.Add(_dataUpdateControl);
     _dataUpdateControl.Dock = DockStyle.Fill;
 }
示例#8
0
        private void sendDataToController(DataUpdateControl updateControl, CheckBox checkBox, DateTimePicker startPicker, DateTimePicker endPicker)
        {
            //Checking the control type whose state was modified
            if (updateControl == DataUpdateControl.START_PICKER)
            {
                String tableName = getSelectedTableName(savingAccountComboBox);
                //If the interval checkbox is selected it means that multiple months data is being requested from the DB
                if (checkBox.Checked == true)
                {
                    //Selecting the multiple months option
                    QueryType option = QueryType.MULTIPLE_MONTHS;

                    //Retrieving the start and end date in the format used by the MySqL database
                    String startDate = getDateStringInSQLFormat(startPicker, DateType.START_DATE);
                    String endDate   = getDateStringInSQLFormat(endPicker, DateType.END_DATE);

                    //Configures the object that is used to store the parameter values for the SQL query and sends it to the controller alongside the type of the query that will be executed
                    QueryData paramContainer = new QueryData.Builder(userID).addStartDate(startDate).addEndDate(endDate).addTableName(tableName).build();

                    controller.requestData(option, paramContainer);
                }
                else
                {
                    //Otherwise single month data is selected
                    QueryType option = QueryType.SINGLE_MONTH;

                    //Retrieving the month and year values
                    int month = startPicker.Value.Month;
                    int year  = startPicker.Value.Year;

                    //Configures the object that is used to store the parameter values for the SQL query and sends it to the controller alongside the type of the query that will be executed
                    QueryData paramContainer = new QueryData.Builder(userID).addMonth(month).addYear(year).addTableName(tableName).build();

                    controller.requestData(option, paramContainer);
                }
            }
            else if (updateControl == DataUpdateControl.END_PICKER)
            {
                String tableName = getSelectedTableName(savingAccountComboBox);
                //Selecting multiple months data if the control whose state was modified is the DateTimePicker used to set the end month
                QueryType option = QueryType.MULTIPLE_MONTHS;

                String startDate = getDateStringInSQLFormat(startPicker, DateType.START_DATE);
                String endDate   = getDateStringInSQLFormat(endPicker, DateType.END_DATE);

                QueryData paramContainer = new QueryData.Builder(userID).addStartDate(startDate).addEndDate(endDate).addTableName(tableName).build(); //CHANGE
                controller.requestData(option, paramContainer);
            }
            else if (updateControl == DataUpdateControl.YEARLY_PICKER)
            {
                //Selecting the query type option that will sum the selected element values for each month of the selected year.
                QueryType option = QueryType.MONTHLY_TOTALS;

                //Just like before the month and year values are retrieved
                int month = startPicker.Value.Month;
                int year  = startPicker.Value.Year;

                //Creating the QueryData object and sending the data to the controller
                QueryData paramContainer = new QueryData.Builder(userID).addMonth(month).addYear(year).build(); //CHANGE
                controller.requestData(option, paramContainer);
            }
            else if (updateControl == DataUpdateControl.REFRESH_BUTTON)
            {
                //Current account balance is calculated based on multiple months data
                QueryType option = QueryType.TOTAL_VALUE;

                //Only the userID is needed since the current saving account balance calculation is always made from the first existing balance record to the record of the current month
                QueryData paramContainer = new QueryData.Builder(userID).build();

                controller.requestData(option, paramContainer);
            }
        }