/// <summary>
        /// Retrieves the gender and age of one person.
        /// </summary>
        /// <param name="APartnerKey">Partner key of the person to examine</param>
        /// <param name="AStartDate">Start date of the conference. The age is calculated at the start date</param>
        /// <param name="AGender">Gender of the current person</param>
        /// <param name="AAge">Age of the current person</param>
        /// <param name="ASituation">The current report situation</param>
        /// <returns></returns>
        private bool GetGenderAndAge(long APartnerKey, DateTime AStartDate, out char AGender, out int AAge,
                                     ref TRptSituation ASituation)
        {
            bool ReturnValue = false;

            AGender = ' ';
            AAge    = 0;

            PPersonTable PersonTable;

            PersonTable = PPersonAccess.LoadByPrimaryKey(APartnerKey, ASituation.GetDatabaseConnection().Transaction);

            if (PersonTable.Rows.Count > 0)
            {
                PPersonRow PersonRow = (PPersonRow)PersonTable.Rows[0];
                AGender = PersonRow.Gender.ToCharArray()[0];

                if (!PersonRow.IsDateOfBirthNull())
                {
                    AAge = Calculations.CalculateAge(PersonRow.DateOfBirth.Value, AStartDate);
                }

                ReturnValue = true;
            }

            return(ReturnValue);
        }
        /// <summary>
        /// Adds one partner to the report table
        /// </summary>
        /// <param name="ABirthday">The birthday of the current partner</param>
        /// <param name="AGender">Gender of the current partner</param>
        /// <param name="ASituation">The current report situation</param>
        /// <returns></returns>
        public bool CalculateSingleAge(DateTime ABirthday, String AGender, ref TRptSituation ASituation)
        {
            bool FoundAge = false;

            int Age = Calculations.CalculateAge(ABirthday);

            for (int Counter = 0; Counter < FAgeTable.Rows.Count; ++Counter)
            {
                if ((int)FAgeTable.Rows[Counter][COLUMNAGE] == Age)
                {
                    FoundAge = true;
                    AddAttendeeToTable(Counter, AGender, Age);
                }
            }

            if (!FoundAge)
            {
                AddAttendeeToTable(-1, AGender, Age);
            }

            if (FEarliestBirthday.CompareTo(ABirthday) > 0)
            {
                FEarliestBirthday = ABirthday;
            }

            if (FLatestBirthday.CompareTo(ABirthday) < 0)
            {
                FLatestBirthday = ABirthday;
            }

            return(true);
        }
        /// <summary>
        /// Gets the row index for the result table to which this room booking refers.
        /// </summary>
        /// <param name="ARow">room booking row</param>
        /// <param name="AReportDetail">Indicator of the details of the report. Possible options: Brief, Full, Detail</param>
        /// <param name="ASituation">The current report situation</param>
        /// <returns></returns>
        private int GetRowIndexForRoom(PcRoomAllocRow ARow, string AReportDetail, ref TRptSituation ASituation)
        {
            // Check if this room is already in the table

            String RoomName = ARow.BuildingCode;

            if (AReportDetail != "Brief")
            {
                RoomName = ARow.BuildingCode + " / " + ARow.RoomNumber;
            }

            int RoomRow = -1;

            for (int Counter = 0; Counter < FAccommodationTable.Rows.Count; ++Counter)
            {
                if (FAccommodationTable.Rows[Counter][0].ToString() == RoomName)
                {
                    RoomRow = Counter;
                    break;
                }
            }

            if (RoomRow == -1)
            {
                DataRow NewRow = FAccommodationTable.NewRow();
                NewRow[0]       = RoomName;
                NewRow["Venue"] = TAccommodationReportCalculation.GetPartnerShortName(ARow.VenueKey, ref ASituation);

                FAccommodationTable.Rows.Add(NewRow);
                RoomRow = FAccommodationTable.Rows.Count - 1;
            }

            return(RoomRow);
        }
Example #4
0
        private String GetCountryName(String ACountryCode, ref TRptSituation ASituation)
        {
            PCountryTable CountryTable;

            CountryTable = PCountryAccess.LoadByPrimaryKey(ACountryCode, ASituation.GetDatabaseConnection().Transaction);

            if (CountryTable.Rows.Count > 0)
            {
                return((String)CountryTable.Rows[0][PCountryTable.GetCountryNameDBName()]);
            }

            return("Unknown");
        }
Example #5
0
        /// <summary>
        /// Calculate the data of one partner attending the conference
        /// </summary>
        /// <param name="AConferenceKey"></param>
        /// <param name="APartnerKey"></param>
        /// <param name="ABirthDay"></param>
        /// <param name="AArrivalDate"></param>
        /// <param name="ADepartureDate"></param>
        /// <param name="AActualArrivalDate"></param>
        /// <param name="AActualDepartureDate"></param>
        /// <param name="AStartDate"></param>
        /// <param name="AEndDate"></param>
        /// <param name="ASituation">Current report situation</param>
        /// <returns></returns>
        public bool CalculateSingleAttendance(long AConferenceKey, long APartnerKey, DateTime ABirthDay,
                                              DateTime AArrivalDate, DateTime ADepartureDate,
                                              DateTime AActualArrivalDate, DateTime AActualDepartureDate,
                                              DateTime AStartDate, DateTime AEndDate,
                                              ref TRptSituation ASituation)
        {
            DateTime ArrivalDate   = AActualArrivalDate;
            DateTime DepartureDate = AActualDepartureDate;

            if (FLastConferenceKey != AConferenceKey)
            {
                FChildDiscountAge  = GetChildDiscountAge(AConferenceKey, ref ASituation);
                FLastConferenceKey = AConferenceKey;
            }

            int Age = Calculations.CalculateAge(ABirthDay, AStartDate);

            if ((AArrivalDate > ADepartureDate) ||
                (AActualArrivalDate > AActualDepartureDate))
            {
                return(false);
            }

            if (DepartureDate == DateTime.MinValue)
            {
                DepartureDate = ADepartureDate;

                if (DepartureDate == DateTime.MinValue)
                {
                    DepartureDate = AEndDate;
                }
            }

            if (ArrivalDate != DateTime.MinValue)
            {
                AddAttendeeToList(ArrivalDate, DepartureDate, Age, true);
            }
            else
            {
                ArrivalDate = AArrivalDate;

                if (ArrivalDate == DateTime.MinValue)
                {
                    ArrivalDate = AStartDate;
                }

                AddAttendeeToList(ArrivalDate, DepartureDate, Age, false);
            }

            return(true);
        }
Example #6
0
        /// <summary>
        /// functions need to be registered here
        /// </summary>
        /// <param name="ASituation"></param>
        /// <param name="f"></param>
        /// <param name="ops"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public override Boolean FunctionSelector(TRptSituation ASituation, String f, TVariant[] ops, out TVariant value)
        {
            if (base.FunctionSelector(ASituation, f, ops, out value))
            {
                return(true);
            }

            if (StringHelper.IsSame(f, "getGiftStatistics"))
            {
                value = new TVariant();
                GetGiftStatistics(ops[1].ToInt(), ops[2].ToString(), ops[3].ToString(), ops[4].ToInt(), ops[5].ToInt(), ops[6].ToInt());
                return(true);
            }

            if (StringHelper.IsSame(f, "IsLapsedDonor"))
            {
                value =
                    new TVariant(IsLapsedDonor(ops[1].ToInt64(), ops[2].ToInt64(), ops[3].ToDate(), ops[4].ToDate(), ops[5].ToString(), ops[6].ToInt(),
                                               ops[7].ToInt(), ops[8].ToString(), ops[9].ToString(), ops[10].ToBool()));
                return(true);
            }

            if (StringHelper.IsSame(f, "SelectLastGift"))
            {
                value = new TVariant(SelectLastGift(ops[1].ToInt64(), ops[2].ToInt64(), ops[3].ToDate(), ops[4].ToDate(), ops[5].ToString()));
                return(true);
            }

            if (StringHelper.IsSame(f, "IsTopDonor"))
            {
                value = new TVariant(IsTopDonor(ops[1].ToDecimal(), ops[2].ToDecimal(), ops[3].ToDecimal()));
                return(true);
            }

            if (StringHelper.IsSame(f, "MakeTopDonor"))
            {
                value = new TVariant(MakeTopDonor(ops[1].ToDecimal(), ops[2].ToDecimal(), ops[3].ToDecimal(),
                                                  ops[4].ToBool(), ops[5].ToString(), ops[6].ToDate(), ops[7].ToDate(),
                                                  ops[8].ToInt64(), ops[9].ToString(), ops[10].ToString()));
                return(true);
            }

            value = new TVariant();
            return(false);
        }
        /// <summary>
        /// Retrieves the short name of a partner.
        /// </summary>
        /// <param name="APartnerKey">Partner key</param>
        /// <param name="ASituation">The current report situation</param>
        /// <returns></returns>
        public static String GetPartnerShortName(Int64 APartnerKey, ref TRptSituation ASituation)
        {
            String           ReturnValue;
            PPartnerTable    table;
            StringCollection fields;

            ReturnValue = "N/A";
            fields      = new StringCollection();
            fields.Add(PPartnerTable.GetPartnerShortNameDBName());
            table = PPartnerAccess.LoadByPrimaryKey(APartnerKey, fields, ASituation.GetDatabaseConnection().Transaction);

            if (table.Rows.Count > 0)
            {
                ReturnValue = table[0].PartnerShortName;
            }

            return(ReturnValue);
        }
Example #8
0
        /// <summary>
        /// Get the passport details and restores them as parameters.
        /// If there is a passport with the MainPassport flag set, then use this passport.
        /// Otherwise use the most recent passport which has a passport number.
        /// </summary>
        /// <param name="APartnerKey">Partner key</param>
        /// <param name="ASituation">A current Report Situation</param>
        /// <returns>true if one passport was found, otherwise false</returns>
        public static PmPassportDetailsRow GetLatestPassport(Int64 APartnerKey, TRptSituation ASituation)
        {
            PmPassportDetailsTable PassportTable     = null;
            PmPassportDetailsRow   ResultPassportRow = null;

            StringCollection PassportCollumns = new StringCollection();
            StringCollection OrderList        = new StringCollection();

            PassportCollumns.Add(PmPassportDetailsTable.GetPassportNationalityCodeDBName());
            PassportCollumns.Add(PmPassportDetailsTable.GetPassportNumberDBName());
            PassportCollumns.Add(PmPassportDetailsTable.GetDateOfExpirationDBName());
            PassportCollumns.Add(PmPassportDetailsTable.GetFullPassportNameDBName());
            OrderList.Add("ORDER BY " + PmPassportDetailsTable.GetDateOfExpirationDBName() + " DESC");

            PassportTable = PmPassportDetailsAccess.LoadViaPPerson(APartnerKey,
                                                                   PassportCollumns, ASituation.GetDatabaseConnection().Transaction,
                                                                   OrderList, 0, 0);

            // Look for MainPassport flag
            foreach (PmPassportDetailsRow Row in PassportTable.Rows)
            {
                if (!Row.IsMainPassportNull() &&
                    Row.MainPassport)
                {
                    ResultPassportRow = Row;
                    break;
                }
            }

            // Look for the most recent passport with a passport number
            if (ResultPassportRow == null)
            {
                foreach (PmPassportDetailsRow Row in PassportTable.Rows)
                {
                    if (Row.PassportNumber.Length > 0)
                    {
                        ResultPassportRow = Row;
                        break;
                    }
                }
            }

            return(ResultPassportRow);
        }
Example #9
0
        private int GetChildDiscountAge(long AConferenceKey, ref TRptSituation ASituation)
        {
            int DiscountAge = 0;

            PcDiscountTable DiscountTable;

            DiscountTable = PcDiscountAccess.LoadViaPcConference(AConferenceKey, ASituation.GetDatabaseConnection().Transaction);

            foreach (DataRow CurrentRow in DiscountTable.Rows)
            {
                if ((string)CurrentRow[PcDiscountTable.GetDiscountCriteriaCodeDBName()] == "CHILD")
                {
                    DiscountAge = (int)CurrentRow[PcDiscountTable.GetUpToAgeDBName()];
                    return(DiscountAge);
                }
            }

            return(DiscountAge);
        }
        /// <summary>
        /// Insert the values of a data row into the report results.
        /// The data row contains for each room / venue the bookings.
        /// </summary>
        /// <param name="ANumColumns">Number of columns the report has</param>
        /// <param name="AChildRow">Index of the child row</param>
        /// <param name="ADataRow">The data row which contains the values</param>
        /// <param name="ASituation">The current report situation</param>
        /// <returns>true</returns>
        private bool InsertDataRow(int ANumColumns, int AChildRow, DataRow ADataRow, ref TRptSituation ASituation)
        {
            TVariant[] Header      = new TVariant[ANumColumns];
            TVariant[] Description =
            {
                new TVariant(), new TVariant()
            };
            TVariant[] Columns = new TVariant[ANumColumns];

            for (int Counter = 0; Counter < ANumColumns; ++Counter)
            {
                Columns[Counter] = new TVariant(ADataRow[Counter * 2].ToString() + ADataRow[Counter * 2 + 1].ToString());
                Header[Counter]  = new TVariant();
            }

            ASituation.GetResults().AddRow(0, AChildRow, true, 2, "", "", false,
                                           Header, Description, Columns);
            return(true);
        }
        /// <summary>
        /// Main entry point for calculating the accommodation report.
        /// This must be called for each partner in each conference.
        /// </summary>
        /// <param name="AConferenceKey">Conference Key of the current conference to examine</param>
        /// <param name="AStartDate">Start date of the conference</param>
        /// <param name="AEndDate">End date of the conference</param>
        /// <param name="AFromDate">Start date of the report</param>
        /// <param name="AToDate">End date of the report</param>
        /// <param name="APartnerKey">Partner Key of the current partner to examine</param>
        /// <param name="AReportDetail">Indicator of the details of the report. Possible options: Brief, Full, Detail</param>
        /// <param name="ASituation">The current report situation</param>
        /// <returns></returns>
        public bool CalculatePartnerAccom(long AConferenceKey,
                                          DateTime AStartDate, DateTime AEndDate,
                                          DateTime AFromDate, DateTime AToDate,
                                          long APartnerKey, string AReportDetail,
                                          ref TRptSituation ASituation)
        {
            PcAttendeeTable             AttendeeTable;
            PcAttendeeRow               AttendeeRow = null;
            PmShortTermApplicationTable ShortTermTable;
            PmShortTermApplicationTable TmpTable = new PmShortTermApplicationTable();
            PmShortTermApplicationRow   TemplateRow;


            TemplateRow                   = TmpTable.NewRowTyped(false);
            TemplateRow.PartnerKey        = APartnerKey;
            TemplateRow.StConfirmedOption = AConferenceKey;

            if (FAccommodationTable == null)
            {
                InitAccomTable(AFromDate, AToDate);
            }

            AttendeeTable = PcAttendeeAccess.LoadByPrimaryKey(AConferenceKey, APartnerKey, ASituation.GetDatabaseConnection().Transaction);

            if (AttendeeTable.Rows.Count > 0)
            {
                AttendeeRow = (PcAttendeeRow)AttendeeTable.Rows[0];
            }

            ShortTermTable = PmShortTermApplicationAccess.LoadUsingTemplate(TemplateRow, ASituation.GetDatabaseConnection().Transaction);

            foreach (DataRow Row in ShortTermTable.Rows)
            {
                AddPartnerToAccom((PmShortTermApplicationRow)Row, AttendeeRow, AStartDate, AEndDate,
                                  AFromDate, AToDate, AReportDetail, ref ASituation);
            }

            return(true);
        }
Example #12
0
        /// <summary>
        /// Copies the result of the FAttendanceTable to report.
        /// </summary>
        /// <returns></returns>
        public bool FinishAttendanceTable(ref TRptSituation ASituation)
        {
            ASituation.GetResults().Clear();

            if (FAttendanceTable == null)
            {
                return(false);
            }

            int ChildRow = 1;

            foreach (DataRow CurrentRow in FAttendanceTable.Rows)
            {
                if (!(bool)CurrentRow[5])
                {
                    // skip dates where there is no entry.
                    continue;
                }

                TVariant[] Header      = new TVariant[5];
                TVariant[] Description =
                {
                    new TVariant(), new TVariant()
                };
                TVariant[] Columns = new TVariant[5];

                for (int Counter = 0; Counter < 5; ++Counter)
                {
                    Columns[Counter] = new TVariant(CurrentRow[Counter].ToString());
                    Header[Counter]  = new TVariant();
                }

                ASituation.GetResults().AddRow(0, ChildRow++, true, 1, "", "", false,
                                               Header, Description, Columns);
            }

            return(true);
        }
Example #13
0
        /// <summary>
        /// Copies the result of the FNationalityTable to report.
        /// </summary>
        /// <returns></returns>
        public bool FinishNationalityTable(ref TRptSituation ASituation)
        {
            ASituation.GetResults().Clear();

            if (FNationalityTable == null)
            {
                return(false);
            }

            int ChildRow = 1;

            foreach (DataRow CurrentRow in FNationalityTable.Rows)
            {
                String NationalityCode = (String)CurrentRow[COLUMNNATIONALITYCODE];
                CurrentRow[COLUMNNATIONALITY] = NationalityCode; // + "  " + GetCountryName(NationalityCode, ref ASituation);

                TVariant[] Header      = new TVariant[6];
                TVariant[] Description =
                {
                    new TVariant(), new TVariant()
                };
                TVariant[] Columns = new TVariant[6];

                for (int Counter = 0; Counter < 5; ++Counter)
                {
                    Columns[Counter] = new TVariant(CurrentRow[Counter].ToString());
                    Header[Counter]  = new TVariant();
                }

                Columns[5] = new TVariant(GetLanguagesSummary(NationalityCode));
                Header[5]  = new TVariant();

                ASituation.GetResults().AddRow(0, ChildRow++, true, 1, "", "", false,
                                               Header, Description, Columns);
            }

            return(true);
        }
        /// <summary>
        /// Calculates the cost of the room for one person for the given number of days.
        /// </summary>
        /// <param name="ARow">Room allocation row for the room booking</param>
        /// <param name="ANumberOfBookedDays">number of booked days</param>
        /// <param name="ARoomRow">the row index on the result table to which this calculation refers</param>
        /// <param name="AAge">age of the person who is in the room</param>
        /// <param name="AConferenceKey">conference key of the current conference</param>
        /// <param name="ASituation">The current report situation</param>
        /// <returns></returns>
        private bool CalculateRoomCost(PcRoomAllocRow ARow, int ANumberOfBookedDays, int ARoomRow,
                                       int AAge, long AConferenceKey, ref TRptSituation ASituation)
        {
            PcRoomTable RoomTable;

            RoomTable = PcRoomAccess.LoadByPrimaryKey(ARow.VenueKey, ARow.BuildingCode, ARow.RoomNumber,
                                                      ASituation.GetDatabaseConnection().Transaction);

            if (RoomTable.Rows.Count > 0)
            {
                PcRoomRow RoomRow = (PcRoomRow)RoomTable.Rows[0];

                decimal cost = RoomRow.BedCost * ANumberOfBookedDays;
                decimal ChildDiscount;
                bool    InPercent;

                if (TAccommodationReportCalculation.GetChildDiscount(AAge, AConferenceKey, "ACCOMMODATION", out ChildDiscount, out InPercent,
                                                                     ref ASituation))
                {
                    if (InPercent)
                    {
                        cost = cost * (100 - ChildDiscount) / 100;
                    }
                    else
                    {
                        // At the moment we ignore if the child discount is not set up as percent
                        cost = RoomRow.BedCost * ANumberOfBookedDays;
                    }
                }

                FAccommodationTable.Rows[ARoomRow]["Total Cost"] =
                    (decimal)FAccommodationTable.Rows[ARoomRow]["Total Cost"] + cost;
            }

            return(true);
        }
Example #15
0
        /// <summary>
        /// Adds one partner to the report table
        /// </summary>
        /// <param name="APartnerKey">The partner key of the current partner</param>
        /// <param name="AGender">Gender of the current partner</param>
        /// <param name="ALanguageCode">The mother language of the current partner</param>
        /// <param name="ASituation">The current report situation</param>
        /// <returns></returns>
        public bool CalculateNationalities(long APartnerKey, String AGender, String ALanguageCode, ref TRptSituation ASituation)
        {
            TCacheable CommonCacheable = new TCacheable();

            StringCollection PassportColumns = StringHelper.StrSplit(
                PmPassportDetailsTable.GetDateOfIssueDBName() + "," +
                PmPassportDetailsTable.GetDateOfExpirationDBName() + "," +
                PmPassportDetailsTable.GetPassportNationalityCodeDBName() + "," +
                PmPassportDetailsTable.GetMainPassportDBName(), ",");

            PmPassportDetailsTable PassportDetailsDT = PmPassportDetailsAccess.LoadViaPPerson(APartnerKey,
                                                                                              PassportColumns, ASituation.GetDatabaseConnection().Transaction, null, 0, 0);

            string Nationalities = Ict.Petra.Shared.MPersonnel.Calculations.DeterminePersonsNationalities(
                @CommonCacheable.GetCacheableTable, PassportDetailsDT);

            string[] NationalitiesArray = Nationalities.Split(',');

            bool          FoundNationality      = false;
            List <string> PreviousNationalities = new List <string>();

            foreach (string Nationality in NationalitiesArray)
            {
                string SingleNationality = Nationality;

                // remove all characters other than the country name
                SingleNationality = Nationality.TrimStart(' ');

                if (SingleNationality.EndsWith(Ict.Petra.Shared.MPersonnel.Calculations.PASSPORT_EXPIRED))
                {
                    SingleNationality = SingleNationality.Remove(SingleNationality.Length -
                                                                 Ict.Petra.Shared.MPersonnel.Calculations.PASSPORT_EXPIRED.Length);
                }
                else if (SingleNationality.EndsWith(Ict.Petra.Shared.MPersonnel.Calculations.PASSPORTMAIN_EXPIRED))
                {
                    SingleNationality = SingleNationality.Remove(SingleNationality.Length -
                                                                 Ict.Petra.Shared.MPersonnel.Calculations.PASSPORTMAIN_EXPIRED.Length);
                }

                if (SingleNationality == "")
                {
                    SingleNationality = Catalog.GetString("UNKNOWN");
                }

                // make sure that this nationality has not already been processed for this partner
                if (!PreviousNationalities.Contains(SingleNationality))
                {
                    for (int Counter = 0; Counter < FNationalityTable.Rows.Count; ++Counter)
                    {
                        if (((String)FNationalityTable.Rows[Counter][COLUMNNATIONALITYCODE] == SingleNationality))
                        {
                            FoundNationality = true;
                            AddAttendeeToTable(Counter, AGender, SingleNationality, ALanguageCode);
                        }
                    }

                    if (!FoundNationality)
                    {
                        AddAttendeeToTable(-1, AGender, SingleNationality, ALanguageCode);
                    }

                    PreviousNationalities.Add(SingleNationality);
                }
            }

            return(true);
        }
        /// <summary>
        /// Adds the dates of one partner to the accommodation report
        /// </summary>
        /// <param name="AShortTermRow">The short term application row of the current partner</param>
        /// <param name="AAttendeeRow">The attendee row of the current partner</param>
        /// <param name="AStartDate">Start date of the conference</param>
        /// <param name="AEndDate">End date of the conference</param>
        /// <param name="AFromDate">Start date of the report</param>
        /// <param name="AToDate">End date of the report</param>
        /// <param name="AReportDetail">Indicator of the details of the report. Possible options: Brief, Full, Detail</param>
        /// <param name="ASituation">The current report situation</param>
        /// <returns></returns>
        private bool AddPartnerToAccom(PmShortTermApplicationRow AShortTermRow,
                                       PcAttendeeRow AAttendeeRow,
                                       DateTime AStartDate, DateTime AEndDate,
                                       DateTime AFromDate, DateTime AToDate,
                                       string AReportDetail, ref TRptSituation ASituation)
        {
            // if we have an actual arrival and departure date from the attendee row use it.
            if (AAttendeeRow != null)
            {
                if (!AAttendeeRow.IsActualArrNull())
                {
                    AShortTermRow.Arrival = AAttendeeRow.ActualArr;
                }

                if (!AAttendeeRow.IsActualDepNull())
                {
                    AShortTermRow.Departure = AAttendeeRow.ActualDep;
                }
            }

            if (AShortTermRow.IsArrivalNull())
            {
                AShortTermRow.Arrival = AStartDate;
            }

            if (AShortTermRow.IsDepartureNull())
            {
                AShortTermRow.Departure = AEndDate;
            }

            if ((AShortTermRow.Arrival <= AToDate) &&
                (AShortTermRow.Departure >= AFromDate))
            {
                // this short term application covers the dates we examine

                PcRoomAllocTable TempTable = new PcRoomAllocTable();
                PcRoomAllocTable RoomAllocTable;
                PcRoomAllocRow   TemplateRow = TempTable.NewRowTyped(false);
                TemplateRow.PartnerKey    = AShortTermRow.PartnerKey;
                TemplateRow.ConferenceKey = AShortTermRow.StConfirmedOption;

                RoomAllocTable = PcRoomAllocAccess.LoadUsingTemplate(TemplateRow, ASituation.GetDatabaseConnection().Transaction);

                char   Gender;
                int    Age;
                string PartnerName;
                GetGenderAndAge(AShortTermRow.PartnerKey, AStartDate, out Gender, out Age, ref ASituation);
                PartnerName = TAccommodationReportCalculation.GetPartnerShortName(AShortTermRow.PartnerKey, ref ASituation);

                foreach (DataRow Row in RoomAllocTable.Rows)
                {
                    CheckRoomAllocation((PcRoomAllocRow)Row, AShortTermRow, AFromDate, AToDate,
                                        AReportDetail, Gender, Age, PartnerName, ref ASituation);
                }

                if (RoomAllocTable.Rows.Count == 0)
                {
                    AddNoRoomBooking(AShortTermRow, AFromDate, AToDate, Gender, PartnerName);
                }
            }

            return(true);
        }
        /// <summary>
        /// Adds the room allocation of one partner to the result.
        /// </summary>
        /// <param name="ARoomAllocRow">The room allocation row of the current partner</param>
        /// <param name="AShortTermRow">The short term application row of the current partner</param>
        /// <param name="AFromDate">Start date of the report</param>
        /// <param name="AToDate">End date of the report</param>
        /// <param name="AReportDetail">Indicator of the details of the report. Possible options: Brief, Full, Detail</param>
        /// <param name="AGender">Gender of the current person to examine</param>
        /// <param name="AAge">Age of the person to examine</param>
        /// <param name="APartnerName">Name of the current person</param>
        /// <param name="ASituation">The current report situation</param>
        /// <returns></returns>
        private bool CheckRoomAllocation(PcRoomAllocRow ARoomAllocRow, PmShortTermApplicationRow AShortTermRow,
                                         DateTime AFromDate, DateTime AToDate, string AReportDetail, char AGender,
                                         int AAge, string APartnerName, ref TRptSituation ASituation)
        {
            int RoomRow = GetRowIndexForRoom(ARoomAllocRow, AReportDetail, ref ASituation);

            TimeSpan CheckLength        = AToDate.Subtract(AFromDate);
            int      DaysNumber         = CheckLength.Days;
            int      MaxCollumns        = FAccommodationTable.Columns.Count - 2;
            int      NumberOfBookedDays = 0;
            bool     FirstDayOfNoAccom  = true;

            DataRow DetailRow = FAccommodationDetailTable.NewRow();

            DetailRow["RoomName"]    = FAccommodationTable.Rows[RoomRow]["RoomName"];
            DetailRow["PartnerName"] = "   " + APartnerName;
            DataRow DetailRowNoBooking = FAccommodationDetailTable.NewRow();

            DetailRowNoBooking["RoomName"]    = NO_ACCOMMODATION;
            DetailRowNoBooking["PartnerName"] = "   " + APartnerName;

            // Check each day for the booking
            for (int Counter = 0; Counter <= DaysNumber; ++Counter)
            {
                DateTime CurrentDay = AFromDate.AddDays(Counter);

                if ((CurrentDay >= ARoomAllocRow.In) &&
                    (CurrentDay < ARoomAllocRow.Out))
                {
                    // there is a room booking for this person for this day
                    if (Counter < MaxCollumns)
                    {
                        FAccommodationTable.Rows[RoomRow][(Counter + 1) * 2] =
                            (int)FAccommodationTable.Rows[RoomRow][(Counter + 1) * 2] + 1;
                        FAccommodationTable.Rows[RoomRow][(Counter + 1) * 2 + 1] =
                            GetGenderOfBooking(AGender, (char)FAccommodationTable.Rows[RoomRow][(Counter + 1) * 2 + 1]);
                        NumberOfBookedDays++;

                        DetailRow[Counter + 1] = "**";
                    }
                }
                else
                {
                    // there is no room booking
                    if ((Counter < MaxCollumns) &&
                        (CurrentDay >= AShortTermRow.Arrival) &&
                        (CurrentDay < AShortTermRow.Departure))
                    {
                        FAccommodationTable.Rows[0][(Counter + 1) * 2] =
                            (int)FAccommodationTable.Rows[0][(Counter + 1) * 2] + 1;
                        FAccommodationTable.Rows[0][(Counter + 1) * 2 + 1] =
                            GetGenderOfBooking(AGender, (char)FAccommodationTable.Rows[0][(Counter + 1) * 2 + 1]);

                        DetailRowNoBooking[Counter + 1] = "**";

                        if (FirstDayOfNoAccom)
                        {
                            AddToNoAccomList(AShortTermRow.PartnerKey, APartnerName, CurrentDay);
                            FirstDayOfNoAccom = false;
                        }
                    }
                }
            }

            CalculateRoomCost(ARoomAllocRow, NumberOfBookedDays, RoomRow, AAge, AShortTermRow.StConfirmedOption, ref ASituation);

            FAccommodationDetailTable.Rows.Add(DetailRow);

            if (!FirstDayOfNoAccom)
            {
                // Add this partner to the "no accomodation" list there is one day without.
                FAccommodationDetailTable.Rows.Add(DetailRowNoBooking);
            }

            return(true);
        }
Example #18
0
        /// <summary>
        /// functions need to be registered here
        /// </summary>
        /// <param name="ASituation"></param>
        /// <param name="f"></param>
        /// <param name="ops"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public override Boolean FunctionSelector(TRptSituation ASituation, String f, TVariant[] ops, out TVariant value)
        {
            if (base.FunctionSelector(ASituation, f, ops, out value))
            {
                return(true);
            }

            if (StringHelper.IsSame(f, "GetSiteName"))
            {
                value = new TVariant(GetSiteName());
                return(true);
            }

            if (StringHelper.IsSame(f, "GetCurrentCommitmentPeriod"))
            {
                value = new TVariant(GetCurrentCommitmentPeriod(ops[1].ToInt64(), ops[2].ToDate()));
                return(true);
            }

            if (StringHelper.IsSame(f, "GetType"))
            {
                value = new TVariant(GetType(ops[1].ToInt64(), ops[2].ToString(), ops[3].ToString()));
                return(true);
            }

            if (StringHelper.IsSame(f, "GenerateUnitHierarchy"))
            {
                value = new TVariant(GenerateUnitHierarchy(ops[1].ToInt64(), ops[2].ToString()));
                return(true);
            }

            if (StringHelper.IsSame(f, "GetMissingInfo"))
            {
                value = new TVariant(GetMissingInfo(ops[1].ToInt64(), ops[2].ToInt(), ops[3].ToInt64()));
                return(true);
            }

            if (StringHelper.IsSame(f, "GetPersonLanguages"))
            {
                value = new TVariant(GetPersonLanguages(ops[1].ToInt64()));
                return(true);
            }

            if (StringHelper.IsSame(f, "GetPassport"))
            {
                value = new TVariant(GetPassport(ops[1].ToInt64()));
                return(true);
            }

            if (StringHelper.IsSame(f, "GetNationalities"))
            {
                value = new TVariant(GetNationalities(ops[1].ToInt64()));
                return(true);
            }

            if (StringHelper.IsSame(f, "GetChurch"))
            {
                value = new TVariant(GetChurch(ops[1].ToInt64()));
                return(true);
            }

            if (StringHelper.IsSame(f, "GetDietary"))
            {
                value = new TVariant(GetDietary(ops[1].ToInt64()));
                return(true);
            }

            if (StringHelper.IsSame(f, "GetMedicalInfo"))
            {
                value = new TVariant(GetMedicalInfo(ops[1].ToInt64()));
                return(true);
            }

            if (StringHelper.IsSame(f, "GetOtherNeeds"))
            {
                value = new TVariant(GetOtherNeeds(ops[1].ToInt64()));
                return(true);
            }

            if (StringHelper.IsSame(f, "GetPartnerContact"))
            {
                value = new TVariant(GetPartnerContact(ops[1].ToInt64()));
                return(true);
            }

            if (StringHelper.IsSame(f, "CalculateAge"))
            {
                value = new TVariant(CalculateAge(ops[1].ToDate()));
                return(true);
            }

            if (StringHelper.IsSame(f, "CalculateAgeAtDate"))
            {
                value = new TVariant(CalculateAgeAtDate(ops[1].ToDate(), ops[2].ToDate()));
                return(true);
            }

            if (StringHelper.IsSame(f, "GetArrivalPoint"))
            {
                value = new TVariant(GetArrivalPoint(ops[1].ToString()));
                return(true);
            }

            /*
             * if (isSame(f, 'doSomething')) then
             * begin
             * value := new TVariant();
             * doSomething(ops[1].ToInt(), ops[2].ToString(), ops[3].ToString());
             * exit;
             * end;
             */
            value = new TVariant();
            return(false);
        }
Example #19
0
        /// <summary>
        /// register functions here
        /// </summary>
        /// <param name="ASituation"></param>
        /// <param name="f"></param>
        /// <param name="ops"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public override Boolean FunctionSelector(TRptSituation ASituation, String f, TVariant[] ops, out TVariant value)
        {
            base.FunctionSelector(ASituation, f, ops, out value);

            if (StringHelper.IsSame(f, "getStatePeriod"))
            {
                value = new TVariant(GetStatePeriod(ops[1].ToInt(), ops[2].ToInt(), ops[3].ToInt()));
                return(true);
            }

            if (StringHelper.IsSame(f, "periodInLastYear"))
            {
                value = new TVariant(PeriodInLastYear(ops[1].ToInt(), ops[2].ToInt()));
                return(true);
            }

            if (StringHelper.IsSame(f, "periodInThisYearOld"))
            {
                value = new TVariant(PeriodInThisYearOld(ops[1].ToInt(), ops[2].ToInt()));
                return(true);
            }

            if (StringHelper.IsSame(f, "getQuarterOrPeriod"))
            {
                value = new TVariant(GetQuarterOrPeriod(ops[1].ToInt(), ops[2].ToInt(), ops[3].ToInt(), ops[4].ToInt()));
                return(true);
            }

            if (StringHelper.IsSame(f, "getPeriodStartDate"))
            {
                value = new TVariant(GetPeriodStartDate(ops[1].ToInt(), ops[2].ToInt()));
                return(true);
            }

            if (StringHelper.IsSame(f, "getPeriodEndDate"))
            {
                value = new TVariant(GetPeriodEndDate(ops[1].ToInt(), ops[2].ToInt()));
                return(true);
            }

            if (StringHelper.IsSame(f, "getYTDPeriod"))
            {
                value = new TVariant(GetYTDPeriod(ops[1].ToInt(), ops[2].ToInt(), ops[3].ToString()));
                return(true);
            }

            if (StringHelper.IsSame(f, "GetPreviousYearCaption"))
            {
                value = new TVariant(GetPreviousYearCaption());
                return(true);
            }

            if (StringHelper.IsSame(f, "GetCurrentYearCaption"))
            {
                value = new TVariant(GetCurrentYearCaption());
                return(true);
            }

            if (StringHelper.IsSame(f, "GetNextYearCaption"))
            {
                value = new TVariant(GetNextYearCaption());
                return(true);
            }

            if (StringHelper.IsSame(f, "getMonthName"))
            {
                value = new TVariant(GetMonthName(ops[1].ToInt(), ops[2].ToInt()));
                return(true);
            }

            if (StringHelper.IsSame(f, "getMonthDiff"))
            {
                value = new TVariant(GetMonthDiff(ops[1].ToInt(), ops[2].ToInt(), ops[3].ToInt(), ops[4].ToInt()));
                return(true);
            }

            value = new TVariant();
            return(false);
        }
Example #20
0
        /// <summary>
        /// all functions for reports in the conference module need to be registered here
        /// </summary>
        /// <param name="ASituation"></param>
        /// <param name="f"></param>
        /// <param name="ops"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public override Boolean FunctionSelector(TRptSituation ASituation, String f, TVariant[] ops, out TVariant value)
        {
            if (base.FunctionSelector(ASituation, f, ops, out value))
            {
                return(true);
            }

            if (StringHelper.IsSame(f, "GetConferenceRoom"))
            {
                value = new TVariant(GetConferenceRoom(ops[1].ToInt64(), ops[2].ToInt64(), ops[3].ToString()));
                return(true);
            }

            if (StringHelper.IsSame(f, "CalculatePartnerAccom"))
            {
                bool ResultValue = false;

                if (FAccommodationReportCalculation != null)
                {
                    ResultValue = FAccommodationReportCalculation.CalculatePartnerAccom(
                        ops[1].ToInt64(), ops[2].ToDate(), ops[3].ToDate(),
                        ops[4].ToDate(), ops[5].ToDate(), ops[6].ToInt64(),
                        ops[7].ToString(), ref situation);
                }

                value = new TVariant(ResultValue);
                return(true);
            }

            if (StringHelper.IsSame(f, "ClearAccomTable"))
            {
                value = new TVariant(true);

                if (FAccommodationReportCalculation != null)
                {
                    FAccommodationReportCalculation = null;
                }

                FAccommodationReportCalculation = new TAccommodationReportCalculation();

                return(true);
            }

            if (StringHelper.IsSame(f, "FinishAccomTable"))
            {
                bool ResultValue = false;

                if (FAccommodationReportCalculation != null)
                {
                    ResultValue = FAccommodationReportCalculation.FinishAccomTable(ops[1].ToString(),
                                                                                   ref situation);
                    // now we don't use FAccommodationReportCalculation any more.
                    FAccommodationReportCalculation = null;
                }

                value = new TVariant(ResultValue);
                return(true);
            }

            if (StringHelper.IsSame(f, "CalculateSingleAttendance"))
            {
                bool ResultValue = false;

                if (FAttendanceSummaryCalculation != null)
                {
                    ResultValue = FAttendanceSummaryCalculation.CalculateSingleAttendance(
                        ops[1].ToInt64(), ops[2].ToInt64(), ops[3].ToDate(),
                        ops[4].ToDate(), ops[5].ToDate(),
                        ops[6].ToDate(), ops[7].ToDate(),
                        ops[8].ToDate(), ops[9].ToDate(), ref situation);
                }

                value = new TVariant(ResultValue);
                return(true);
            }

            if (StringHelper.IsSame(f, "ClearAttendanceTable"))
            {
                FAttendanceSummaryCalculation = new TAttendanceSummaryCalculation(ops[1].ToDate(), ops[2].ToDate());
                value = new TVariant(true);
                return(true);
            }

            if (StringHelper.IsSame(f, "FinishAttendanceTable"))
            {
                bool ResultValue = false;

                if (FAttendanceSummaryCalculation != null)
                {
                    ResultValue = FAttendanceSummaryCalculation.FinishAttendanceTable(ref situation);
                    FAttendanceSummaryCalculation = null;
                }

                value = new TVariant(ResultValue);
                return(true);
            }

            if (StringHelper.IsSame(f, "CalculateNationalities"))
            {
                bool ResultValue = false;

                if (FNationalitySummaryCalculation != null)
                {
                    ResultValue = FNationalitySummaryCalculation.CalculateNationalities(ops[1].ToInt64(),
                                                                                        ops[2].ToString(), ops[3].ToString(), ref situation);
                }

                value = new TVariant(ResultValue);
                return(true);
            }

            if (StringHelper.IsSame(f, "ClearNationalityTable"))
            {
                FNationalitySummaryCalculation = new TNationalitySummaryCalculation();

                value = new TVariant(true);
                return(true);
            }

            if (StringHelper.IsSame(f, "FinishNationalityTable"))
            {
                bool ResultValue = false;

                if (FNationalitySummaryCalculation != null)
                {
                    ResultValue = FNationalitySummaryCalculation.FinishNationalityTable(ref situation);
                    FNationalitySummaryCalculation = null;
                }

                value = new TVariant(ResultValue);
                return(true);
            }

            if (StringHelper.IsSame(f, "CalculateSingleAge"))
            {
                bool ResultValue = false;

                if (FAgeSummaryCalculation != null)
                {
                    ResultValue = FAgeSummaryCalculation.CalculateSingleAge(
                        ops[1].ToDate(), ops[2].ToString(), ref situation);
                }

                value = new TVariant(ResultValue);
                return(true);
            }

            if (StringHelper.IsSame(f, "ClearAgeTable"))
            {
                FAgeSummaryCalculation = new TAgeSummaryCalculation();

                value = new TVariant(true);
                return(true);
            }

            if (StringHelper.IsSame(f, "FinishAgeTable"))
            {
                bool ResultValue = false;

                if (FAgeSummaryCalculation != null)
                {
                    ResultValue            = FAgeSummaryCalculation.FinishAgeTable(ref situation);
                    FAgeSummaryCalculation = null;
                }

                value = new TVariant(ResultValue);
                return(true);
            }

            if (StringHelper.IsSame(f, "CalculateSingleConferenceRole"))
            {
                bool ResultValue = false;

                if (FConferenceRoleCalculation != null)
                {
                    ResultValue = FConferenceRoleCalculation.CalculateSingleConferenceRole(
                        ops[1].ToString(), ops[2].ToInt64(), ops[3].ToString(), ops[4].ToInt64(),
                        ops[5].ToInt64());
                }

                value = new TVariant(ResultValue);
                return(true);
            }

            if (StringHelper.IsSame(f, "ClearConferenceRoleTable"))
            {
                FConferenceRoleCalculation = new TConferenceRoleCalculation();

                value = new TVariant(true);
                return(true);
            }

            if (StringHelper.IsSame(f, "FinishConferenceRoleTable"))
            {
                bool ResultValue = false;

                if (FConferenceRoleCalculation != null)
                {
                    ResultValue = FConferenceRoleCalculation.FinishConferenceRoleTable(
                        ops[1].ToString(), ref situation);
                    FConferenceRoleCalculation = null;
                }

                value = new TVariant(ResultValue);
                return(true);
            }

            if (StringHelper.IsSame(f, "InitFieldCostsCalculation"))
            {
                if (FConferenceFieldCalculation == null)
                {
                    FConferenceFieldCalculation = new TConferenceFieldCalculation(ref situation,
                                                                                  ops[1].ToInt64());
                }

                value = new TVariant(true);
                return(true);
            }

            if (StringHelper.IsSame(f, "ClearFieldCostsCalculation"))
            {
                if (FConferenceFieldCalculation != null)
                {
                    FConferenceFieldCalculation = null;
                }

                value = new TVariant(true);
                return(true);
            }

            if (StringHelper.IsSame(f, "PrintFieldFinancialCosts"))
            {
                bool ResultValue = false;

                if (FConferenceFieldCalculation != null)
                {
                    ResultValue = FConferenceFieldCalculation.PrintFieldFinancialCosts(ref situation, ops[1].ToString());
                }

                value = new TVariant(ResultValue);
                return(true);
            }

            if (StringHelper.IsSame(f, "PrintFinancialSignOffLines"))
            {
                bool ResultValue = false;

                if (FConferenceFieldCalculation != null)
                {
                    ResultValue = FConferenceFieldCalculation.PrintFinancialSignOffLines(ref situation, ops[1].ToString());
                }

                value = new TVariant(ResultValue);
                return(true);
            }

            if (StringHelper.IsSame(f, "PrintAttendanceSignOffLines"))
            {
                bool ResultValue = false;

                if (FConferenceFieldCalculation != null)
                {
                    ResultValue = FConferenceFieldCalculation.PrintAttendanceSignOffLines(ref situation, ops[1].ToString());
                }

                value = new TVariant(ResultValue);
                return(true);
            }

            if (StringHelper.IsSame(f, "PrintEmptyLineInFieldReport"))
            {
                bool ResultValue = false;

                if (FConferenceFieldCalculation != null)
                {
                    ResultValue = FConferenceFieldCalculation.PrintEmptyLineInFieldReport(ref situation);
                }

                value = new TVariant(ResultValue);
                return(true);
            }

            if (StringHelper.IsSame(f, "CalculateOneAttendeeFieldCost"))
            {
                bool ResultValue = false;

                if (FConferenceFieldCalculation != null)
                {
                    String FinanceDetails;
                    String Accommodation;

                    ResultValue = FConferenceFieldCalculation.CalculateOneAttendeeFieldCost(ref situation,
                                                                                            ops[1].ToInt32(), ops[2].ToInt64(), ops[3].ToInt32(), ops[4].ToInt64(),
                                                                                            ops[5].ToInt64(),
                                                                                            ops[6].ToString(), ops[7].ToDate(), out FinanceDetails, out Accommodation);

                    situation.GetParameters().Add("AccommodationCost", new TVariant(Accommodation));
                    situation.GetParameters().Add("FinanceDetails", new TVariant(FinanceDetails));
                }

                value = new TVariant(ResultValue);
                return(true);
            }

            if (StringHelper.IsSame(f, "GetExtraCosts"))
            {
                bool ResultValue = false;

                if (FConferenceFieldCalculation != null)
                {
                    ResultValue = FConferenceFieldCalculation.GetExtraCosts(ref situation, ops[1].ToInt64(),
                                                                            ops[2].ToInt64());
                }

                value = new TVariant(ResultValue);
                return(true);
            }

            if (StringHelper.IsSame(f, "HasReportSendingField"))
            {
                bool ResultValue = false;

                if (FConferenceFieldCalculation != null)
                {
                    ResultValue = FConferenceFieldCalculation.HasReportSendingField(ops[1].ToString());
                }

                value = new TVariant(ResultValue);
                return(true);
            }

            if (StringHelper.IsSame(f, "HasAttendeeReceivingField"))
            {
                bool ResultValue = false;

                if (FConferenceFieldCalculation != null)
                {
                    ResultValue = FConferenceFieldCalculation.HasAttendeeReceivingField(ref situation, ops[1].ToInt64(),
                                                                                        ops[2].ToString());
                }

                value = new TVariant(ResultValue);
                return(true);
            }

            if (StringHelper.IsSame(f, "HasFieldReportDiscount"))
            {
                bool ResultValue = false;

                if (FConferenceFieldCalculation != null)
                {
                    ResultValue = FConferenceFieldCalculation.HasFieldReportDiscount(ops[1].ToString());
                }

                value = new TVariant(ResultValue);
                return(true);
            }

            /*
             * if (isSame(f, 'doSomething')) then
             * begin
             * value := new TVariant();
             * doSomething(ops[1].ToInt(), ops[2].ToString(), ops[3].ToString());
             * exit;
             * end;
             */
            value = new TVariant();
            return(false);
        }
Example #21
0
        /// <summary>
        /// Copies the result of the FConferenceRoleTable to report.
        /// </summary>
        /// <param name="ASelectedOutreachOptions">csv list of the selected outreach options</param>
        /// <param name="ASituation">current report situation</param>
        /// <returns></returns>
        public bool FinishConferenceRoleTable(String ASelectedOutreachOptions, ref TRptSituation ASituation)
        {
            ASituation.GetResults().Clear();

            if (FConferenceRoleTable == null)
            {
                return(false);
            }

            DataTable ResultTable = MakeResultTable(ASelectedOutreachOptions);

            int ChildRow = 1;

            int[] Totals = new int[] {
                0, 0, 0, 0, 0, 0
            };

            foreach (DataRow CurrentRow in ResultTable.Rows)
            {
                TVariant[] Header      = new TVariant[6];
                TVariant[] Description =
                {
                    new TVariant(), new TVariant()
                };
                TVariant[] Columns = new TVariant[6];

                for (int Counter = 0; Counter < 6; ++Counter)
                {
                    Columns[Counter] = new TVariant(CurrentRow[Counter].ToString());
                    Header[Counter]  = new TVariant();

                    if (Counter > 0)
                    {
                        Totals[Counter] = Totals[Counter] + (int)CurrentRow[Counter];
                    }
                }

                ASituation.GetResults().AddRow(0, ChildRow++, true, 1, "", "", false,
                                               Header, Description, Columns);
            }

            // Add empty Row
            TVariant[] LastHeader      = new TVariant[6];
            TVariant[] LastDescription =
            {
                new TVariant(), new TVariant()
            };
            TVariant[] LastColumns = new TVariant[6];

            for (int Counter = 0; Counter < 6; ++Counter)
            {
                LastColumns[Counter] = new TVariant(" ");
                LastHeader[Counter]  = new TVariant();
            }

            ASituation.GetResults().AddRow(0, ChildRow++, true, 1, "", "", false,
                                           LastHeader, LastDescription, LastColumns);
            // Add Total Row

            LastColumns[0] = new TVariant("Total");

            for (int Counter = 1; Counter < 6; ++Counter)
            {
                LastColumns[Counter] = new TVariant(Totals[Counter]);
            }

            ASituation.GetResults().AddRow(0, ChildRow++, true, 1, "", "", false,
                                           LastHeader, LastDescription, LastColumns);
            return(true);
        }
Example #22
0
 /// <summary>
 /// constructor
 /// </summary>
 /// <param name="situation"></param>
 public TRptUserFunctionsDate(TRptSituation situation) : base(situation)
 {
 }
        /// <summary>
        /// Get the child discount for
        /// </summary>
        /// <param name="AAge">age of the person</param>
        /// <param name="AConferenceKey">conference key</param>
        /// <param name="ACostType">Defines the type of discount (e.g. ACCOMMODATION or CONFERENCE)</param>
        /// <param name="ADiscount">discount the person gets</param>
        /// <param name="AInPercent">Type of discaount: True - discount is in percent. False - discount is the amount</param>
        /// <param name="ASituation">The current report situation</param>
        /// <returns></returns>
        public static bool GetChildDiscount(int AAge, long AConferenceKey, String ACostType,
                                            out decimal ADiscount, out bool AInPercent, ref TRptSituation ASituation)
        {
            ADiscount  = 0.0M;
            AInPercent = false;

            PcDiscountTable DiscountTable;

            PcDiscountTable TmpTable    = new PcDiscountTable();
            PcDiscountRow   TemplateRow = TmpTable.NewRowTyped(false);

            TemplateRow.ConferenceKey        = AConferenceKey;
            TemplateRow.CostTypeCode         = ACostType;
            TemplateRow.DiscountCriteriaCode = "CHILD";
            TemplateRow.Validity             = "ALWAYS";

            StringCollection OrderList = new StringCollection();

            OrderList.Add(" ORDER BY " + PcDiscountTable.GetUpToAgeDBName() + " ASC");

            DiscountTable = PcDiscountAccess.LoadUsingTemplate(TemplateRow, null, null,
                                                               ASituation.GetDatabaseConnection().Transaction, OrderList, 0, 0);

            foreach (PcDiscountRow DiscountRow in DiscountTable.Rows)
            {
                if ((!DiscountRow.IsUpToAgeNull()) &&
                    (DiscountRow.UpToAge >= AAge))
                {
                    ADiscount  = DiscountRow.Discount;
                    AInPercent = DiscountRow.Percentage;

                    return(true);
                }
            }

            return(false);
        }
        /// <summary>
        /// Copies the result of the FAgeTable to report.
        /// </summary>
        /// <returns></returns>
        public bool FinishAgeTable(ref TRptSituation ASituation)
        {
            ASituation.GetResults().Clear();

            if (FAgeTable == null)
            {
                return(false);
            }

            int ChildRow = 1;

            foreach (DataRow CurrentRow in FAgeTable.Rows)
            {
                TVariant[] Header      = new TVariant[5];
                TVariant[] Description =
                {
                    new TVariant(), new TVariant()
                };
                TVariant[] Columns = new TVariant[5];

                for (int Counter = 0; Counter < 5; ++Counter)
                {
                    Columns[Counter] = new TVariant(CurrentRow[Counter].ToString());
                    Header[Counter]  = new TVariant();
                }

                ASituation.GetResults().AddRow(0, ChildRow++, true, 2, "", "", false,
                                               Header, Description, Columns);
            }

            TVariant[] LastHeader      = new TVariant[5];
            TVariant[] LastDescription =
            {
                new TVariant(), new TVariant()
            };
            TVariant[] LastColumns = new TVariant[5];

            for (int Counter = 0; Counter < 5; ++Counter)
            {
                LastColumns[Counter] = new TVariant(" ");
                LastHeader[Counter]  = new TVariant();
            }

            ASituation.GetResults().AddRow(0, ChildRow++, true, 1, "", "", false,
                                           LastHeader, LastDescription, LastColumns);

            LastColumns[0] = new TVariant("Youngest person was born on: " + FLatestBirthday.ToString("dd-MMM-yyyy"));

            ASituation.GetResults().AddRow(0, ChildRow++, true, 1, "", "", false,
                                           LastHeader, LastDescription, LastColumns);

            LastColumns[0] = new TVariant(" ");
            ASituation.GetResults().AddRow(0, ChildRow++, true, 1, "", "", false,
                                           LastHeader, LastDescription, LastColumns);

            LastColumns[0] = new TVariant("Oldest person was born on: " + FEarliestBirthday.ToString("dd-MMM-yyyy"));

            ASituation.GetResults().AddRow(0, ChildRow++, true, 1, "", "", false,
                                           LastHeader, LastDescription, LastColumns);


            return(true);
        }
        /// <summary>
        /// Insert the values of the detail data row if we have "Detail" as report level.
        /// The detail row contains for each partner the room bookings.
        /// </summary>
        /// <param name="ANumColumns">Number of columns the report has</param>
        /// <param name="AChildRow">Index of the child row</param>
        /// <param name="ARoomName">The room name of which to add the details to the table</param>
        /// <param name="ASituation">The current report situation</param>
        /// <returns>true</returns>
        private bool InsertDetailDataRow(int ANumColumns, ref int AChildRow, string ARoomName, ref TRptSituation ASituation)
        {
            foreach (DataRow DetailRow in FAccommodationDetailTable.Rows)
            {
                if (DetailRow["RoomName"].ToString() != ARoomName)
                {
                    continue;
                }

                TVariant[] Header      = new TVariant[ANumColumns];
                TVariant[] Description =
                {
                    new TVariant(), new TVariant()
                };
                TVariant[] Columns = new TVariant[ANumColumns];

                for (int Counter = 0; Counter < ANumColumns; ++Counter)
                {
                    Columns[Counter] = new TVariant(DetailRow[Counter].ToString());
                    Header[Counter]  = new TVariant();
                }

                ASituation.GetResults().AddRow(0, AChildRow++, true, 2, "", "", false,
                                               Header, Description, Columns);
            }

            return(true);
        }
        /// <summary>
        /// Transfers the result of the accommodation table to the report results
        /// </summary>
        /// <param name="ADetailLevel">Indicator if we have a brief, full or detail accommodation report</param>
        /// <param name="ASituation">The current report situation</param>
        /// <returns>true</returns>
        public bool FinishAccomTable(String ADetailLevel, ref TRptSituation ASituation)
        {
            ASituation.GetResults().Clear();

            if (FAccommodationTable == null)
            {
                return(false);
            }

            int ChildRow   = 1;
            int NumColumns = FAccommodationTable.Columns.Count / 2;

            if (ADetailLevel == "Detail")
            {
                // Don't show the cost column if we have a detailed report
                NumColumns--;
            }

            String PreviousVenueName = "";

            DataRow[] SortedRows = FAccommodationTable.Select("", "Venue DESC");

            foreach (DataRow CurrentRow in SortedRows)
            {
                if (CurrentRow[0].ToString() == NO_ACCOMMODATION)
                {
                    // ignore the row with no accomodation here
                    continue;
                }

                if (CurrentRow["Venue"].ToString() != PreviousVenueName)
                {
                    PreviousVenueName = (String)CurrentRow["Venue"];

                    if (ChildRow > 1)
                    {
                        InsertEmptyRow(NumColumns, ChildRow++, "", ref ASituation);
                    }

                    InsertEmptyRow(NumColumns, ChildRow++, PreviousVenueName, ref ASituation);
                }

                InsertDataRow(NumColumns, ChildRow++, CurrentRow, ref ASituation);

                if (ADetailLevel == "Detail")
                {
                    InsertDetailDataRow(NumColumns, ref ChildRow, CurrentRow["RoomName"].ToString(), ref ASituation);
                }
            }

            InsertEmptyRow(NumColumns, ChildRow++, "", ref ASituation);

            foreach (DataRow CurrentRow in FAccommodationTable.Rows)
            {
                if (CurrentRow[0].ToString() != NO_ACCOMMODATION)
                {
                    continue;
                }

                InsertDataRow(NumColumns, ChildRow++, CurrentRow, ref ASituation);
                break;
            }

            if (ADetailLevel == "Full")
            {
                InsertEmptyRow(NumColumns, ChildRow++, "", ref ASituation);

                TVariant[] Header      = new TVariant[NumColumns];
                TVariant[] Description =
                {
                    new TVariant(), new TVariant()
                };
                TVariant[] Columns = new TVariant[NumColumns];

                for (int Counter = 0; Counter < NumColumns; ++Counter)
                {
                    Columns[Counter] = new TVariant();
                    Header[Counter]  = new TVariant();
                }

                Columns[0] = new TVariant("");
                Columns[1] = new TVariant("People with accommodation not allocated for their actual time at the conference:");
                ASituation.GetResults().AddRow(0, ChildRow++, true, 1, "", "", false,
                                               Header, Description, Columns);

                foreach (String NoAccom in FNoAccommodationList)
                {
                    Header         = new TVariant[NumColumns];
                    Description[0] = new TVariant();
                    Description[1] = new TVariant();
                    Columns        = new TVariant[NumColumns];

                    for (int Counter = 0; Counter < NumColumns; ++Counter)
                    {
                        Columns[Counter] = new TVariant();
                        Header[Counter]  = new TVariant();
                    }

                    Columns[0] = new TVariant("");
                    Columns[1] = new TVariant(NoAccom);
                    ASituation.GetResults().AddRow(0, ChildRow++, true, 1, "", "", false,
                                                   Header, Description, Columns);
                }
            }
            else if (ADetailLevel == "Detail")
            {
                InsertDetailDataRow(NumColumns, ref ChildRow, NO_ACCOMMODATION, ref ASituation);
            }

            return(true);
        }
        /// <summary>
        /// Insert an empty row into the report results
        /// </summary>
        /// <param name="ANumColumns">Number of columns the report has</param>
        /// <param name="AChildRow">The child row index</param>
        /// <param name="AVenueName">The first column entry</param>
        /// <param name="ASituation">The current report situation</param>
        /// <returns>true</returns>
        private bool InsertEmptyRow(int ANumColumns, int AChildRow, String AVenueName, ref TRptSituation ASituation)
        {
            TVariant[] Header      = new TVariant[ANumColumns];
            TVariant[] Description =
            {
                new TVariant(), new TVariant()
            };
            TVariant[] Columns = new TVariant[ANumColumns];

            for (int Counter = 0; Counter < ANumColumns; ++Counter)
            {
                Columns[Counter] = new TVariant(" ");
                Header[Counter]  = new TVariant();
            }

            Columns[0] = new TVariant(AVenueName);

            ASituation.GetResults().AddRow(0, AChildRow, true, 2, "", "", false,
                                           Header, Description, Columns);
            return(true);
        }