예제 #1
0
        /// <summary>
        /// Called during loading of the form
        /// Adds the available labels to the Selection box.
        /// </summary>
        private void SetLocalDataLabels()
        {
            double             widthInCm;
            PDataLabelTable    DataLabels;
            PDataLabelUseTable DataLabelUse;

            DataRow[] filteredRows;

            DataLabels   = (PDataLabelTable)TDataCache.TMPartner.GetCacheablePartnerTable(TCacheablePartnerTablesEnum.DataLabelList);
            DataLabelUse = (PDataLabelUseTable)TDataCache.TMPartner.GetCacheablePartnerTable(TCacheablePartnerTablesEnum.DataLabelUseList);

            foreach (PDataLabelUseRow UseRow in DataLabelUse.Rows)
            {
                if ((UseRow.Use == "Bank") ||
                    (UseRow.Use == "Church") ||
                    (UseRow.Use == "Family") ||
                    (UseRow.Use == "Organisation") ||
                    (UseRow.Use == "Person") ||
                    (UseRow.Use == "Unit") ||
                    (UseRow.Use == "Venue"))
                {
                    filteredRows = DataLabels.Select(PDataLabelTable.GetKeyDBName() + " = " + UseRow.DataLabelKey.ToString());

                    if (filteredRows.Length > 0)
                    {
                        PDataLabelRow row = (PDataLabelRow)filteredRows[0];

                        if (row.DataType == "char")
                        {
                            widthInCm = TPartnerColumnFunction.CharLengthToCM(row.CharLength);
                        }
                        else if (row.DataType == "partnerkey")
                        {
                            widthInCm = TPartnerColumnFunction.CharLengthToCM(10);
                        }
                        else if (row.DataType == "lookup")
                        {
                            widthInCm = TPartnerColumnFunction.CharLengthToCM(14);
                        }
                        else if (row.DataType == "boolean")
                        {
                            widthInCm = TPartnerColumnFunction.CharLengthToCM(5);
                        }
                        else
                        {
                            widthInCm = TPartnerColumnFunction.CharLengthToCM(10);
                        }

                        /* minimum width of column, so that the caption can be displayed (with a footnote number if necessary) */
                        if (widthInCm < 1.5)
                        {
                            widthInCm = 1.5;
                        }

                        FPetraUtilsObject.AddAvailableFunction(new TPartnerColumnFunction("DataLabelColumn", "param_label", row.Text, widthInCm)); //FPetraUtilsObject.AddAvailableFunction(new TPartnerColumnFunction(row.Text, "param_label",
                                                                                                                                                   // "DataLabelColumn", widthInCm));
                    }
                }
            }
        }
예제 #2
0
        /// create new PM data
        public static PDataLabelTable CreateNewPMData(long AFromPartnerKey, long AToPartnerKey, IndividualDataTDS AMainDS, TDataBase ADataBase = null)
        {
            TDataBase      db          = DBAccess.Connect("CreateNewPMData", ADataBase);
            TDBTransaction Transaction = db.BeginTransaction(IsolationLevel.ReadCommitted);

            // Create a new DataLabel record
            PDataLabelTable AllDataLabelTable = PDataLabelAccess.LoadAll(Transaction);
            PDataLabelTable DataLabelTable    = new PDataLabelTable();
            PDataLabelRow   DataLabelRow      = DataLabelTable.NewRowTyped();

            // Get the first available key, which is our unique primary key field
            Int32 Key = 1;

            while (AllDataLabelTable.Rows.Find(new object[] { Key }) != null)
            {
                Key++;
            }

            DataLabelRow.Key      = Key;
            DataLabelRow.DataType = "char";
            DataLabelTable.Rows.Add(DataLabelRow);

            // Create a new DataLabelValuePartner record
            PDataLabelValuePartnerRow DataLabelValuePartner = AMainDS.PDataLabelValuePartner.NewRowTyped();

            DataLabelValuePartner.PartnerKey   = AFromPartnerKey;
            DataLabelValuePartner.DataLabelKey = DataLabelRow.Key;
            AMainDS.PDataLabelValuePartner.Rows.Add(DataLabelValuePartner);

            // Create a new PassportDetails record
            IndividualDataTDSPmPassportDetailsRow PassportDetails = AMainDS.PmPassportDetails.NewRowTyped();

            PassportDetails.PartnerKey              = AFromPartnerKey;
            PassportDetails.PassportNumber          = "0";
            PassportDetails.PassportNationalityName = "IRELAND";
            AMainDS.PmPassportDetails.Rows.Add(PassportDetails);

            // Create two new PersonalData records
            PmPersonalDataRow FromPersonalData = AMainDS.PmPersonalData.NewRowTyped();

            FromPersonalData.PartnerKey = AFromPartnerKey;
            FromPersonalData.HeightCm   = 175;
            FromPersonalData.WeightKg   = 80;
            AMainDS.PmPersonalData.Rows.Add(FromPersonalData);

            PmPersonalDataRow ToPersonalData = AMainDS.PmPersonalData.NewRowTyped();

            ToPersonalData.PartnerKey = AToPartnerKey;
            ToPersonalData.WeightKg   = 95;
            AMainDS.PmPersonalData.Rows.Add(ToPersonalData);

            Transaction.Rollback();

            return(DataLabelTable);
        }
예제 #3
0
        public TSubmitChangesResult PrepareChangesServerSide(
            DataTable AInspectDT,
            TDBTransaction AReadTransaction)
        {
            TSubmitChangesResult SubmissionResult = TSubmitChangesResult.scrOK;

            // TODO: once we have centrally cached data tables on the server then get the data
            // from there. Until then just load it on the spot here!
            PDataLabelTable DataLabelDT = PDataLabelAccess.LoadAll(AReadTransaction);

            if (AInspectDT != null)
            {
                // Run through all rows of the value table and see if the significant column is empty/null. If so
                // then delete the row from the table (these rows are not needed any longer in order to save space
                // in the database)
                int NumRows = AInspectDT.Rows.Count;

                for (int RowIndex = NumRows - 1; RowIndex >= 0; RowIndex -= 1)
                {
                    DataRow InspectedDataRow = AInspectDT.Rows[RowIndex];

                    // only check modified or added rows because the deleted ones are deleted anyway
                    if ((InspectedDataRow.RowState == DataRowState.Modified) || (InspectedDataRow.RowState == DataRowState.Added))
                    {
                        if (IsRowObsolete(DataLabelDT, InspectedDataRow, (AInspectDT.TableName == PDataLabelValuePartnerTable.GetTableName())))
                        {
                            InspectedDataRow.Delete();
                        }
                    }
                }
            }
            else
            {
                TLogging.LogAtLevel(8, "AInspectDS = null!");
                SubmissionResult = TSubmitChangesResult.scrNothingToBeSaved;
            }

            return(SubmissionResult);
        }
예제 #4
0
        /// create new PM data
        public static PDataLabelTable CreateNewPMData(long AFromPartnerKey, long AToPartnerKey, IndividualDataTDS AMainDS)
        {
            // Create a new DataLabel record
            PDataLabelTable AllDataLabelTable = PDataLabelAccess.LoadAll(DBAccess.GDBAccessObj.Transaction);
            PDataLabelTable DataLabelTable = new PDataLabelTable();
            PDataLabelRow DataLabelRow = DataLabelTable.NewRowTyped();

            // Get the first available key, which is our unique primary key field
            Int32 Key = 1;

            while (AllDataLabelTable.Rows.Find(new object[] { Key }) != null)
            {
                Key++;
            }

            DataLabelRow.Key = Key;
            DataLabelRow.DataType = "char";
            DataLabelTable.Rows.Add(DataLabelRow);

            // Create a new DataLabelValuePartner record
            PDataLabelValuePartnerRow DataLabelValuePartner = AMainDS.PDataLabelValuePartner.NewRowTyped();
            DataLabelValuePartner.PartnerKey = AFromPartnerKey;
            DataLabelValuePartner.DataLabelKey = DataLabelRow.Key;
            AMainDS.PDataLabelValuePartner.Rows.Add(DataLabelValuePartner);

            // Create a new PassportDetails record
            IndividualDataTDSPmPassportDetailsRow PassportDetails = AMainDS.PmPassportDetails.NewRowTyped();
            PassportDetails.PartnerKey = AFromPartnerKey;
            PassportDetails.PassportNumber = "0";
            PassportDetails.PassportNationalityName = "IRELAND";
            AMainDS.PmPassportDetails.Rows.Add(PassportDetails);

            // Create two new PersonalData records
            PmPersonalDataRow FromPersonalData = AMainDS.PmPersonalData.NewRowTyped();
            FromPersonalData.PartnerKey = AFromPartnerKey;
            FromPersonalData.HeightCm = 175;
            FromPersonalData.WeightKg = 80;
            AMainDS.PmPersonalData.Rows.Add(FromPersonalData);

            PmPersonalDataRow ToPersonalData = AMainDS.PmPersonalData.NewRowTyped();
            ToPersonalData.PartnerKey = AToPartnerKey;
            ToPersonalData.WeightKg = 95;
            AMainDS.PmPersonalData.Rows.Add(ToPersonalData);

            return DataLabelTable;
        }
예제 #5
0
        private static bool LoadApplicationsFromDB(
            ref ConferenceApplicationTDS AMainDS,
            string AEventCode,
            Int64?ARegisteringOffice,
            string ARole,
            Int64?APartnerKey,
            TDBTransaction ATransaction)
        {
            ConferenceApplicationTDS MainDS = new ConferenceApplicationTDS();

            List <OdbcParameter> parameters = new List <OdbcParameter>();

            OdbcParameter parameter = new OdbcParameter("eventcode", OdbcType.VarChar, PmShortTermApplicationTable.GetConfirmedOptionCodeLength());

            parameter.Value = AEventCode.Substring(0, 5);
            parameters.Add(parameter);

            string DataLabels = "(PUB_p_data_label.p_text_c = 'MedicalNotes' OR PUB_p_data_label.p_text_c = 'Rebukes')";

            string queryShortTermApplication = "SELECT PUB_pm_short_term_application.* " +
                                               "FROM PUB_pm_short_term_application " +
                                               "WHERE SUBSTRING(PUB_pm_short_term_application.pm_confirmed_option_code_c, 1, 5) = ? ";

            string queryGeneralApplication = "SELECT PUB_pm_general_application.* " +
                                             "FROM PUB_pm_short_term_application, PUB_pm_general_application " +
                                             "WHERE SUBSTRING(PUB_pm_short_term_application.pm_confirmed_option_code_c, 1, 5) = ? " +
                                             "  AND PUB_pm_general_application.p_partner_key_n = PUB_pm_short_term_application.p_partner_key_n " +
                                             "  AND PUB_pm_general_application.pm_application_key_i = PUB_pm_short_term_application.pm_application_key_i "
                                             +
                                             "  AND PUB_pm_general_application.pm_registration_office_n = PUB_pm_short_term_application.pm_registration_office_n";
            string queryPerson = "SELECT DISTINCT PUB_p_person.* " +
                                 "FROM PUB_pm_short_term_application, PUB_p_person " +
                                 "WHERE SUBSTRING(PUB_pm_short_term_application.pm_confirmed_option_code_c, 1, 5) = ? " +
                                 "  AND PUB_p_person.p_partner_key_n = PUB_pm_short_term_application.p_partner_key_n";
            string queryPartner = "SELECT DISTINCT PUB_p_partner.* " +
                                  "FROM PUB_p_partner, PUB_pm_short_term_application " +
                                  "WHERE SUBSTRING(PUB_pm_short_term_application.pm_confirmed_option_code_c, 1, 5) = ? " +
                                  "  AND (PUB_p_partner.p_partner_key_n = PUB_pm_short_term_application.p_partner_key_n" +
                                  " OR PUB_p_partner.p_partner_key_n = PUB_pm_short_term_application.pm_st_field_charged_n)";
            string queryDataLabel = "SELECT DISTINCT PUB_p_data_label_value_partner.* " +
                                    "FROM PUB_pm_short_term_application, PUB_p_data_label_value_partner, PUB_p_data_label " +
                                    "WHERE SUBSTRING(PUB_pm_short_term_application.pm_confirmed_option_code_c, 1, 5) = ? " +
                                    "  AND PUB_p_data_label_value_partner.p_partner_key_n = PUB_pm_short_term_application.p_partner_key_n" +
                                    "  AND PUB_p_data_label_value_partner.p_data_label_key_i = PUB_p_data_label.p_key_i" +
                                    " AND " + DataLabels;

            if ((ARole != null) && (ARole.Length > 0))
            {
                queryGeneralApplication   += "  AND PUB_pm_short_term_application.pm_st_congress_code_c LIKE '" + ARole + "%'";
                queryShortTermApplication += "  AND PUB_pm_short_term_application.pm_st_congress_code_c LIKE '" + ARole + "%'";
                queryPerson    += "  AND PUB_pm_short_term_application.pm_st_congress_code_c LIKE '" + ARole + "%'";
                queryDataLabel += "  AND PUB_pm_short_term_application.pm_st_congress_code_c LIKE '" + ARole + "%'";
            }

            if (ARegisteringOffice.HasValue && (ARegisteringOffice.Value > 0))
            {
                string queryRegistrationOffice =
                    "  AND (PUB_pm_short_term_application.pm_st_field_charged_n = ? OR PUB_pm_short_term_application.pm_registration_office_n = ?)";
                queryGeneralApplication   += queryRegistrationOffice;
                queryShortTermApplication += queryRegistrationOffice;
                queryPerson    += queryRegistrationOffice;
                queryPartner   += "  AND PUB_pm_short_term_application.pm_st_congress_code_c LIKE '" + ARole + "%'";
                queryDataLabel += queryRegistrationOffice;

                parameter       = new OdbcParameter("fieldCharged", OdbcType.Decimal, 10);
                parameter.Value = ARegisteringOffice.Value;
                parameters.Add(parameter);
                parameter       = new OdbcParameter("registrationOffice", OdbcType.Decimal, 10);
                parameter.Value = ARegisteringOffice.Value;
                parameters.Add(parameter);
            }

            if (APartnerKey.HasValue && (APartnerKey.Value > 0))
            {
                queryGeneralApplication   += "  AND PUB_pm_short_term_application.p_partner_key_n = ?";
                queryShortTermApplication += "  AND PUB_pm_short_term_application.p_partner_key_n = ?";
                queryPerson    += "  AND PUB_pm_short_term_application.p_partner_key_n = ?";
                queryPartner   += "  AND PUB_pm_short_term_application.p_partner_key_n = ?";
                queryDataLabel += "  AND PUB_pm_short_term_application.p_partner_key_n = ?";

                parameter       = new OdbcParameter("partnerkey", OdbcType.Decimal, 10);
                parameter.Value = APartnerKey.Value;
                parameters.Add(parameter);
            }

            DBAccess.GDBAccessObj.Select(MainDS,
                                         queryShortTermApplication,
                                         MainDS.PmShortTermApplication.TableName, ATransaction, parameters.ToArray());

            DBAccess.GDBAccessObj.Select(MainDS,
                                         queryPerson,
                                         MainDS.PPerson.TableName, ATransaction, parameters.ToArray());

            DBAccess.GDBAccessObj.Select(MainDS,
                                         queryPartner,
                                         MainDS.PPartner.TableName, ATransaction, parameters.ToArray());

            DBAccess.GDBAccessObj.Select(MainDS,
                                         queryGeneralApplication,
                                         MainDS.PmGeneralApplication.TableName, ATransaction, parameters.ToArray());

            DBAccess.GDBAccessObj.Select(MainDS,
                                         queryDataLabel,
                                         MainDS.PDataLabelValuePartner.TableName, ATransaction, parameters.ToArray());

            DBAccess.GDBAccessObj.Select(MainDS,
                                         "SELECT * FROM PUB_p_data_label WHERE " + DataLabels,
                                         MainDS.PDataLabel.TableName, ATransaction);

            AMainDS.Merge(MainDS);

            AMainDS.PDataLabelValuePartner.DefaultView.Sort = PDataLabelValuePartnerTable.GetDataLabelKeyDBName() + "," +
                                                              PDataLabelValuePartnerTable.GetPartnerKeyDBName();
            AMainDS.PDataLabel.DefaultView.Sort = PDataLabelTable.GetTextDBName();

            return(true);
        }
예제 #6
0
        /// <summary>
        /// return a list of all applicants for a given event,
        /// but if AConferenceOrganisingOffice is false,
        /// consider only the registration office that the user has permissions for, ie. Module REG-00xx0000000
        /// </summary>
        /// <param name="AMainDS"></param>
        /// <param name="AEventPartnerKey">The ConferenceKey</param>
        /// <param name="AEventCode">The OutreachPrefix</param>
        /// <param name="AApplicationStatus"></param>
        /// <param name="ARegistrationOffice">if -1, then show all offices that the user has permission for</param>
        /// <param name="AConferenceOrganisingOffice">if true, all offices are considered</param>
        /// <param name="ARole"></param>
        /// <param name="AClearJSONData"></param>
        /// <returns></returns>
        public static bool GetApplications(
            ref ConferenceApplicationTDS AMainDS,
            Int64 AEventPartnerKey,
            string AEventCode,
            string AApplicationStatus,
            Int64 ARegistrationOffice,
            bool AConferenceOrganisingOffice,
            string ARole,
            bool AClearJSONData)
        {
            TDBTransaction           Transaction = null;
            ConferenceApplicationTDS MainDS      = new ConferenceApplicationTDS();

            DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(
                IsolationLevel.ReadCommitted,
                TEnforceIsolationLevel.eilMinimum,
                ref Transaction,
                delegate
            {
                // load all attendees of this conference.
                // only load once: GetApplications might be called for several application stati
                if (MainDS.PcAttendee.Rows.Count == 0)
                {
                    PcAttendeeRow templateAttendeeRow = MainDS.PcAttendee.NewRowTyped(false);
                    templateAttendeeRow.ConferenceKey = AEventPartnerKey;
                    PcAttendeeAccess.LoadUsingTemplate(MainDS, templateAttendeeRow, Transaction);
                    MainDS.PcAttendee.DefaultView.Sort = PcAttendeeTable.GetPartnerKeyDBName();
                }

                if (AConferenceOrganisingOffice && (ARegistrationOffice == -1))
                {
                    // avoid duplicates, who are registered by one office, but charged to another office
                    GetApplications(ref MainDS, AEventCode, -1, AApplicationStatus, ARole, AClearJSONData, Transaction);
                }
                else
                {
                    List <Int64> AllowedRegistrationOffices = GetRegistrationOfficeKeysOfUser(Transaction);

                    foreach (Int64 RegistrationOffice in AllowedRegistrationOffices)
                    {
                        if ((ARegistrationOffice == RegistrationOffice) || (ARegistrationOffice == -1))
                        {
                            GetApplications(ref MainDS, AEventCode, RegistrationOffice, AApplicationStatus, ARole, AClearJSONData, Transaction);
                        }
                    }
                }

                // required for DefaultView.Find
                MainDS.PmShortTermApplication.DefaultView.Sort =
                    PmShortTermApplicationTable.GetStConfirmedOptionDBName() + "," +
                    PmShortTermApplicationTable.GetPartnerKeyDBName();
                MainDS.PmGeneralApplication.DefaultView.Sort =
                    PmGeneralApplicationTable.GetPartnerKeyDBName() + "," +
                    PmGeneralApplicationTable.GetApplicationKeyDBName() + "," +
                    PmGeneralApplicationTable.GetRegistrationOfficeDBName();
                MainDS.PDataLabelValuePartner.DefaultView.Sort = PDataLabelValuePartnerTable.GetDataLabelKeyDBName() + "," +
                                                                 PDataLabelValuePartnerTable.GetPartnerKeyDBName();
                MainDS.PDataLabel.DefaultView.Sort = PDataLabelTable.GetTextDBName();
            });

            AMainDS = MainDS;

            if (AMainDS.HasChanges())
            {
                AMainDS.EnforceConstraints = false;
                AMainDS.AcceptChanges();
            }

            return(true);
        }
        /// <summary>
        /// Check if a data row is obsolete. It does not need to be saved if there is no
        /// value in it.
        ///
        /// </summary>
        /// <returns>void</returns>
        private Boolean IsRowObsolete(PDataLabelTable ADataLabelTable, DataRow ADataRow, Boolean AIsPartnerTable)
        {
            Boolean ReturnValue;
            PDataLabelValuePartnerRow DataLabelValuePartnerRow;
            PDataLabelValueApplicationRow DataLabelValueApplicationRow;
            PDataLabelRow DataLabelRow;

            // initialize Result and variables
            ReturnValue = false;
            DataLabelValuePartnerRow = null;
            DataLabelValueApplicationRow = null;

            if (AIsPartnerTable)
            {
                DataLabelValuePartnerRow = (PDataLabelValuePartnerRow)ADataRow;
                DataLabelRow = (PDataLabelRow)ADataLabelTable.Rows.Find(DataLabelValuePartnerRow.DataLabelKey);
            }
            else
            {
                DataLabelValueApplicationRow = (PDataLabelValueApplicationRow)ADataRow;
                DataLabelRow = (PDataLabelRow)ADataLabelTable.Rows.Find(DataLabelValueApplicationRow.DataLabelKey);
            }

            if (DataLabelRow.DataType == Ict.Petra.Shared.MCommon.MCommonConstants.OFFICESPECIFIC_DATATYPE_CHAR)
            {
                if (DataLabelValuePartnerRow != null)
                {
                    if (DataLabelValuePartnerRow.IsValueCharNull())
                    {
                        ReturnValue = true;
                    }
                }
                else if (DataLabelValueApplicationRow != null)
                {
                    if (DataLabelValueApplicationRow.IsValueCharNull())
                    {
                        ReturnValue = true;
                    }
                }
            }
            else if (DataLabelRow.DataType == Ict.Petra.Shared.MCommon.MCommonConstants.OFFICESPECIFIC_DATATYPE_FLOAT)
            {
                if (DataLabelValuePartnerRow != null)
                {
                    if (DataLabelValuePartnerRow.IsValueNumNull())
                    {
                        ReturnValue = true;
                    }
                }
                else if (DataLabelValueApplicationRow != null)
                {
                    if (DataLabelValueApplicationRow.IsValueNumNull())
                    {
                        ReturnValue = true;
                    }
                }
            }
            else if (DataLabelRow.DataType == Ict.Petra.Shared.MCommon.MCommonConstants.OFFICESPECIFIC_DATATYPE_DATE)
            {
                if (DataLabelValuePartnerRow != null)
                {
                    if (DataLabelValuePartnerRow.IsValueDateNull())
                    {
                        ReturnValue = true;
                    }
                }
                else if (DataLabelValueApplicationRow != null)
                {
                    if (DataLabelValueApplicationRow.IsValueDateNull())
                    {
                        ReturnValue = true;
                    }
                }
            }
            else if (DataLabelRow.DataType == Ict.Petra.Shared.MCommon.MCommonConstants.OFFICESPECIFIC_DATATYPE_INTEGER)
            {
                if (DataLabelValuePartnerRow != null)
                {
                    if (DataLabelValuePartnerRow.IsValueIntNull())
                    {
                        ReturnValue = true;
                    }
                }
                else if (DataLabelValueApplicationRow != null)
                {
                    if (DataLabelValueApplicationRow.IsValueIntNull())
                    {
                        ReturnValue = true;
                    }
                }
            }
            else if (DataLabelRow.DataType == Ict.Petra.Shared.MCommon.MCommonConstants.OFFICESPECIFIC_DATATYPE_CURRENCY)
            {
                if (DataLabelValuePartnerRow != null)
                {
                    if (DataLabelValuePartnerRow.IsValueCurrencyNull())
                    {
                        ReturnValue = true;
                    }
                }
                else if (DataLabelValueApplicationRow != null)
                {
                    if (DataLabelValueApplicationRow.IsValueCurrencyNull())
                    {
                        ReturnValue = true;
                    }
                }
            }
            else if (DataLabelRow.DataType == Ict.Petra.Shared.MCommon.MCommonConstants.OFFICESPECIFIC_DATATYPE_BOOLEAN)
            {
                if (DataLabelValuePartnerRow != null)
                {
                    if (DataLabelValuePartnerRow.IsValueBoolNull())
                    {
                        ReturnValue = true;
                    }
                }
                else if (DataLabelValueApplicationRow != null)
                {
                    if (DataLabelValueApplicationRow.IsValueBoolNull())
                    {
                        ReturnValue = true;
                    }
                }
            }
            else if (DataLabelRow.DataType == Ict.Petra.Shared.MCommon.MCommonConstants.OFFICESPECIFIC_DATATYPE_PARTNERKEY)
            {
                if (DataLabelValuePartnerRow != null)
                {
                    // do not only check for nil but also check if the partner key is 0
                    // in which case the row is obsolete as well
                    if ((DataLabelValuePartnerRow.IsValuePartnerKeyNull()) || (DataLabelValuePartnerRow.ValuePartnerKey == 0))
                    {
                        ReturnValue = true;
                    }
                }
                else if (DataLabelValueApplicationRow != null)
                {
                    // do not only check for nil but also check if the partner key is 0
                    // in which case the row is obsolete as well
                    if ((DataLabelValueApplicationRow.IsValuePartnerKeyNull()) || (DataLabelValueApplicationRow.ValuePartnerKey == 0))
                    {
                        ReturnValue = true;
                    }
                }
            }
            else if (DataLabelRow.DataType == Ict.Petra.Shared.MCommon.MCommonConstants.OFFICESPECIFIC_DATATYPE_LOOKUP)
            {
                if (DataLabelValuePartnerRow != null)
                {
                    if (DataLabelValuePartnerRow.IsValueLookupNull())
                    {
                        ReturnValue = true;
                    }
                }
                else if (DataLabelValueApplicationRow != null)
                {
                    if (DataLabelValueApplicationRow.IsValueLookupNull())
                    {
                        ReturnValue = true;
                    }
                }
            }

            return ReturnValue;
        }
예제 #8
0
        /// <summary>
        /// Check if a data row is obsolete. It does not need to be saved if there is no
        /// value in it.
        ///
        /// </summary>
        /// <returns>void</returns>
        private Boolean IsRowObsolete(PDataLabelTable ADataLabelTable, DataRow ADataRow, Boolean AIsPartnerTable)
        {
            Boolean ReturnValue;
            PDataLabelValuePartnerRow     DataLabelValuePartnerRow;
            PDataLabelValueApplicationRow DataLabelValueApplicationRow;
            PDataLabelRow DataLabelRow;

            // initialize Result and variables
            ReturnValue = false;
            DataLabelValuePartnerRow     = null;
            DataLabelValueApplicationRow = null;

            if (AIsPartnerTable)
            {
                DataLabelValuePartnerRow = (PDataLabelValuePartnerRow)ADataRow;
                DataLabelRow             = (PDataLabelRow)ADataLabelTable.Rows.Find(DataLabelValuePartnerRow.DataLabelKey);
            }
            else
            {
                DataLabelValueApplicationRow = (PDataLabelValueApplicationRow)ADataRow;
                DataLabelRow = (PDataLabelRow)ADataLabelTable.Rows.Find(DataLabelValueApplicationRow.DataLabelKey);
            }

            if (DataLabelRow.DataType == Ict.Petra.Shared.MCommon.MCommonConstants.OFFICESPECIFIC_DATATYPE_CHAR)
            {
                if (DataLabelValuePartnerRow != null)
                {
                    if (DataLabelValuePartnerRow.IsValueCharNull())
                    {
                        ReturnValue = true;
                    }
                }
                else if (DataLabelValueApplicationRow != null)
                {
                    if (DataLabelValueApplicationRow.IsValueCharNull())
                    {
                        ReturnValue = true;
                    }
                }
            }
            else if (DataLabelRow.DataType == Ict.Petra.Shared.MCommon.MCommonConstants.OFFICESPECIFIC_DATATYPE_FLOAT)
            {
                if (DataLabelValuePartnerRow != null)
                {
                    if (DataLabelValuePartnerRow.IsValueNumNull())
                    {
                        ReturnValue = true;
                    }
                }
                else if (DataLabelValueApplicationRow != null)
                {
                    if (DataLabelValueApplicationRow.IsValueNumNull())
                    {
                        ReturnValue = true;
                    }
                }
            }
            else if (DataLabelRow.DataType == Ict.Petra.Shared.MCommon.MCommonConstants.OFFICESPECIFIC_DATATYPE_DATE)
            {
                if (DataLabelValuePartnerRow != null)
                {
                    if (DataLabelValuePartnerRow.IsValueDateNull())
                    {
                        ReturnValue = true;
                    }
                }
                else if (DataLabelValueApplicationRow != null)
                {
                    if (DataLabelValueApplicationRow.IsValueDateNull())
                    {
                        ReturnValue = true;
                    }
                }
            }
            else if (DataLabelRow.DataType == Ict.Petra.Shared.MCommon.MCommonConstants.OFFICESPECIFIC_DATATYPE_INTEGER)
            {
                if (DataLabelValuePartnerRow != null)
                {
                    if (DataLabelValuePartnerRow.IsValueIntNull())
                    {
                        ReturnValue = true;
                    }
                }
                else if (DataLabelValueApplicationRow != null)
                {
                    if (DataLabelValueApplicationRow.IsValueIntNull())
                    {
                        ReturnValue = true;
                    }
                }
            }
            else if (DataLabelRow.DataType == Ict.Petra.Shared.MCommon.MCommonConstants.OFFICESPECIFIC_DATATYPE_CURRENCY)
            {
                if (DataLabelValuePartnerRow != null)
                {
                    if (DataLabelValuePartnerRow.IsValueCurrencyNull())
                    {
                        ReturnValue = true;
                    }
                }
                else if (DataLabelValueApplicationRow != null)
                {
                    if (DataLabelValueApplicationRow.IsValueCurrencyNull())
                    {
                        ReturnValue = true;
                    }
                }
            }
            else if (DataLabelRow.DataType == Ict.Petra.Shared.MCommon.MCommonConstants.OFFICESPECIFIC_DATATYPE_BOOLEAN)
            {
                if (DataLabelValuePartnerRow != null)
                {
                    if (DataLabelValuePartnerRow.IsValueBoolNull())
                    {
                        ReturnValue = true;
                    }
                }
                else if (DataLabelValueApplicationRow != null)
                {
                    if (DataLabelValueApplicationRow.IsValueBoolNull())
                    {
                        ReturnValue = true;
                    }
                }
            }
            else if (DataLabelRow.DataType == Ict.Petra.Shared.MCommon.MCommonConstants.OFFICESPECIFIC_DATATYPE_PARTNERKEY)
            {
                if (DataLabelValuePartnerRow != null)
                {
                    // do not only check for nil but also check if the partner key is 0
                    // in which case the row is obsolete as well
                    if ((DataLabelValuePartnerRow.IsValuePartnerKeyNull()) || (DataLabelValuePartnerRow.ValuePartnerKey == 0))
                    {
                        ReturnValue = true;
                    }
                }
                else if (DataLabelValueApplicationRow != null)
                {
                    // do not only check for nil but also check if the partner key is 0
                    // in which case the row is obsolete as well
                    if ((DataLabelValueApplicationRow.IsValuePartnerKeyNull()) || (DataLabelValueApplicationRow.ValuePartnerKey == 0))
                    {
                        ReturnValue = true;
                    }
                }
            }
            else if (DataLabelRow.DataType == Ict.Petra.Shared.MCommon.MCommonConstants.OFFICESPECIFIC_DATATYPE_LOOKUP)
            {
                if (DataLabelValuePartnerRow != null)
                {
                    if (DataLabelValuePartnerRow.IsValueLookupNull())
                    {
                        ReturnValue = true;
                    }
                }
                else if (DataLabelValueApplicationRow != null)
                {
                    if (DataLabelValueApplicationRow.IsValueLookupNull())
                    {
                        ReturnValue = true;
                    }
                }
            }

            return(ReturnValue);
        }
        /// <summary>
        /// Initialises DataSets and Tables
        ///
        /// </summary>
        /// <returns>void</returns>
        private void InitialiseDataStructures(PDataLabelValuePartnerTable ADataTableValuePartner,
            PDataLabelValueApplicationTable ADataTableValueApplication)
        {
            FDataLabelDT = (PDataLabelTable)TDataCache.TMPartner.GetCacheablePartnerTable(TCacheablePartnerTablesEnum.DataLabelList);

            // FDataLabelDT.Tablename := 'PDataLabel';
            // MessageBox.Show('FDataLabelDT.Rows[0].Key: ' + FDataLabelDT.Row[0].Key.ToString);
            FDataLabelUseDT = (PDataLabelUseTable)TDataCache.TMPartner.GetCacheablePartnerTable(TCacheablePartnerTablesEnum.DataLabelUseList);

            // MessageBox.Show('FDataLabelUseDT.Rows[0].Key: ' + FDataLabelUseDT.Row[0].Idx1.ToString);
            FDataLabelLookupDT = (PDataLabelLookupTable)TDataCache.TMPartner.GetCacheablePartnerTable(TCacheablePartnerTablesEnum.DataLabelLookupList);

            // MessageBox.Show('FDataLabelLookupDT.Row[0].CategoryCode: ' + FDataLabelLookupDT.Row[0].CategoryCode);
            FDataLabelLookupCategoryDT = (PDataLabelLookupCategoryTable)TDataCache.TMPartner.GetCacheablePartnerTable(
                TCacheablePartnerTablesEnum.DataLabelLookupCategoryList);

            // MessageBox.Show('FDataLabelLookupCategoryDT.Row[0].CategoryCode: ' + FDataLabelLookupCategoryDT.Row[0].CategoryCode);
            // Set up DataSet that holds all DataTables
            FLocalDataDS = new OfficeSpecificDataLabelsTDS("OfficeSpecificData");

            // Merge in cached Typed DataTables (should be done differently in the future when TypedDataSet.Tables.Add works fine)
            FLocalDataDS.Merge(FDataLabelDT);
            FLocalDataDS.Merge(FDataLabelUseDT);
            FLocalDataDS.Merge(FDataLabelLookupDT);
            FLocalDataDS.Merge(FDataLabelLookupCategoryDT);
            FDataLabelValuePartnerDT = ADataTableValuePartner;
            FDataLabelValueApplicationDT = ADataTableValueApplication;
        }