private void GetDataFromControls(PmGeneralApplicationRow ARow, PmShortTermApplicationRow AEventAppRow) { ucoEvent.GetDetails(FApplicationDS.PmGeneralApplication[0]); ucoApplicant.GetDetails(FApplicationDS.PmGeneralApplication[0]); ucoTravel.GetDetails(FApplicationDS.PmGeneralApplication[0]); DataUtilities.CopyAllColumnValues(FApplicationDS.PmGeneralApplication[0], ARow); DataUtilities.CopyAllColumnValues(FApplicationDS.PmShortTermApplication[0], AEventAppRow); }
private void EditApplication(System.Object sender, EventArgs e) { PmShortTermApplicationRow SelectedRow = GetSelectedApplication(); // Open the selected partner's Partner Edit screen at Personnel Applications TFrmPartnerEdit frm = new TFrmPartnerEdit(FPetraUtilsObject.GetForm()); frm.SetParameters(TScreenMode.smEdit, SelectedRow.PartnerKey, TPartnerEditTabPageEnum.petpPersonnelApplications); frm.Show(); frm.SelectApplication(SelectedRow.ApplicationKey, SelectedRow.RegistrationOffice); }
/// <summary> /// Adds one partner to the result which has no room booking at all. /// </summary> /// <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="AGender">Gender of the current person to examine</param> /// <param name="APartnerName">Name of the current person</param> /// <returns></returns> private bool AddNoRoomBooking(PmShortTermApplicationRow AShortTermRow, DateTime AFromDate, DateTime AToDate, char AGender, string APartnerName) { int RoomRow = 0; bool FirstDayOfNoAccom = true; TimeSpan CheckLength = AToDate.Subtract(AFromDate); int DaysNumber = CheckLength.Days; int MaxCollumns = FAccommodationTable.Columns.Count - 2; DataRow DetailedRow = FAccommodationDetailTable.NewRow(); DetailedRow["RoomName"] = NO_ACCOMMODATION; DetailedRow["PartnerName"] = " " + APartnerName; // Check each day if the partner is at the conference for (int Counter = 0; Counter <= DaysNumber; ++Counter) { DateTime CurrentDay = AFromDate.AddDays(Counter); if ((CurrentDay >= AShortTermRow.Arrival) && (CurrentDay < AShortTermRow.Departure)) { // the partner is here at this date but has no booking 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]); DetailedRow[Counter + 1] = "**"; if (FirstDayOfNoAccom) { AddToNoAccomList(AShortTermRow.PartnerKey, APartnerName, CurrentDay); FirstDayOfNoAccom = false; } } } } FAccommodationDetailTable.Rows.Add(DetailedRow); return(true); }
/// <summary> /// if attendee is not valid anymore, the attendee should be removed from pc_attendee table /// </summary> /// <returns></returns> private static bool IsAttendeeValid(ConferenceApplicationTDS AMainDS, string AOutreachPrefix, Int64 AAttendeeKey) { PmShortTermApplicationRow ShortTermRow = null; foreach (PmShortTermApplicationRow Row in AMainDS.PmShortTermApplication.Rows) { if ((Row.PartnerKey == AAttendeeKey) && (AOutreachPrefix.Length >= 5) && (Row.ConfirmedOptionCode.Substring(0, 5) == AOutreachPrefix.Substring(0, 5))) { ShortTermRow = Row; break; } } if (ShortTermRow == null) { return(false); } if (ShortTermRow.StBasicDeleteFlag) { return(false); } PmGeneralApplicationRow GeneralAppRow = (PmGeneralApplicationRow)AMainDS.PmGeneralApplication.Rows.Find( new object[] { ShortTermRow.PartnerKey, ShortTermRow.ApplicationKey, ShortTermRow.RegistrationOffice }); if (GeneralAppRow == null) { return(false); } if (GeneralAppRow.GenAppDeleteFlag) { return(false); } if (!(GeneralAppRow.GenApplicationStatus.StartsWith("H") || GeneralAppRow.GenApplicationStatus.StartsWith("A"))) { return(false); } return(true); }
/// <summary> /// add a new short term application /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void NewRowShortTermApp(System.Object sender, EventArgs e) { // Clear any validation errors so that the following call to ValidateAllData starts with a 'clean slate'. FPetraUtilsObject.VerificationResultCollection.Clear(); if (ValidateAllData(true, TErrorProcessingMode.Epm_IgnoreNonCritical)) { // we create the table locally, no dataset IndividualDataTDSPmGeneralApplicationRow NewRowGeneralApp = FMainDS.PmGeneralApplication.NewRowTyped(true); PmShortTermApplicationRow NewRowShortTermApp = FMainDS.PmShortTermApplication.NewRowTyped(true); NewRowGeneralApp.PartnerKey = FMainDS.PPerson[0].PartnerKey; NewRowGeneralApp.ApplicationKey = GetNextApplicationKey(); NewRowGeneralApp.RegistrationOffice = TSystemDefaults.GetSiteKeyDefault(); NewRowGeneralApp.GenAppDate = DateTime.Today; NewRowGeneralApp.ApplicationForEventOrField = Catalog.GetString("Event"); //TODO temp, needs to be changed NewRowGeneralApp.AppTypeName = "CONFERENCE"; NewRowGeneralApp.OldLink = TSystemDefaults.GetSiteKeyDefault().ToString() + ";" + NewRowGeneralApp.ApplicationKey.ToString(); NewRowGeneralApp.GenApplicantType = "Participant"; NewRowShortTermApp.PartnerKey = NewRowGeneralApp.PartnerKey; NewRowShortTermApp.ApplicationKey = NewRowGeneralApp.ApplicationKey; NewRowShortTermApp.RegistrationOffice = NewRowGeneralApp.RegistrationOffice; NewRowShortTermApp.StAppDate = NewRowGeneralApp.GenAppDate; //TODO temp, needs to be changed NewRowShortTermApp.StApplicationType = "A"; NewRowShortTermApp.StBasicOutreachId = NewRowGeneralApp.OldLink; FMainDS.PmGeneralApplication.Rows.Add(NewRowGeneralApp); FMainDS.PmShortTermApplication.Rows.Add(NewRowShortTermApp); FPetraUtilsObject.SetChangedFlag(); grdDetails.DataSource = null; grdDetails.DataSource = new DevAge.ComponentModel.BoundDataView(FMainDS.PmGeneralApplication.DefaultView); SelectDetailRowByDataTableIndex(FMainDS.PmGeneralApplication.Rows.Count - 1); } }
private void ShowData(PmGeneralApplicationRow AGeneralAppRow, PmShortTermApplicationRow AEventAppRow) { // clear dataset and create a copy of the row to be displayed so Dataset contains only one set of records FApplicationDS.PmShortTermApplication.Rows.Clear(); FApplicationDS.PmGeneralApplication.Rows.Clear(); PmGeneralApplicationRow GeneralAppRowCopy = (PmGeneralApplicationRow)FApplicationDS.PmGeneralApplication.NewRow(); PmShortTermApplicationRow EventAppRowCopy = (PmShortTermApplicationRow)FApplicationDS.PmShortTermApplication.NewRow(); DataUtilities.CopyAllColumnValues(AGeneralAppRow, GeneralAppRowCopy); DataUtilities.CopyAllColumnValues(AEventAppRow, EventAppRowCopy); FApplicationDS.PmGeneralApplication.Rows.Add(GeneralAppRowCopy); FApplicationDS.PmShortTermApplication.Rows.Add(EventAppRowCopy); ucoEvent.ShowDetails(GeneralAppRowCopy); ucoApplicant.ShowDetails(GeneralAppRowCopy); ucoTravel.ShowDetails(GeneralAppRowCopy); }
private void ShowData(PmGeneralApplicationRow AGeneralAppRow, PmShortTermApplicationRow AEventAppRow) { // clear dataset and create a copy of the row to be displayed so Dataset contains only one set of records FApplicationDS.PmShortTermApplication.Rows.Clear(); FApplicationDS.PmGeneralApplication.Rows.Clear(); PmGeneralApplicationRow GeneralAppRowCopy = (PmGeneralApplicationRow)FApplicationDS.PmGeneralApplication.NewRow(); PmShortTermApplicationRow EventAppRowCopy = (PmShortTermApplicationRow)FApplicationDS.PmShortTermApplication.NewRow(); DataUtilities.CopyAllColumnValues(AGeneralAppRow, GeneralAppRowCopy); DataUtilities.CopyAllColumnValues(AEventAppRow, EventAppRowCopy); FApplicationDS.PmGeneralApplication.Rows.Add(GeneralAppRowCopy); FApplicationDS.PmShortTermApplication.Rows.Add(EventAppRowCopy); // The row in the data set will be 'Added', which means that some of our validation will not give the correct result. FApplicationDS.PmGeneralApplication.AcceptChanges(); FApplicationDS.PmShortTermApplication.AcceptChanges(); ucoEvent.ShowDetails(GeneralAppRowCopy); ucoApplicant.ShowDetails(GeneralAppRowCopy); ucoTravel.ShowDetails(GeneralAppRowCopy); }
/// <summary> /// /// </summary> /// <param name="ASituation"></param> /// <param name="AShortTermerRow">The row of the attendee from the personnel short termer table</param> /// <param name="AOutreachType"></param> /// <returns></returns> private bool DetermineConferenceBasicCharges(ref TRptSituation ASituation, ref PmShortTermApplicationRow AShortTermerRow, String AOutreachType) { FAttendeeStartDate = FConferenceStartDate; FAttendeeEndDate = FConferenceEndDate; PcConferenceCostTable ConferenceCostTable; ConferenceCostTable = PcConferenceCostAccess.LoadByPrimaryKey(FConferenceKey, FAttendeeDays, ASituation.GetDatabaseConnection().Transaction); if (ConferenceCostTable.Rows.Count > 0) { FConferenceRate = ((PcConferenceCostRow)ConferenceCostTable.Rows[0]).Charge; } else { FConferenceRate = 0; } //Find the outreach length for this individual // use the confirmed option code (the last two characters should give the number of days FAttendeeDays = 0; long OutreachOption = 0; FIsCongressOnly = false; FAttendeeDays = GetConferenceLengthFromConferenceCode(AShortTermerRow.ConfirmedOptionCode); if (FAttendeeDays > 0) { OutreachOption = AShortTermerRow.StConfirmedOption; } if (FAttendeeDays == 0) { // None of the options has given us a valid number of days so start with the conference length FAttendeeDays = FConferenceDays; OutreachOption = FConferenceKey; } if (FIsCongressOnly && (AOutreachType != "CNGRSS")) { GetCongressOptionRates(ref ASituation, OutreachOption, ref AShortTermerRow); } return true; }
/// <summary> /// Display data in control based on data from Rows /// </summary> /// <param name="AGeneralAppRow"></param> /// <param name="AEventAppRow"></param> public void ShowDetails(PmGeneralApplicationRow AGeneralAppRow, PmShortTermApplicationRow AEventAppRow) { ShowData(AGeneralAppRow, AEventAppRow); }
/// <summary> /// Read data from controls into Row parameters /// </summary> /// <param name="ARow"></param> /// <param name="AEventAppRow"></param> public void GetDetails(PmGeneralApplicationRow ARow, PmShortTermApplicationRow AEventAppRow) { GetDataFromControls(ARow, AEventAppRow); }
/// <summary> /// Get the missing information of a short term application partner. /// This could be Passport, Date of Birth, Gender, Mother Tongue, Emergency Contact, Event, Travel information /// </summary> /// <param name="APartnerKey">Partner Key</param> /// <param name="AApplicationKey">Application Key</param> /// <param name="ARegistrationOffice">Registration Office</param> /// <returns>String of all the missing informations for this partner and application</returns> private String GetMissingInfo(Int64 APartnerKey, int AApplicationKey, Int64 ARegistrationOffice) { String MissingInfo = ""; PmPassportDetailsTable PassportTable; PPersonTable PersonTable; PPartnerTable PartnerTable; PPartnerRelationshipTable PartnerRelationshipTable; PmShortTermApplicationTable ShortTermApplicationTable; // Check for passport Details PassportTable = PmPassportDetailsAccess.LoadViaPPerson(APartnerKey, situation.GetDatabaseConnection().Transaction); bool PassportDetailMissing = true; for (int Counter = 0; Counter < PassportTable.Rows.Count; ++Counter) { PmPassportDetailsRow row = (PmPassportDetailsRow)PassportTable.Rows[Counter]; if (row.FullPassportName.Length > 0) { PassportDetailMissing = false; } } if (PassportDetailMissing) { MissingInfo += " Passport Details,"; } // Check for Date of Birth and Gender PersonTable = PPersonAccess.LoadByPrimaryKey(APartnerKey, situation.GetDatabaseConnection().Transaction); if (PassportTable.Rows.Count == 0) { MissingInfo += " Date of Birth, Gender,"; } else { PPersonRow PersonRow = (PPersonRow)PersonTable.Rows[0]; if (PersonRow.IsDateOfBirthNull()) { MissingInfo += " Date of Birth,"; } if (PersonRow.Gender == "Unknown") { MissingInfo += " Gender,"; } } // Check for mother tongue PartnerTable = PPartnerAccess.LoadByPrimaryKey(APartnerKey, situation.GetDatabaseConnection().Transaction); if (PassportTable.Rows.Count == 0) { MissingInfo += " Mother Tongue,"; } else if (((PPartnerRow)PartnerTable.Rows[0]).LanguageCode == "99") { MissingInfo += " Mother Tongue,"; } // Check for partner relationship PartnerRelationshipTable = PPartnerRelationshipAccess.LoadViaPPartnerRelationKey(APartnerKey, situation.GetDatabaseConnection().Transaction); bool HasEmergencyContact = false; for (int Counter = 0; Counter < PartnerRelationshipTable.Rows.Count; ++Counter) { PPartnerRelationshipRow Row = (PPartnerRelationshipRow)PartnerRelationshipTable.Rows[Counter]; if (Row.PartnerKey == 0) { continue; } if ((Row.RelationName == "PAREND") || (Row.RelationName == "GUARDIAN") || (Row.RelationName == "RELATIVE") || (Row.RelationName == "EMER-1") || (Row.RelationName == "EMER-2") || (Row.RelationName == "NOK-OTHER")) { HasEmergencyContact = true; break; } } if (!HasEmergencyContact) { MissingInfo += " Emergency Contact,"; } // Check for Event and Travel information ShortTermApplicationTable = PmShortTermApplicationAccess.LoadByPrimaryKey(APartnerKey, AApplicationKey, ARegistrationOffice, situation.GetDatabaseConnection().Transaction); bool HasEvent = false; bool HasTravelInfo = false; for (int Counter = 0; Counter < ShortTermApplicationTable.Rows.Count; ++Counter) { PmShortTermApplicationRow Row = (PmShortTermApplicationRow)ShortTermApplicationTable.Rows[Counter]; if (Row.ConfirmedOptionCode != "") { HasEvent = true; } if ((!Row.IsArrivalNull()) && (!Row.IsDepartureNull())) { HasTravelInfo = true; } } if (!HasEvent) { MissingInfo += " Event,"; } if (!HasTravelInfo) { MissingInfo += "Travel Information,"; } // remove the last , if (MissingInfo.Length > 0) { MissingInfo.Remove(MissingInfo.Length - 1); } return(MissingInfo); }
/// <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> /// Puts the calculated results of one attendee to the FResult data table /// </summary> /// <param name="AField"></param> /// <param name="AAge"></param> /// <param name="AShortTermerRow">The row of the attendee from the personnel short termer table</param> /// <param name="ASituation"></param> /// <returns></returns> private bool AddCalculationsToResultTable(String AField, int AAge, PmShortTermApplicationRow AShortTermerRow, ref TRptSituation ASituation) { int ResultTableRowIndex = -1; Char RowType = '?'; ResultTableRowIndex = GetResultTableRowIndex(AField, ref RowType, AAge, ref ASituation); if (ResultTableRowIndex >= FResultDataTable.Rows.Count) { TLogging.Log("Can't add calculations to the result table"); return false; } DataRow CurrentRow = FResultDataTable.Rows[ResultTableRowIndex]; decimal TotalFees = 0; // Add the costs CurrentRow["Conference Fees"] = (decimal)CurrentRow["Conference Fees"] + FCongressCosts + FPreConferenceCosts + FPostConferenceCosts; CurrentRow["Outreach Fees"] = (decimal)CurrentRow["Outreach Fees"] + FOutreachCosts; CurrentRow["Supplement"] = (decimal)CurrentRow["Supplement"] + FSupportCost; CurrentRow["Extra Costs"] = (decimal)CurrentRow["Extra Costs"] + FExtraCost; CurrentRow["Accommodation"] = (decimal)CurrentRow["Accommodation"] + FAccommodationCosts + FPreAccommodationCosts + FPostAccommodationCosts; TotalFees = FCongressCosts + FPreConferenceCosts + FPostConferenceCosts + FOutreachCosts + FSupportCost + FExtraCost + FAccommodationCosts + FPreAccommodationCosts + FPostAccommodationCosts; CurrentRow["Total Fees"] = (decimal)CurrentRow["Total Fees"] + TotalFees; // Add the counts of the attendees CurrentRow["Total"] = (Int32)CurrentRow["Total"] + 1; if (FIsCongressVolunteer) { CurrentRow["Congress Volunteer"] = (Int32)CurrentRow["Congress Volunteer"] + 1; } else if (FIsCongressOnly) { CurrentRow["Congress Only"] = (Int32)CurrentRow["Congress Only"] + 1; } else if (FIsOutreachOnly) { CurrentRow["Outreach Only"] = (Int32)CurrentRow["Outreach Only"] + 1; } else if (FIsCongressRole) { CurrentRow["Congress Special Role"] = (Int32)CurrentRow["Congress Special Role"] + 1; } AddCalculationsToTotalRow(AField, TotalFees, ref ASituation); return true; }
private static void CreateShortTermApplication(XmlNode ANode, Int64 APartnerKey, ref PartnerImportExportTDS AMainDS, TDBTransaction ATransaction) { String strEventKey = TXMLParser.GetAttribute(ANode, MPartnerConstants.PARTNERIMPORT_EVENTKEY); long EventKey = -1; if (strEventKey.Length > 0) { try { EventKey = long.Parse(strEventKey); } catch (System.FormatException) { AddVerificationResult("Bad number format in EventKey: " + strEventKey); } if (!PUnitAccess.Exists(EventKey, ATransaction)) { AddVerificationResult("EventKey not known - application cannot be imported: " + EventKey); return; } PmGeneralApplicationRow GenAppRow = AMainDS.PmGeneralApplication.NewRowTyped(); GenAppRow.PartnerKey = APartnerKey; GenAppRow.ApplicationKey = (int)DBAccess.GDBAccessObj.GetNextSequenceValue("seq_application", ATransaction); GenAppRow.OldLink = TSystemDefaults.GetSystemDefault(SharedConstants.SYSDEFAULT_SITEKEY, "") + ";" + GenAppRow.ApplicationKey.ToString(); GenAppRow.RegistrationOffice = DomainManager.GSiteKey; // When this is imported, RegistrationOffice can't be null. GenAppRow.GenAppDate = DateTime.Now; GenAppRow.AppTypeName = TXMLParser.GetAttribute(ANode, MPartnerConstants.PARTNERIMPORT_APPTYPE); GenAppRow.GenApplicationStatus = TXMLParser.GetAttribute(ANode, MPartnerConstants.PARTNERIMPORT_APPSTATUS); GenAppRow.Comment = TXMLParser.GetAttribute(ANode, MPartnerConstants.PARTNERIMPORT_APPCOMMENTS); PmShortTermApplicationRow ShortTermRow = AMainDS.PmShortTermApplication.NewRowTyped(); ShortTermRow.PartnerKey = APartnerKey; ShortTermRow.ApplicationKey = GenAppRow.ApplicationKey; ShortTermRow.RegistrationOffice = GenAppRow.RegistrationOffice; // When this is imported, RegistrationOffice can't be null. ShortTermRow.StBasicOutreachId = "Unused field"; // This field is scheduled for deletion, but NOT NULL now. ShortTermRow.StAppDate = DateTime.Now; ShortTermRow.StApplicationType = GenAppRow.AppTypeName; ShortTermRow.StConfirmedOption = EventKey; String TimeString = ""; try { TimeString = TXMLParser.GetAttribute(ANode, MPartnerConstants.PARTNERIMPORT_ARRIVALDATE); if (TimeString.Length > 0) { ShortTermRow.Arrival = DateTime.Parse(TimeString); } TimeString = TXMLParser.GetAttribute(ANode, MPartnerConstants.PARTNERIMPORT_DEPARTUREDATE); if (TimeString.Length > 0) { ShortTermRow.Departure = DateTime.Parse(TimeString); } } catch (System.FormatException) { AddVerificationResult("Bad date format in Application: " + TimeString); } DateTime TempTime; TimeString = TXMLParser.GetAttribute(ANode, MPartnerConstants.PARTNERIMPORT_ARRIVALTIME); if (TimeString.Length > 0) { try { TempTime = DateTime.Parse(TimeString); ShortTermRow.ArrivalHour = TempTime.Hour; ShortTermRow.ArrivalMinute = TempTime.Minute; } catch (System.FormatException) { AddVerificationResult("Bad time format in Application: " + TimeString); } } TimeString = TXMLParser.GetAttribute(ANode, MPartnerConstants.PARTNERIMPORT_DEPARTURETIME); if (TimeString.Length > 0) { try { TempTime = DateTime.Parse(TimeString); ShortTermRow.DepartureHour = TempTime.Hour; ShortTermRow.DepartureMinute = TempTime.Minute; } catch (System.FormatException) { AddVerificationResult("Bad time format in Application: " + TimeString); } } ShortTermRow.OutreachRole = TXMLParser.GetAttribute(ANode, MPartnerConstants.PARTNERIMPORT_EVENTROLE); String ChargedField = TXMLParser.GetAttribute(ANode, MPartnerConstants.PARTNERIMPORT_CHARGEDFIELD); if (ChargedField.Length > 0) { try { ShortTermRow.StFieldCharged = long.Parse(ChargedField); } catch { AddVerificationResult("Bad number format in ChargedField: " + ChargedField); } } AMainDS.PmGeneralApplication.Rows.Add(GenAppRow); AMainDS.PmShortTermApplication.Rows.Add(ShortTermRow); AddVerificationResult("Application Record Created.", TResultSeverity.Resv_Status); } }
/// <summary> /// Returns the number of days the attendee is on the conference. /// </summary> /// <param name="ASituation"></param> /// <param name="AShortTermerRow">The row of the attendee from the personnel short termer table</param> /// <param name="AArrivalDate"></param> /// <param name="ADepartureDate"></param> /// <returns></returns> private int GetDaysAtCongress(ref TRptSituation ASituation, PmShortTermApplicationRow AShortTermerRow, DateTime AArrivalDate, DateTime ADepartureDate) { int Nights = 0; if (AArrivalDate.CompareTo(FAttendeeStartDate) >= 0) { if (ADepartureDate.CompareTo(FConferenceEndDate) <= 0) { Nights = GetRoomAllocatedNightsBetween(ref ASituation, AShortTermerRow.PartnerKey, AArrivalDate, ADepartureDate); } else { Nights = GetRoomAllocatedNightsBetween(ref ASituation, AShortTermerRow.PartnerKey, AArrivalDate, FAttendeeEndDate); } } else { if (ADepartureDate.CompareTo(FAttendeeEndDate) <= 0) { Nights = GetRoomAllocatedNightsBetween(ref ASituation, AShortTermerRow.PartnerKey, FAttendeeStartDate, ADepartureDate); } else { Nights = GetRoomAllocatedNightsBetween(ref ASituation, AShortTermerRow.PartnerKey, FAttendeeStartDate, FAttendeeEndDate); } } return Nights; }
/// <summary> /// Returns the early or late charges of the attendee /// </summary> /// <param name="ASituation"></param> /// <param name="ARegistrationDate"></param> /// <param name="AShortTermerRow">The row of the attendee from the personnel short termer table</param> /// <param name="EarlyPercent"></param> /// <param name="EarlyAmount"></param> /// <param name="LatePercent"></param> /// <param name="LateAmount"></param> private void GetEarlyLateCharges(ref TRptSituation ASituation, DateTime ARegistrationDate, PmShortTermApplicationRow AShortTermerRow, out int EarlyPercent, out decimal EarlyAmount, out int LatePercent, out decimal LateAmount) { EarlyAmount = 0; EarlyPercent = 0; LateAmount = 0; LatePercent = 0; PcEarlyLateTable EarlyLateTable; EarlyLateTable = PcEarlyLateAccess.LoadViaPcConference(FConferenceKey, ASituation.GetDatabaseConnection().Transaction); foreach (PcEarlyLateRow Row in EarlyLateTable.Rows) { if ((Row.Type) && (ARegistrationDate.CompareTo(Row.Applicable) <= 0) && ((AShortTermerRow.Departure.Value.Subtract(AShortTermerRow.Arrival.Value).Days * 2) > FConferenceDays)) { // Early if (Row.AmountPercent) { EarlyAmount = Row.Amount; } else { EarlyPercent = Row.Percent; } // One record only FConferenceFlags = FConferenceFlags + "E"; break; } if ((!Row.Type) && (ARegistrationDate.CompareTo(Row.Applicable) >= 0)) { // Late if (Row.AmountPercent) { LateAmount = Row.Amount; } else { LatePercent = Row.Percent; } // One record only FConferenceFlags = FConferenceFlags + "L"; break; } } }
/// <summary> /// Adds one partner to the result which has no room booking at all. /// </summary> /// <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="AGender">Gender of the current person to examine</param> /// <param name="APartnerName">Name of the current person</param> /// <returns></returns> private bool AddNoRoomBooking(PmShortTermApplicationRow AShortTermRow, DateTime AFromDate, DateTime AToDate, char AGender, string APartnerName) { int RoomRow = 0; bool FirstDayOfNoAccom = true; TimeSpan CheckLength = AToDate.Subtract(AFromDate); int DaysNumber = CheckLength.Days; int MaxCollumns = FAccommodationTable.Columns.Count - 2; DataRow DetailedRow = FAccommodationDetailTable.NewRow(); DetailedRow["RoomName"] = NO_ACCOMMODATION; DetailedRow["PartnerName"] = " " + APartnerName; // Check each day if the partner is at the conference for (int Counter = 0; Counter <= DaysNumber; ++Counter) { DateTime CurrentDay = AFromDate.AddDays(Counter); if ((CurrentDay >= AShortTermRow.Arrival) && (CurrentDay < AShortTermRow.Departure)) { // the partner is here at this date but has no booking 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]); DetailedRow[Counter + 1] = "**"; if (FirstDayOfNoAccom) { AddToNoAccomList(AShortTermRow.PartnerKey, APartnerName, CurrentDay); FirstDayOfNoAccom = false; } } } } FAccommodationDetailTable.Rows.Add(DetailedRow); 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> /// Validates the event (short term) application record of a Person. /// </summary> /// <param name="AContext">Context that describes where the data validation failed.</param> /// <param name="ARow">The <see cref="DataRow" /> which holds the the data against which the validation is run.</param> /// <param name="AVerificationResultCollection">Will be filled with any <see cref="TVerificationResult" /> items if /// data validation errors occur.</param> /// <param name="AValidationControlsDict">A <see cref="TValidationControlsDict" /> containing the Controls that /// display data that is about to be validated.</param> /// <returns>void</returns> public static void ValidateEventApplicationManual(object AContext, PmShortTermApplicationRow ARow, ref TVerificationResultCollection AVerificationResultCollection, TValidationControlsDict AValidationControlsDict) { DataColumn ValidationColumn; TValidationControlsData ValidationControlsData; TVerificationResult VerificationResult; // Don't validate deleted DataRows if (ARow.RowState == DataRowState.Deleted) { return; } // 'Event' must be a Partner of Class 'UNIT' and must not be 0 ValidationColumn = ARow.Table.Columns[PmShortTermApplicationTable.ColumnStConfirmedOptionId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { if (ARow.IsStConfirmedOptionNull()) { VerificationResult = new TScreenVerificationResult(new TVerificationResult(AContext, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_PARTNERKEY_INVALID_NOTNULL, new string[] { ValidationControlsData.ValidationControlLabel })), ValidationColumn, ValidationControlsData.ValidationControl); } else { VerificationResult = TSharedPartnerValidation_Partner.IsValidUNITPartner( ARow.StConfirmedOption, false, THelper.NiceValueDescription( ValidationControlsData.ValidationControlLabel) + " must be set correctly.", AContext, ValidationColumn, ValidationControlsData.ValidationControl); } // Since the validation can result in different ResultTexts we need to remove any validation result manually as a call to // AVerificationResultCollection.AddOrRemove wouldn't remove a previous validation result with a different // ResultText! AVerificationResultCollection.Remove(ValidationColumn); AVerificationResultCollection.AddAndIgnoreNullValue(VerificationResult); } // 'Charged Field' must be a Partner of Class 'UNIT' // // HOWEVER, 'null' is a perfectly valid value for 'Charged Field' (according to WolfgangB). // If it is null then we must not call TSharedPartnerValidation_Partner.IsValidUNITPartner // as the attempt to retrieve 'ARow.StFieldCharged' would result in // 'System.Data.StrongTypingException("Error: DB null", null)'!!! if (!ARow.IsStFieldChargedNull()) { ValidationColumn = ARow.Table.Columns[PmShortTermApplicationTable.ColumnStFieldChargedId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { VerificationResult = TSharedPartnerValidation_Partner.IsValidUNITPartner( ARow.StFieldCharged, true, THelper.NiceValueDescription( ValidationControlsData.ValidationControlLabel) + " must be set correctly.", AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Since the validation can result in different ResultTexts we need to remove any validation result manually as a call to // AVerificationResultCollection.AddOrRemove wouldn't remove a previous validation result with a different // ResultText! AVerificationResultCollection.Remove(ValidationColumn); AVerificationResultCollection.AddAndIgnoreNullValue(VerificationResult); } } // 'Arrival Method' must not be unassignable ValidationColumn = ARow.Table.Columns[PmShortTermApplicationTable.ColumnTravelTypeToCongCodeId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { PtTravelTypeTable TravelTypeTable; PtTravelTypeRow TravelTypeRow = null; VerificationResult = null; if (!ARow.IsTravelTypeToCongCodeNull()) { TravelTypeTable = (PtTravelTypeTable)TSharedDataCache.TMPersonnel.GetCacheablePersonnelTableDelegate( TCacheablePersonTablesEnum.TransportTypeList); TravelTypeRow = (PtTravelTypeRow)TravelTypeTable.Rows.Find(ARow.TravelTypeToCongCode); // 'Arrival Method' must not be unassignable if ((TravelTypeRow != null) && TravelTypeRow.UnassignableFlag && (TravelTypeRow.IsUnassignableDateNull() || (TravelTypeRow.UnassignableDate <= DateTime.Today))) { // if 'Arrival Method' is unassignable then check if the value has been changed or if it is a new record if (TSharedValidationHelper.IsRowAddedOrFieldModified(ARow, PmShortTermApplicationTable.GetTravelTypeToCongCodeDBName())) { VerificationResult = new TScreenVerificationResult(new TVerificationResult(AContext, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_VALUEUNASSIGNABLE_WARNING, new string[] { ValidationControlsData.ValidationControlLabel, ARow.TravelTypeToCongCode })), ValidationColumn, ValidationControlsData.ValidationControl); } } } // Handle addition/removal to/from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } // 'Departure Method' must not be unassignable ValidationColumn = ARow.Table.Columns[PmShortTermApplicationTable.ColumnTravelTypeFromCongCodeId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { PtTravelTypeTable TravelTypeTable; PtTravelTypeRow TravelTypeRow = null; VerificationResult = null; if (!ARow.IsTravelTypeFromCongCodeNull()) { TravelTypeTable = (PtTravelTypeTable)TSharedDataCache.TMPersonnel.GetCacheablePersonnelTableDelegate( TCacheablePersonTablesEnum.TransportTypeList); TravelTypeRow = (PtTravelTypeRow)TravelTypeTable.Rows.Find(ARow.TravelTypeFromCongCode); // 'Departure Method' must not be unassignable if ((TravelTypeRow != null) && TravelTypeRow.UnassignableFlag && (TravelTypeRow.IsUnassignableDateNull() || (TravelTypeRow.UnassignableDate <= DateTime.Today))) { // if 'Departure Method' is unassignable then check if the value has been changed or if it is a new record if (TSharedValidationHelper.IsRowAddedOrFieldModified(ARow, PmShortTermApplicationTable.GetTravelTypeFromCongCodeDBName())) { VerificationResult = new TScreenVerificationResult(new TVerificationResult(AContext, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_VALUEUNASSIGNABLE_WARNING, new string[] { ValidationControlsData.ValidationControlLabel, ARow.TravelTypeFromCongCode })), ValidationColumn, ValidationControlsData.ValidationControl); } } } // Handle addition/removal to/from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } // 'Departure Date' must be later than 'Arrival Date' ValidationColumn = ARow.Table.Columns[PmShortTermApplicationTable.ColumnDepartureId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { VerificationResult = TDateChecks.FirstGreaterOrEqualThanSecondDate(ARow.Departure, ARow.Arrival, ValidationControlsData.ValidationControlLabel, ValidationControlsData.SecondValidationControlLabel, AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition to/removal from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } // 'Arrival Hour' must be between 0 and 24 ValidationColumn = ARow.Table.Columns[PmShortTermApplicationTable.ColumnArrivalHourId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { VerificationResult = TNumericalChecks.IsInRange(ARow.ArrivalHour, 0, 24, Catalog.GetString("Arrival Hour"), AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition/removal to/from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } // 'Arrival Minute' must be between 0 and 59 ValidationColumn = ARow.Table.Columns[PmShortTermApplicationTable.ColumnArrivalMinuteId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { VerificationResult = TNumericalChecks.IsInRange(ARow.ArrivalMinute, 0, 59, Catalog.GetString("Arrival Minute"), AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition/removal to/from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } // 'Departure Hour' must be between 0 and 24 ValidationColumn = ARow.Table.Columns[PmShortTermApplicationTable.ColumnDepartureHourId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { VerificationResult = TNumericalChecks.IsInRange(ARow.DepartureHour, 0, 24, Catalog.GetString("Departure Hour"), AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition/removal to/from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } // 'Departure Minute' must be between 0 and 59 ValidationColumn = ARow.Table.Columns[PmShortTermApplicationTable.ColumnDepartureMinuteId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { VerificationResult = TNumericalChecks.IsInRange(ARow.DepartureMinute, 0, 59, Catalog.GetString("Departure Minute"), AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition/removal to/from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } // 'Arrival Point' must not be unassignable ValidationColumn = ARow.Table.Columns[PmShortTermApplicationTable.ColumnArrivalPointCodeId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { PtArrivalPointTable ArrivalPointTable; PtArrivalPointRow ArrivalPointRow; VerificationResult = null; if ((!ARow.IsArrivalPointCodeNull()) && (ARow.ArrivalPointCode != String.Empty)) { ArrivalPointTable = (PtArrivalPointTable)TSharedDataCache.TMPersonnel.GetCacheablePersonnelTable( TCacheablePersonTablesEnum.ArrivalDeparturePointList); ArrivalPointRow = (PtArrivalPointRow)ArrivalPointTable.Rows.Find(ARow.ArrivalPointCode); // 'Arrival Point' must not be unassignable if ((ArrivalPointRow != null) && ArrivalPointRow.UnassignableFlag && (ArrivalPointRow.IsUnassignableDateNull() || (ArrivalPointRow.UnassignableDate <= DateTime.Today))) { // if 'Contact' is unassignable then check if the value has been changed or if it is a new record if (TSharedValidationHelper.IsRowAddedOrFieldModified(ARow, PmShortTermApplicationTable.GetArrivalPointCodeDBName())) { VerificationResult = new TScreenVerificationResult(new TVerificationResult(AContext, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_VALUEUNASSIGNABLE_WARNING, new string[] { ValidationControlsData.ValidationControlLabel, ARow.ArrivalPointCode })), ValidationColumn, ValidationControlsData.ValidationControl); } } } // Handle addition/removal to/from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } // 'Departure Point' must not be unassignable ValidationColumn = ARow.Table.Columns[PmShortTermApplicationTable.ColumnDeparturePointCodeId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { PtArrivalPointTable ArrivalPointTable; PtArrivalPointRow ArrivalPointRow; VerificationResult = null; if ((!ARow.IsDeparturePointCodeNull()) && (ARow.DeparturePointCode != String.Empty)) { ArrivalPointTable = (PtArrivalPointTable)TSharedDataCache.TMPersonnel.GetCacheablePersonnelTable( TCacheablePersonTablesEnum.ArrivalDeparturePointList); ArrivalPointRow = (PtArrivalPointRow)ArrivalPointTable.Rows.Find(ARow.DeparturePointCode); // 'Arrival Point' must not be unassignable if ((ArrivalPointRow != null) && ArrivalPointRow.UnassignableFlag && (ArrivalPointRow.IsUnassignableDateNull() || (ArrivalPointRow.UnassignableDate <= DateTime.Today))) { // if 'Arrival Point' is unassignable then check if the value has been changed or if it is a new record if (TSharedValidationHelper.IsRowAddedOrFieldModified(ARow, PmShortTermApplicationTable.GetDeparturePointCodeDBName())) { VerificationResult = new TScreenVerificationResult(new TVerificationResult(AContext, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_VALUEUNASSIGNABLE_WARNING, new string[] { ValidationControlsData.ValidationControlLabel, ARow.DeparturePointCode })), ValidationColumn, ValidationControlsData.ValidationControl); } } } // Handle addition/removal to/from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } //TODO: if arrival hour == 24 then arrival minute must be 0 //TODO: if departure hour == 24 then departure minute must be 0 //TODO: make sure that no other application already exists for this event and this person }
/// <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> /// Congress option within a main congress which is charged at fixed rate /// Particularly applicable to De Bron when Staff and Ladies occur /// The conference rate and arrival/departure need to be adjusted /// </summary> /// <param name="ASituation"></param> /// <param name="AOutreachOption">The unit key of the outreach</param> /// <param name="AShortTermerRow">The row of the attendee from the personnel short termer table</param> /// <returns></returns> private bool GetCongressOptionRates(ref TRptSituation ASituation, long AOutreachOption, ref PmShortTermApplicationRow AShortTermerRow) { PPartnerLocationTable PartnerLocationTable; PartnerLocationTable = PPartnerLocationAccess.LoadViaPPartner(AOutreachOption, ASituation.GetDatabaseConnection().Transaction); if (PartnerLocationTable.Rows.Count < 1) { return false; } PPartnerLocationRow PartnerLocationRow = (PPartnerLocationRow)PartnerLocationTable.Rows[0]; FAttendeeStartDate = PartnerLocationRow.DateEffective.Value; FAttendeeEndDate = PartnerLocationRow.DateGoodUntil.Value; // Update arrival and departure dates if none have been entered yet, // either in the application travel details or the actual arrival at the conference if (AShortTermerRow.IsArrivalNull()) { AShortTermerRow.Arrival = FAttendeeStartDate; } if (AShortTermerRow.IsDepartureNull()) { AShortTermerRow.Departure = FAttendeeEndDate; } PcConferenceCostTable ConferenceCostTable; ConferenceCostTable = PcConferenceCostAccess.LoadByPrimaryKey(AOutreachOption, FAttendeeDays, ASituation.GetDatabaseConnection().Transaction); if (ConferenceCostTable.Rows.Count > 0) { FConferenceRate = (decimal)ConferenceCostTable.Rows[0][PcConferenceCostTable.GetChargeDBName()]; } 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; }
/// <summary> /// method for importing data entered on the web form /// </summary> /// <returns></returns> public static string DataImportFromForm(string AFormID, string AJSONFormData, bool ASendApplicationReceivedEmail) { if (AFormID == "TestPrintingEmail") { // This is a test for printing to PDF and sending an email, no partner is created in the database. // make sure you have a photo with name data\photos\815.jpg for the photo to appear in the pdf TApplicationFormData data = (TApplicationFormData)TJsonTools.ImportIntoTypedStructure(typeof(TApplicationFormData), AJSONFormData); data.RawData = AJSONFormData; string pdfIdentifier; string pdfFilename = GeneratePDF(0815, data.registrationcountrycode, data, out pdfIdentifier); try { if (SendEmail(0815, data.registrationcountrycode, data, pdfFilename)) { // return id of the PDF pdfIdentifier string result = "{\"success\":true,\"data\":{\"pdfPath\":\"downloadPDF.aspx?pdf-id=" + pdfIdentifier + "\"}}"; return(result); } else { string message = String.Format(Catalog.GetString("We were not able to send the email to {0}"), data.email); TLogging.Log("returning: " + "{\"failure\":true, \"data\":{\"result\":\"" + message + "\"}}"); return("{\"failure\":true, \"data\":{\"result\":\"" + message + "\"}}"); } } catch (Exception e) { TLogging.Log(e.Message); TLogging.Log(e.StackTrace); } } if (AFormID == "RegisterPerson") { TApplicationFormData data = (TApplicationFormData)TJsonTools.ImportIntoTypedStructure(typeof(TApplicationFormData), AJSONFormData); data.RawData = AJSONFormData; Int64 NewPersonPartnerKey = -1; string imageTmpPath = String.Empty; try { PartnerEditTDS MainDS = new PartnerEditTDS(); // TODO: check that email is unique. do not allow email to be associated with 2 records. this would cause trouble with authentication // TODO: create a user for this partner Int64 NewFamilyPartnerKey = CreateFamily(ref MainDS, data); NewPersonPartnerKey = CreatePerson(ref MainDS, NewFamilyPartnerKey, data); CreateAddress(ref MainDS, data, NewFamilyPartnerKey); try { PartnerEditTDSAccess.SubmitChanges(MainDS); } catch (Exception Exc) { string message = "There is some critical error when saving to the database: " + Exc.ToString(); return("{\"failure\":true, \"data\":{\"result\":\"" + message + "\"}}"); } // add a record for the application ConferenceApplicationTDS ConfDS = new ConferenceApplicationTDS(); PmGeneralApplicationRow GeneralApplicationRow = ConfDS.PmGeneralApplication.NewRowTyped(); GeneralApplicationRow.RawApplicationData = AJSONFormData; GeneralApplicationRow.PartnerKey = NewPersonPartnerKey; GeneralApplicationRow.ApplicationKey = -1; GeneralApplicationRow.RegistrationOffice = data.registrationoffice; GeneralApplicationRow.GenAppDate = DateTime.Today; GeneralApplicationRow.AppTypeName = MConferenceConstants.APPTYPE_CONFERENCE; // TODO pm_st_basic_camp_identifier_c is quite strange. will there be an overflow soon? // see ticket https://sourceforge.net/apps/mantisbt/openpetraorg/view.php?id=161 GeneralApplicationRow.OldLink = ""; GeneralApplicationRow.GenApplicantType = ""; GeneralApplicationRow.GenApplicationStatus = MConferenceConstants.APPSTATUS_ONHOLD; ConfDS.PmGeneralApplication.Rows.Add(GeneralApplicationRow); PmShortTermApplicationRow ShortTermApplicationRow = ConfDS.PmShortTermApplication.NewRowTyped(); ShortTermApplicationRow.PartnerKey = NewPersonPartnerKey; ShortTermApplicationRow.ApplicationKey = -1; ShortTermApplicationRow.RegistrationOffice = data.registrationoffice; ShortTermApplicationRow.StAppDate = DateTime.Today; ShortTermApplicationRow.StApplicationType = MConferenceConstants.APPTYPE_CONFERENCE; ShortTermApplicationRow.StBasicOutreachId = GeneralApplicationRow.OldLink; ShortTermApplicationRow.StCongressCode = data.role; ShortTermApplicationRow.ConfirmedOptionCode = data.eventidentifier; ShortTermApplicationRow.StConfirmedOption = Convert.ToInt64(data.eventpartnerkey); ShortTermApplicationRow.StFieldCharged = data.registrationoffice; ShortTermApplicationRow.Arrival = data.dateofarrival; ShortTermApplicationRow.Departure = data.dateofdeparture; ConfDS.PmShortTermApplication.Rows.Add(ShortTermApplicationRow); // TODO ApplicationForms try { ConferenceApplicationTDSAccess.SubmitChanges(ConfDS); } catch (Exception Exc) { string message = "There is some critical error when saving to the database: " + Exc.ToString(); return("{\"failure\":true, \"data\":{\"result\":\"" + message + "\"}}"); } // process Photo imageTmpPath = TAppSettingsManager.GetValue("Server.PathTemp") + Path.DirectorySeparatorChar + Path.GetFileName(data.imageid); if (File.Exists(imageTmpPath)) { string photosPath = TAppSettingsManager.GetValue("Server.PathData") + Path.DirectorySeparatorChar + "photos"; if (!Directory.Exists(photosPath)) { Directory.CreateDirectory(photosPath); } File.Copy(imageTmpPath, photosPath + Path.DirectorySeparatorChar + NewPersonPartnerKey + Path.GetExtension(imageTmpPath).ToLower(), true); } } catch (Exception e) { TLogging.Log(e.Message); TLogging.Log(e.StackTrace); string message = "There is some critical error when saving to the database"; return("{\"failure\":true, \"data\":{\"result\":\"" + message + "\"}}"); } if (ASendApplicationReceivedEmail) { string pdfIdentifier; string pdfFilename = GeneratePDF(NewPersonPartnerKey, data.registrationcountrycode, data, out pdfIdentifier); try { if (SendEmail(NewPersonPartnerKey, data.registrationcountrycode, data, pdfFilename)) { if (File.Exists(imageTmpPath)) { // only delete the temp image after successful application. otherwise we have a problem with resending the application, because the tmp image is gone File.Delete(imageTmpPath); } // return id of the PDF pdfIdentifier string result = "{\"success\":true,\"data\":{\"pdfPath\":\"downloadPDF.aspx?pdf-id=" + pdfIdentifier + "\"}}"; return(result); } } catch (Exception e) { TLogging.Log(e.Message); TLogging.Log(e.StackTrace); } } string message2 = String.Format(Catalog.GetString("We were not able to send the email to {0}"), data.email); string result2 = "{\"failure\":true, \"data\":{\"result\":\"" + message2 + "\"}}"; if (ASendApplicationReceivedEmail) { TLogging.Log(result2); } return(result2); } else { string message = "The server does not know about a form called " + AFormID; TLogging.Log(message); return("{\"failure\":true, \"data\":{\"result\":\"" + message + "\"}}"); } }