Exemplo n.º 1
0
 /// <summary>
 /// this function should be overwritten; sets the environment for running the function
 /// </summary>
 public virtual Boolean FunctionSelector(TRptSituation ASituation, String f, TVariant[] ops, out TVariant AValue)
 {
     this.situation = ASituation;
     parameters     = situation.GetParameters();
     AValue         = null;
     return(false);
 }
Exemplo n.º 2
0
 /// <summary>
 /// this function should be overwritten; sets the environment for running the function
 /// </summary>
 public virtual Boolean FunctionSelector(TRptSituation ASituation, String f, TVariant[] ops, out TVariant AValue)
 {
     this.situation = ASituation;
     parameters = situation.GetParameters();
     AValue = null;
     return false;
 }
Exemplo n.º 3
0
        /// <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;
        }
Exemplo n.º 4
0
 /// <summary>
 /// constructor
 /// </summary>
 /// <param name="situation"></param>
 public TRptSituation(TRptSituation situation)
 {
     this.Parameters         = situation.Parameters;
     this.Results            = situation.Results;
     this.ReportStore        = situation.ReportStore;
     this.CurrentReport      = situation.CurrentReport;
     this.DatabaseConnection = situation.DatabaseConnection;
     this.Depth       = situation.Depth;
     this.column      = situation.column;
     this.LineId      = situation.LineId;
     this.ParentRowId = situation.ParentRowId;
 }
Exemplo n.º 5
0
 /// <summary>
 /// constructor
 /// </summary>
 /// <param name="situation"></param>
 /// <param name="depth"></param>
 /// <param name="column"></param>
 /// <param name="lineId"></param>
 /// <param name="parentRowId"></param>
 public TRptSituation(TRptSituation situation, int depth, int column, int lineId, int parentRowId)
 {
     this.Parameters         = situation.Parameters;
     this.Results            = situation.Results;
     this.ReportStore        = situation.ReportStore;
     this.CurrentReport      = situation.CurrentReport;
     this.DatabaseConnection = situation.DatabaseConnection;
     this.Depth       = depth;
     this.column      = column;
     this.LineId      = lineId;
     this.ParentRowId = parentRowId;
 }
        /// <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;
        }
Exemplo n.º 7
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;
        }
Exemplo n.º 8
0
 /// <summary>
 /// constructor
 /// </summary>
 /// <param name="situation"></param>
 /// <param name="depth"></param>
 /// <param name="column"></param>
 /// <param name="lineId"></param>
 /// <param name="parentRowId"></param>
 public TRptEvaluator(TRptSituation situation, int depth, int column, int lineId, int parentRowId) : base(situation, depth, column, lineId,
                                                                                                          parentRowId)
 {
 }
Exemplo n.º 9
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, "GetPartnerLabelValues"))
            {
                value = new TVariant(GetPartnerLabelValues());
                return true;
            }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            value = new TVariant();
            return false;
        }
        /// <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;
        }
        /// <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;
        }
Exemplo n.º 12
0
 /// <summary>
 /// this constructor is used when the System.Object is instantiated in other situations
 ///
 /// </summary>
 /// <returns>void</returns>
 public TRptUserFunctions(TRptSituation ASituation)
 {
     this.situation = ASituation;
     parameters     = situation.GetParameters();
 }
        /// <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;
        }
Exemplo n.º 14
0
        /// <summary>
        /// recalculate row after all the columns have been calculated already,
        /// but now the functions based on other columns are calculated.
        /// </summary>
        /// <param name="situation"></param>
        /// <param name="row"></param>
        public static void RecalculateRow(TRptSituation situation, TResult row)
        {
            int                counter;
            string             strCalculation;
            TVariant           ColumnCalc;
            TVariant           levelCalc;
            TRptDataCalcResult rptDataCalcResult;
            String             ColumnFormat;
            TVariant           value;

            for (counter = 0; counter <= row.column.Length - 1; counter += 1)
            {
                // calculation is used for display in the GUI, formula is used for adding ledgers
                ColumnCalc = situation.GetParameters().Get("param_formula", counter, -1, eParameterFit.eExact);

                if (ColumnCalc.IsZeroOrNull())
                {
                    ColumnCalc = situation.GetParameters().Get("param_calculation", counter, -1, eParameterFit.eExact);
                }

                levelCalc = situation.GetParameters().Get("param_formula", ReportingConsts.ALLCOLUMNS, row.depth, eParameterFit.eExact);

                if (levelCalc.IsZeroOrNull())
                {
                    levelCalc = situation.GetParameters().Get("param_calculation", ReportingConsts.ALLCOLUMNS, row.depth, eParameterFit.eExact);
                }

                strCalculation = "";

                if ((!ColumnCalc.IsZeroOrNull() && situation.GetReportStore().IsFunctionCalculation(situation.GetCurrentReport(), ColumnCalc.ToString())))
                {
                    // e.g. add(Column(1), Column(2))
                    strCalculation = ColumnCalc.ToString();
                }
                else if ((!levelCalc.IsZeroOrNull() &&
                          situation.GetReportStore().IsFunctionCalculation(situation.GetCurrentReport(), levelCalc.ToString())))
                {
                    // e.g. getSumLowerReport
                    strCalculation = levelCalc.ToString();
                }

                if (situation.GetReportStore().IsFunctionCalculation(situation.GetCurrentReport(), strCalculation))
                {
                    rptDataCalcResult = new TRptDataCalcResult(situation, row.depth, counter, row.childRow, row.masterRow);
                    ColumnFormat      = "";

                    if (situation.GetParameters().Exists("ColumnFormat", counter, row.depth))
                    {
                        ColumnFormat = situation.GetParameters().Get("ColumnFormat", counter, row.depth).ToString();
                    }

                    value = rptDataCalcResult.Precalculate(row.column);
                    value.ApplyFormatString(ColumnFormat);

                    if (value.ToFormattedString().Length > 0)
                    {
                        row.column[counter] = value;
                    }
                }
            }
        }
Exemplo n.º 15
0
 /// <summary>
 /// this parameterless constructor is called when the System.Object is instantiated in TRptEvaluator
 ///
 /// </summary>
 /// <returns>void</returns>
 public TRptUserFunctions()
 {
     this.situation = null;
     parameters = null;
 }
        /// <summary>
        /// Gets the different discounts for this conference
        /// (Volunteer, Omer, Pre, Post)
        /// </summary>
        /// <param name="ASituation">Current report situation. Used to get a database transacion</param>
        /// <param name="AConferenceKey">Unique partner key of the conference</param>
        /// <returns>true if succussful</returns>
        private bool DetermineConferenceDiscounts(ref TRptSituation ASituation, long AConferenceKey)
        {
            PcDiscountTable DiscountTable;

            FParticipantDiscountAccommodationPre = 0;
            FParticipantDiscountConferencePre = 0;
            FRoleDiscountAccommodationConference = 0;
            FRoleDiscountAccommodationPre = 0;
            FRoleDiscountConferenceConference = 0;
            FRoleDiscountConferencePost = 0;
            FRoleDiscountConferencePre = 0;
            FVolunteerDiscountAccommodationConference = 0;
            FVolunteerDiscountAccommodationPre = 0;
            FVolunteerDiscountConferenceConference = 0;
            FVolunteerDiscountConferencePre = 0;

            // this does not seem to be used anywhere, see Mantis #412
            // FRoleDiscountAccommodationPost = 0;

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

            foreach (PcDiscountRow Row in DiscountTable.Rows)
            {
                if (Row.DiscountCriteriaCode == "ROLE")
                {
                    if (Row.CostTypeCode == "CONFERENCE")
                    {
                        if (Row.Validity == "PRE")
                        {
                            FRoleDiscountConferencePre = Row.Discount;
                        }
                        else if (Row.Validity == "CONF")
                        {
                            FRoleDiscountConferenceConference = Row.Discount;
                        }
                        else if (Row.Validity == "POST")
                        {
                            FRoleDiscountConferencePost = Row.Discount;
                        }
                    }
                    else if (Row.CostTypeCode == "ACCOMMODATION")
                    {
                        if (Row.Validity == "PRE")
                        {
                            FRoleDiscountAccommodationPre = Row.Discount;
                        }
                        else if (Row.Validity == "CONF")
                        {
                            FRoleDiscountAccommodationConference = Row.Discount;
                        }
                        else if (Row.Validity == "POST")
                        {
                            // this does not seem to be used anywhere, see Mantis #412
                            // FRoleDiscountAccommodationPost = Row.Discount;
                        }
                    }
                }
                else if (Row.DiscountCriteriaCode == "VOL")
                {
                    if (Row.CostTypeCode == "CONFERENCE")
                    {
                        if (Row.Validity == "PRE")
                        {
                            FVolunteerDiscountConferencePre = Row.Discount;
                        }
                        else if (Row.Validity == "CONF")
                        {
                            FVolunteerDiscountConferenceConference = Row.Discount;
                        }
                    }
                    else if (Row.CostTypeCode == "ACCOMMODATION")
                    {
                        if (Row.Validity == "PRE")
                        {
                            FVolunteerDiscountAccommodationPre = Row.Discount;
                        }
                        else if (Row.Validity == "CONF")
                        {
                            FVolunteerDiscountAccommodationConference = Row.Discount;
                        }
                    }
                }
                else if (Row.DiscountCriteriaCode == "OTHER")
                {
                    if (Row.CostTypeCode == "CONFERENCE")
                    {
                        if (Row.Validity == "PRE")
                        {
                            FParticipantDiscountConferencePre = Row.Discount;
                        }
                    }
                    else if (Row.CostTypeCode == "ACCOMMODATION")
                    {
                        if (Row.Validity == "PRE")
                        {
                            FParticipantDiscountAccommodationPre = Row.Discount;
                        }
                    }
                }
            }

            return true;
        }
Exemplo n.º 17
0
        /// <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>
        /// Get the start and end date of the conference.
        /// </summary>
        /// <param name="ASituation">Current report situation. Used to get a database transacion</param>
        /// <param name="AConferenceKey">Unique partner key of the conference</param>
        /// <returns>true if succussful</returns>
        private bool DetermineConferenceDate(ref TRptSituation ASituation, long AConferenceKey)
        {
            PcConferenceTable ConferenceTable;

            ConferenceTable = PcConferenceAccess.LoadByPrimaryKey(AConferenceKey, ASituation.GetDatabaseConnection().Transaction);

            if (ConferenceTable.Rows.Count > 0)
            {
                PcConferenceRow Row = (PcConferenceRow)ConferenceTable.Rows[0];

                if (Row.IsStartNull() || Row.IsEndNull())
                {
                    TLogging.Log("Can't get start or end date of conference: " + AConferenceKey.ToString());
                    return false;
                }

                FConferenceStartDate = Row.Start.Value;
                FConferenceEndDate = Row.End.Value;
                FConferenceDays = FConferenceEndDate.Subtract(FConferenceStartDate).Days + 1;

                FConferenceCurrency = Row.CurrencyCode;
            }

            return true;
        }
        /// <summary>
        /// Determine the conference cost type. Either per day, per night, by outreach.
        /// </summary>
        /// <param name="ASituation">Current report situation. Used to get a database transacion</param>
        /// <param name="AConferenceKey">Unique partner key of the conference</param>
        /// <returns>true</returns>
        private bool DetermineConferenceCostType(ref TRptSituation ASituation, long AConferenceKey)
        {
            PcConferenceOptionTable ConferenceOptionTable;

            ConferenceOptionTable = PcConferenceOptionAccess.LoadViaPcConference(AConferenceKey, ASituation.GetDatabaseConnection().Transaction);

            FConferenceCostType = TConferenceCostTypeEnum.cctPerOutreach;

            foreach (DataRow Row in ConferenceOptionTable.Rows)
            {
                if ((String)Row[PcConferenceOptionTable.GetOptionTypeCodeDBName()] == "COST_PER_DAY")
                {
                    FConferenceCostType = TConferenceCostTypeEnum.cctPerDay;
                    break;
                }
                else if ((String)Row[PcConferenceOptionTable.GetOptionTypeCodeDBName()] == "COST_PER_NIGHT")
                {
                    FConferenceCostType = TConferenceCostTypeEnum.cctPerNight;
                }
            }

            return true;
        }
        /// <summary>
        /// Determine the conference cost charges. Either per single day or per conference
        /// </summary>
        /// <param name="ASituation">Current report situation. Used to get a database transacion</param>
        /// <param name="AConferenceKey">Unique partner key of the conference</param>
        /// <returns>true</returns>
        private bool DetermineConferenceCostCharges(ref TRptSituation ASituation, long AConferenceKey)
        {
            PcConferenceCostTable ConferenceCostTable;

            ConferenceCostTable = PcConferenceCostAccess.LoadByPrimaryKey(AConferenceKey, 1, ASituation.GetDatabaseConnection().Transaction);

            if (ConferenceCostTable.Rows.Count > 0)
            {
                FConferenceDayRate = (decimal)ConferenceCostTable.Rows[0][PcConferenceCostTable.GetChargeDBName()];
            }
            else
            {
                FConferenceDayRate = 0;
            }

            return true;
        }
Exemplo n.º 21
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;
        }
Exemplo n.º 22
0
 /// <summary>
 /// constructor
 /// </summary>
 /// <param name="situation"></param>
 /// <param name="depth"></param>
 /// <param name="column"></param>
 /// <param name="lineId"></param>
 /// <param name="parentRowId"></param>
 public TRptDataCalcResult(TRptSituation situation, int depth, int column, int lineId, int parentRowId) : base(situation, depth, column,
                                                                                                               lineId, parentRowId)
 {
 }
Exemplo n.º 23
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;
        }
Exemplo n.º 24
0
 /// <summary>
 /// constructor
 /// </summary>
 /// <param name="situation"></param>
 public TRptDataCalcResult(TRptSituation situation) : base(situation)
 {
 }
Exemplo n.º 25
0
 /// <summary>
 /// this constructor is used when the System.Object is instantiated in other situations
 ///
 /// </summary>
 /// <returns>void</returns>
 public TRptUserFunctions(TRptSituation ASituation)
 {
     this.situation = ASituation;
     parameters = situation.GetParameters();
 }
        /// <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;
        }
Exemplo n.º 27
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, "getAccountDetailAmount"))
            {
                value = GetAccountDetailAmount(ops[1].ToDecimal(), ops[2].ToBool());
                return true;
            }

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

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

            if (StringHelper.IsSame(f, "getNetBalance"))
            {
                value = new TVariant(GetNetBalance(ops[1].ToInt()), "currency");
                return true;
            }

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

            if (StringHelper.IsSame(f, "getActual"))
            {
                value = new TVariant(GetActual(ops[1].ToInt(), ops[2].ToInt(), ops[3].ToBool(), ops[4].ToString()), "currency");
                return true;
            }

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

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

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

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

            if (StringHelper.IsSame(f, "getLedgerName"))
            {
                value = new TVariant(TFinanceReportingWebConnector.GetLedgerName(ops[1].ToInt()));
                return true;
            }

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

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

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

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

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

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

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

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

            if (StringHelper.IsSame(f, "getAllAccountDescendants"))
            {
                value = new TVariant("CSV:" + GetAllAccountDescendants(ops[1].ToInt(), ops[2].ToString(), ops[3].ToString()));
                return true;
            }

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

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

            value = new TVariant();
            return false;
        }
        /// <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>
        /// 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>
        /// 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>
        /// 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;
        }
Exemplo n.º 32
0
 /// <summary>
 /// this parameterless constructor is called when the System.Object is instantiated in TRptEvaluator
 ///
 /// </summary>
 /// <returns>void</returns>
 public TRptUserFunctions()
 {
     this.situation = null;
     parameters     = null;
 }
        /// <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;
        }
Exemplo n.º 34
0
 /// <summary>
 /// constructor
 /// </summary>
 /// <param name="situation"></param>
 public TRptEvaluator(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;
        }
Exemplo n.º 36
0
 /// <summary>
 /// constructor
 /// </summary>
 /// <param name="situation"></param>
 public TRptEvaluator(TRptSituation situation) : base(situation)
 {
 }
        /// <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;
        }
Exemplo n.º 38
0
 /// <summary>
 /// constructor
 /// </summary>
 /// <param name="situation"></param>
 /// <param name="depth"></param>
 /// <param name="column"></param>
 /// <param name="lineId"></param>
 /// <param name="parentRowId"></param>
 public TRptEvaluator(TRptSituation situation, int depth, int column, int lineId, int parentRowId) : base(situation, depth, column, lineId,
                                                                                                         parentRowId)
 {
 }
        /// <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;
        }
Exemplo n.º 40
0
        /// <summary>
        /// Find the best address of a partner
        /// </summary>
        /// <param name="APartnerKey">Partner key</param>
        /// <param name="ASituation">describing the current state of the report generator</param>
        /// <param name="AAddressRow">best address</param>
        /// <returns>true if a best address was found, otherwise false</returns>
        public static bool GetPartnerBestAddressRow(long APartnerKey, TRptSituation ASituation, out PPartnerLocationRow AAddressRow)
        {
            bool FoundBestAddress = false;

            AAddressRow = null;
            PPartnerLocationTable PartnerLocationTable;

            PartnerLocationTable = new PPartnerLocationTable();

            // add special column BestAddress and Icon
            PartnerLocationTable.Columns.Add(new System.Data.DataColumn("BestAddress", typeof(Boolean)));
            PartnerLocationTable.Columns.Add(new System.Data.DataColumn("Icon", typeof(Int32)));

            // find all locations of the partner, put it into a dataset
            PartnerLocationTable = PPartnerLocationAccess.LoadViaPPartner(APartnerKey, ASituation.GetDatabaseConnection().Transaction);

            // uses Ict.Petra.Shared.MPartner.Calculations.pas, DetermineBestAddress
            Calculations.DeterminePartnerLocationsDateStatus(PartnerLocationTable, DateTime.Today);
            Calculations.DetermineBestAddress(PartnerLocationTable);

            foreach (PPartnerLocationRow row in PartnerLocationTable.Rows)
            {
                // find the row with BestAddress = 1
                if (Convert.ToInt32(row["BestAddress"]) == 1)
                {
                    AAddressRow = row;
                    FoundBestAddress = true;
                }
            }

            return FoundBestAddress;
        }