// sets ARow.Type and ARow.Applicable when Early/Late radio buttons are changed
        private void UpdateRegistrationType(object sender, EventArgs e)
        {
            PcEarlyLateRow ARow = GetSelectedDetailRow();

            // does nothing if the check box is only changed because a new row is selected
            if (rbtEarly.Checked && !ARow.Type)
            {
                ARow.Type = true;

                // update ARow.Applicable if it allowed to be changed
                if (dtpDetailApplicable.Enabled)
                {
                    ARow.Applicable = GetLatestAvailableEarlyDate(ARow);
                    SelectRowInGrid(GetDataTableRowIndexByPrimaryKeys(ARow.Applicable));    // keep the current row highlighted
                }
            }
            // does nothing if the check box is only changed because a new row is selected
            else if (rbtLate.Checked && ARow.Type)
            {
                ARow.Type = false;

                // update ARow.Applicable if it allowed to be changed
                if (dtpDetailApplicable.Enabled)
                {
                    ARow.Applicable = GetEarliestAvailableLateDate(ARow);
                    SelectRowInGrid(GetDataTableRowIndexByPrimaryKeys(ARow.Applicable));    // keep the current row highlighted
                }
            }
        }
        private void NewRowManual(ref PcEarlyLateRow ARow)
        {
            // set the conference key
            ARow.ConferenceKey = FPartnerKey;

            ARow.Applicable = GetLatestAvailableEarlyDate(ARow);
        }
        private void NewRowManual(ref PcEarlyLateRow ARow)
        {
            // set the conference key
            ARow.ConferenceKey = FPartnerKey;

            ARow.Applicable = GetLatestAvailableEarlyDate(ARow);
        }
        // check the correct radio buttons and set the correct text box to read only on screen load and record change
        private void ShowDetailsManual(PcEarlyLateRow ARow)
        {
            // only run if screen in not empty
            if (ARow != null)
            {
                if (ARow.Type == true)
                {
                    rbtEarly.Checked = true;
                }
                else
                {
                    rbtLate.Checked = true;
                }

                if (ARow.AmountPercent == true)
                {
                    rbtAmount.Checked         = true;
                    txtDetailPercent.ReadOnly = true;
                }
                else
                {
                    rbtPercent.Checked       = true;
                    txtDetailAmount.ReadOnly = true;
                }
            }
        }
        private void ValidateDataDetailsManual(PcEarlyLateRow ARow)
        {
            // this is used to compare with the row that is being validated
            DataRowCollection GridData = FMainDS.PcEarlyLate.Rows;

            TVerificationResultCollection VerificationResultCollection = FPetraUtilsObject.VerificationResultCollection;

            TSharedConferenceValidation_Conference.ValidateEarlyLateRegistration(this, ARow, ref VerificationResultCollection,
                                                                                 FPetraUtilsObject.ValidationControlsDict, GridData, FEndDate);
        }
        // sets ARow.Percent and changes which text box is readonly when Amount/Percent radio buttons are changed
        private void UpdateAmountPercent(object sender, EventArgs e)
        {
            PcEarlyLateRow ARow = (PcEarlyLateRow)FMainDS.PcEarlyLate.Rows.Find(new object[] { FPartnerKey, dtpDetailApplicable.Date });

            if (rbtAmount.Checked)
            {
                ARow.AmountPercent = true;

                txtDetailAmount.ReadOnly  = false;
                txtDetailPercent.ReadOnly = true;
            }
            else
            {
                ARow.AmountPercent = false;

                txtDetailAmount.ReadOnly  = true;
                txtDetailPercent.ReadOnly = false;
            }
        }
        // return the grid index for the current row being worked on
        private int GetDataTableRowIndexByPrimaryKeys(DateTime AApplicable)
        {
            int RowPos = 0;

            foreach (DataRowView rowView in FMainDS.PcEarlyLate.DefaultView)
            {
                PcEarlyLateRow Row = (PcEarlyLateRow)rowView.Row;

                if ((Row.ConferenceKey == FPartnerKey) && (Row.Applicable == AApplicable))
                {
                    break;
                }

                RowPos++;
            }

            //remember grid is out of sync with DataView by 1 because of grid header rows
            return(RowPos + 1);
        }
        private DateTime GetLatestAvailableEarlyDate(PcEarlyLateRow ARow)
        {
            DateTime ApplicableDate = FStartDate.AddDays(-1);

            if (FMainDS.PcEarlyLate.Count >= 1)
            {
                DateTime          EarliestDate = ApplicableDate;
                DataRowCollection AllRecords   = FMainDS.PcEarlyLate.Rows;
                int i = 0;

                // find the earliest late registration date for conference
                while (i < AllRecords.Count)
                {
                    if ((((PcEarlyLateRow)AllRecords[i]).RowState != DataRowState.Deleted) &&
                        (((PcEarlyLateRow)AllRecords[i]).Type == false) && (((PcEarlyLateRow)AllRecords[i]).Applicable < EarliestDate))
                    {
                        EarliestDate = ((PcEarlyLateRow)AllRecords[i]).Applicable;
                    }

                    i++;
                }

                // if the earliest late registration date is already the row's current date then nothing needs changed
                if (EarliestDate == ARow.Applicable)
                {
                    return(ApplicableDate);
                }

                // find the first free date before the earliest late registration date
                while (FMainDS.PcEarlyLate.Rows.Find(new object[] { FPartnerKey, EarliestDate }) != null)
                {
                    EarliestDate = EarliestDate.AddDays(-1);
                }

                ApplicableDate = EarliestDate;
            }

            return(ApplicableDate);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Validates the MConference Standard Cost Setup screen data.
        /// </summary>
        /// <param name="AContext">Context that describes where the data validation failed.</param>
        /// <param name="ARow">The <see cref="DataRow" /> which holds the the data against which the validation is run.</param>
        /// <param name="AVerificationResultCollection">Will be filled with any <see cref="TVerificationResult" /> items if
        /// data validation errors occur.</param>
        /// <param name="AGridData">Contains all rows that are included in the grid</param>
        /// <param name="AEndDate">The End date for the selected conference</param>
        public static void ValidateEarlyLateRegistration(object AContext, PcEarlyLateRow ARow,
                                                         ref TVerificationResultCollection AVerificationResultCollection,
                                                         DataRowCollection AGridData, DateTime AEndDate)
        {
            TScreenVerificationResult VerificationResult = null;
            DataColumn ValidationColumn;

            // Don't validate deleted DataRows
            if (ARow.RowState == DataRowState.Deleted)
            {
                return;
            }

            if (ARow.Applicable > AEndDate)
            {
                ValidationColumn = ARow.Table.Columns[PcEarlyLateTable.ColumnApplicableId];

                // displays an error message
                VerificationResult = new TScreenVerificationResult(new TVerificationResult(AContext, ErrorCodes.GetErrorInfo(
                                                                                               PetraErrorCodes.ERR_APPLICABLE_DATE_AFTER_CONFERENCE_END_DATE)),
                                                                   ValidationColumn);

                // Handle addition to/removal from TVerificationResultCollection
                AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult);
            }

            // Check the row being validated is consistent with the rest of the data in the table
            PcEarlyLateRow ARowCompare            = null;
            Boolean        ApplicableDateTooEarly = false;
            Boolean        ApplicableDateTooLate  = false;
            int            i = 0;

            while (i < AGridData.Count)
            {
                ARowCompare = (PcEarlyLateRow)AGridData[i];

                if ((ARowCompare.RowState != DataRowState.Deleted) && (ARowCompare.Type == true) &&
                    (ARow.Type == false) && (ARowCompare.Applicable > ARow.Applicable))
                {
                    ApplicableDateTooEarly = true;
                    break;
                }
                else if ((ARowCompare.RowState != DataRowState.Deleted) && (ARowCompare.Type == false) &&
                         (ARow.Type == true) && (ARowCompare.Applicable < ARow.Applicable))
                {
                    ApplicableDateTooLate = true;
                    break;
                }

                i++;
            }

            // if an inconsistency is found
            if (ApplicableDateTooEarly == true)
            {
                ValidationColumn = ARow.Table.Columns[PcEarlyLateTable.ColumnApplicableId];

                // displays a warning message (non-critical error)
                VerificationResult = new TScreenVerificationResult(new TVerificationResult(AContext, ErrorCodes.GetErrorInfo(
                                                                                               PetraErrorCodes.ERR_EARLY_APPLICABLE_DATE_LATER_THAN_LATE_APPLICABLE_DATE)),
                                                                   ValidationColumn);

                // Handle addition to/removal from TVerificationResultCollection
                AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult);
            }
            else if (ApplicableDateTooLate == true)
            {
                ValidationColumn = ARow.Table.Columns[PcEarlyLateTable.ColumnApplicableId];

                // displays a warning message (non-critical error)
                VerificationResult = new TScreenVerificationResult(new TVerificationResult(AContext, ErrorCodes.GetErrorInfo(
                                                                                               PetraErrorCodes.ERR_LATE_APPLICABLE_DATE_EARLIER_THAN_EARLY_APPLICABLE_DATE)),
                                                                   ValidationColumn);

                // Handle addition to/removal from TVerificationResultCollection
                AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult);
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Validates the MConference Standard Cost Setup screen data.
        /// </summary>
        /// <param name="AContext">Context that describes where the data validation failed.</param>
        /// <param name="ARow">The <see cref="DataRow" /> which holds the the data against which the validation is run.</param>
        /// <param name="AVerificationResultCollection">Will be filled with any <see cref="TVerificationResult" /> items if
        /// data validation errors occur.</param>
        /// <param name="AValidationControlsDict">A <see cref="TValidationControlsDict" /> containing the Controls that
        /// display data that is about to be validated.</param>
        /// <param name="AGridData">A <see cref="TValidationControlsDict" />Contains all rows that are included in the grid</param>
        /// <param name="AEndDate">The End date for the selected conference</param>
        public static void ValidateEarlyLateRegistration(object AContext, PcEarlyLateRow ARow,
            ref TVerificationResultCollection AVerificationResultCollection, TValidationControlsDict AValidationControlsDict,
            DataRowCollection AGridData, DateTime AEndDate)
        {
            TValidationControlsData ValidationControlsData;
            TScreenVerificationResult VerificationResult = null;
            DataColumn ValidationColumn;

            // Don't validate deleted DataRows
            if (ARow.RowState == DataRowState.Deleted)
            {
                return;
            }

            if (ARow.Applicable > AEndDate)
            {
                ValidationColumn = ARow.Table.Columns[PcEarlyLateTable.ColumnApplicableId];

                // displays an error message
                VerificationResult = new TScreenVerificationResult(new TVerificationResult(AContext, ErrorCodes.GetErrorInfo(
                            PetraErrorCodes.ERR_APPLICABLE_DATE_AFTER_CONFERENCE_END_DATE)),
                    ValidationColumn, ValidationControlsData.ValidationControl);

                // Handle addition to/removal from TVerificationResultCollection
                AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn);
            }

            // Check the row being validated is consistent with the rest of the data in the table
            PcEarlyLateRow ARowCompare = null;
            Boolean ApplicableDateTooEarly = false;
            Boolean ApplicableDateTooLate = false;
            int i = 0;

            while (i < AGridData.Count)
            {
                ARowCompare = (PcEarlyLateRow)AGridData[i];

                if ((ARowCompare.RowState != DataRowState.Deleted) && (ARowCompare.Type == true)
                    && (ARow.Type == false) && (ARowCompare.Applicable > ARow.Applicable))
                {
                    ApplicableDateTooEarly = true;
                    break;
                }
                else if ((ARowCompare.RowState != DataRowState.Deleted) && (ARowCompare.Type == false)
                         && (ARow.Type == true) && (ARowCompare.Applicable < ARow.Applicable))
                {
                    ApplicableDateTooLate = true;
                    break;
                }

                i++;
            }

            // if an inconsistency is found
            if (ApplicableDateTooEarly == true)
            {
                ValidationColumn = ARow.Table.Columns[PcEarlyLateTable.ColumnApplicableId];

                // displays a warning message (non-critical error)
                VerificationResult = new TScreenVerificationResult(new TVerificationResult(AContext, ErrorCodes.GetErrorInfo(
                            PetraErrorCodes.ERR_EARLY_APPLICABLE_DATE_LATER_THAN_LATE_APPLICABLE_DATE)),
                    ValidationColumn, ValidationControlsData.ValidationControl);

                // Handle addition to/removal from TVerificationResultCollection
                AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn);
            }
            else if (ApplicableDateTooLate == true)
            {
                ValidationColumn = ARow.Table.Columns[PcEarlyLateTable.ColumnApplicableId];

                // displays a warning message (non-critical error)
                VerificationResult = new TScreenVerificationResult(new TVerificationResult(AContext, ErrorCodes.GetErrorInfo(
                            PetraErrorCodes.ERR_LATE_APPLICABLE_DATE_EARLIER_THAN_EARLY_APPLICABLE_DATE)),
                    ValidationColumn, ValidationControlsData.ValidationControl);

                // Handle addition to/removal from TVerificationResultCollection
                AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn);
            }
        }
        private void ValidateDataDetailsManual(PcEarlyLateRow ARow)
        {
            // this is used to compare with the row that is being validated
            DataRowCollection GridData = FMainDS.PcEarlyLate.Rows;

            TVerificationResultCollection VerificationResultCollection = FPetraUtilsObject.VerificationResultCollection;

            TSharedConferenceValidation_Conference.ValidateEarlyLateRegistration(this, ARow, ref VerificationResultCollection,
                FPetraUtilsObject.ValidationControlsDict, GridData, FEndDate);
        }
        // check the correct radio buttons and set the correct text box to read only on screen load and record change
        private void ShowDetailsManual(PcEarlyLateRow ARow)
        {
            // only run if screen in not empty
            if (ARow != null)
            {
                if (ARow.Type == true)
                {
                    rbtEarly.Checked = true;
                }
                else
                {
                    rbtLate.Checked = true;
                }

                if (ARow.AmountPercent == true)
                {
                    rbtAmount.Checked = true;
                    txtDetailPercent.ReadOnly = true;
                }
                else
                {
                    rbtPercent.Checked = true;
                    txtDetailAmount.ReadOnly = true;
                }
            }
        }
        private DateTime GetEarliestAvailableLateDate(PcEarlyLateRow ARow)
        {
            DateTime ApplicableDate = FStartDate.AddDays(-1);

            DateTime LatestDate = ApplicableDate;
            DataRowCollection AllRecords = FMainDS.PcEarlyLate.Rows;
            int i = 0;

            // find the latest early registration date for conference
            while (i < AllRecords.Count)
            {
                if ((((PcEarlyLateRow)AllRecords[i]).RowState != DataRowState.Deleted) && (((PcEarlyLateRow)AllRecords[i]).Type == true)
                    && ((((PcEarlyLateRow)AllRecords[i]).Applicable > LatestDate) || (LatestDate == ApplicableDate)))
                {
                    LatestDate = ((PcEarlyLateRow)AllRecords[i]).Applicable;
                }

                i++;
            }

            // if the latest early registration date is already the row's current date then nothing needs changed
            if (LatestDate == ARow.Applicable)
            {
                return ApplicableDate;
            }

            // find the first free date after the latest early registration date
            while (FMainDS.PcEarlyLate.Rows.Find(new object[] { FPartnerKey, LatestDate }) != null)
            {
                LatestDate = LatestDate.AddDays(1);
            }

            ApplicableDate = LatestDate;

            return ApplicableDate;
        }