/// <summary> /// Gets the data from all UserControls on this TabControl. /// The data is stored in the DataTables/DataColumns to which the Controls /// are mapped. /// </summary> /// <returns>void</returns> public void GetDataFromControls() { ucoApplications.GetDataFromControls2(); if (!FPartnerEditTDS.Tables.Contains(PmGeneralApplicationTable.GetTableName())) { FPartnerEditTDS.Tables.Add(new PmGeneralApplicationTable()); } if (!FPartnerEditTDS.Tables.Contains(PmShortTermApplicationTable.GetTableName())) { FPartnerEditTDS.Tables.Add(new PmShortTermApplicationTable()); } if (!FPartnerEditTDS.Tables.Contains(PmYearProgramApplicationTable.GetTableName())) { FPartnerEditTDS.Tables.Add(new PmYearProgramApplicationTable()); } FPartnerEditTDS.Tables[PmShortTermApplicationTable.GetTableName()].Rows.Clear(); FPartnerEditTDS.Tables[PmShortTermApplicationTable.GetTableName()].Merge(FMainDS.PmShortTermApplication); FPartnerEditTDS.Tables[PmYearProgramApplicationTable.GetTableName()].Rows.Clear(); FPartnerEditTDS.Tables[PmYearProgramApplicationTable.GetTableName()].Merge(FMainDS.PmYearProgramApplication); FPartnerEditTDS.Tables[PmGeneralApplicationTable.GetTableName()].Rows.Clear(); FPartnerEditTDS.Tables[PmGeneralApplicationTable.GetTableName()].Merge(FMainDS.PmGeneralApplication); }
/// <summary> /// Refresh Outreach Code for applications and conference /// </summary> public static void RefreshOutreachCode(Int64 AConferenceKey) { TDBTransaction Transaction = new TDBTransaction(); bool SubmissionOK = true; PcConferenceTable ConferenceTable; PUnitTable UnitTable; PmShortTermApplicationTable ShortTermAppTable; ConferenceApplicationTDS MainDS; DBAccess.WriteTransaction( ref Transaction, ref SubmissionOK, delegate { ConferenceTable = new PcConferenceTable(); UnitTable = new PUnitTable(); ShortTermAppTable = new PmShortTermApplicationTable(); MainDS = new ConferenceApplicationTDS(); // get the conference in order to update the OutreachPrefix ConferenceTable = PcConferenceAccess.LoadByPrimaryKey(AConferenceKey, Transaction); if (ConferenceTable.Count == 0) { throw new Exception("Cannot find conference " + AConferenceKey.ToString("0000000000")); } // update OutreachPrefix in conference record in case it was changed in Unit record for event UnitTable = PUnitAccess.LoadByPrimaryKey(AConferenceKey, Transaction); if (UnitTable[0].OutreachCode.Length >= 5) { ConferenceTable[0].OutreachPrefix = UnitTable[0].OutreachCode.Substring(0, 5); } else { ConferenceTable[0].OutreachPrefix = UnitTable[0].OutreachCode; } MainDS.Merge(ConferenceTable); // update event code ShortTermAppTable = PmShortTermApplicationAccess.LoadViaPUnitStConfirmedOption(AConferenceKey, Transaction); foreach (PmShortTermApplicationRow ShortTermAppRow in ShortTermAppTable.Rows) { ShortTermAppRow.ConfirmedOptionCode = UnitTable[0].OutreachCode; } MainDS.Merge(ShortTermAppTable); MainDS.ThrowAwayAfterSubmitChanges = true; ConferenceApplicationTDSAccess.SubmitChanges(MainDS); }); }
/// <summary> /// Refresh Outreach Code for applications and conference /// </summary> public static void RefreshOutreachCode(Int64 AConferenceKey) { TDBTransaction Transaction = null; bool SubmissionOK = true; PcConferenceTable ConferenceTable; PUnitTable UnitTable; PmShortTermApplicationTable ShortTermAppTable; ConferenceApplicationTDS MainDS; DBAccess.GDBAccessObj.GetNewOrExistingAutoTransaction(IsolationLevel.Serializable, ref Transaction, ref SubmissionOK, delegate { ConferenceTable = new PcConferenceTable(); UnitTable = new PUnitTable(); ShortTermAppTable = new PmShortTermApplicationTable(); MainDS = new ConferenceApplicationTDS(); // get the conference in order to update the OutreachPrefix ConferenceTable = PcConferenceAccess.LoadByPrimaryKey(AConferenceKey, Transaction); if (ConferenceTable.Count == 0) { throw new Exception("Cannot find conference " + AConferenceKey.ToString("0000000000")); } // update OutreachPrefix in conference record in case it was changed in Unit record for event UnitTable = PUnitAccess.LoadByPrimaryKey(AConferenceKey, Transaction); if (UnitTable[0].OutreachCode.Length >= 5) { ConferenceTable[0].OutreachPrefix = UnitTable[0].OutreachCode.Substring(0, 5); } else { ConferenceTable[0].OutreachPrefix = UnitTable[0].OutreachCode; } MainDS.Merge(ConferenceTable); // update event code ShortTermAppTable = PmShortTermApplicationAccess.LoadViaPUnitStConfirmedOption(AConferenceKey, Transaction); foreach (PmShortTermApplicationRow ShortTermAppRow in ShortTermAppTable.Rows) { ShortTermAppRow.ConfirmedOptionCode = UnitTable[0].OutreachCode; } MainDS.Merge(ShortTermAppTable); MainDS.ThrowAwayAfterSubmitChanges = true; ConferenceApplicationTDSAccess.SubmitChanges(MainDS); }); }
/// <summary> /// use the permissions of the user to get all offices that this user has permissions for /// </summary> /// <returns></returns> private static List <Int64> GetRegistrationOfficeKeysOfUser(TDBTransaction ATransaction) { List <Int64> AllowedRegistrationOffices = new List <long>(); // get all offices that have registrations for this event DataTable offices = DBAccess.GDBAccessObj.SelectDT( String.Format("SELECT DISTINCT {0} FROM PUB_{1}", PmShortTermApplicationTable.GetRegistrationOfficeDBName(), PmShortTermApplicationTable.GetTableDBName()), "registrationoffice", ATransaction); // if there are no REG-... module permissions for anyone, allow all offices? this would help with a base database for testing? Int32 CountRegModules = Convert.ToInt32(DBAccess.GDBAccessObj.ExecuteScalar("SELECT COUNT(*) FROM " + SModuleTable.GetTableDBName() + " WHERE " + SModuleTable.GetModuleIdDBName() + " LIKE 'REG-%'", ATransaction)); foreach (DataRow officeRow in offices.Rows) { Int64 RegistrationOffice = Convert.ToInt64(officeRow[0]); try { if ((CountRegModules == 0) || TModuleAccessManager.CheckUserModulePermissions(String.Format("REG-{0:10}", StringHelper.PartnerKeyToStr(RegistrationOffice)))) { AllowedRegistrationOffices.Add(RegistrationOffice); } } catch (ESecurityModuleAccessDeniedException) { // no permissions for this registration office } } // the organizer has access to all attendees if (AllowedRegistrationOffices.Count > MINIMUM_OFFICES_TO_BECOME_ORGANIZER) { AllowedRegistrationOffices = new List <long>(); foreach (DataRow officeRow in offices.Rows) { Int64 RegistrationOffice = Convert.ToInt64(officeRow[0]); AllowedRegistrationOffices.Add(RegistrationOffice); } } return(AllowedRegistrationOffices); }
private void ShowAllOutreaches_CheckBox(System.Object sender, EventArgs e) { FShowAllOutreaches = !FShowAllOutreaches; DataView MyDataView = FMainDS.PmShortTermApplication.DefaultView; if (!chkShowAllOutreaches.Checked) { // filter rows so only showing applicants for selected outreach rather than the entire conference MyDataView.RowFilter = PmShortTermApplicationTable.GetConfirmedOptionCodeDBName() + " = " + "'" + FOutreachCode + "'"; } else { MyDataView.RowFilter = null; } grdApplications.DataSource = new DevAge.ComponentModel.BoundDataView(MyDataView); UpdateRecordNumberDisplay(); }
/// <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); }
private void LoadDataGrid() { FMainDS = new ApplicationTDS(); // populate dataset TRemote.MPersonnel.WebConnectors.LoadShortTermApplications(ref FMainDS, FOutreachCode); FMainDS.PmShortTermApplication.DefaultView.AllowNew = false; // sort order for grid DataView MyDataView = FMainDS.PmShortTermApplication.DefaultView; MyDataView.Sort = "p_partner_short_name_c ASC"; if (!chkShowAllOutreaches.Checked && chkShowAllOutreaches.Enabled) { // filter rows so only showing applicants for selected outreach rather than the entire conference MyDataView.RowFilter = PmShortTermApplicationTable.GetConfirmedOptionCodeDBName() + " = " + "'" + FOutreachCode + "'"; } grdApplications.DataSource = new DevAge.ComponentModel.BoundDataView(MyDataView); }
public static void FillFormDataFromApplicant(Int64 AEventPartnerKey, Int64 APartnerKey, TFormDataApplicant AFormDataApplicant, TFormLetterInfo AFormLetterInfo, TDBTransaction AReadTransaction, Int64 ASiteKey = 0, Int32 ALocationKey = 0) { TPartnerClass PartnerClass; String ShortName; TStdPartnerStatusCode PartnerStatusCode; if (AFormDataApplicant == null) { return; } if (MCommonMain.RetrievePartnerShortName(APartnerKey, out ShortName, out PartnerClass, out PartnerStatusCode, AReadTransaction)) { // first retrieve all personnel information TFormLettersPersonnelWebConnector.FillFormDataFromPersonnel(APartnerKey, AFormDataApplicant, AFormLetterInfo, AReadTransaction, ASiteKey, ALocationKey); // retrieve Applicant information PmShortTermApplicationTable ShortTermAppTable; PmShortTermApplicationRow ShortTermAppRow; PmShortTermApplicationRow template = new PmShortTermApplicationTable().NewRowTyped(false); template.PartnerKey = APartnerKey; template.StConfirmedOption = AEventPartnerKey; ShortTermAppTable = PmShortTermApplicationAccess.LoadUsingTemplate(template, AReadTransaction); if (ShortTermAppTable.Count > 0) { ShortTermAppRow = (PmShortTermApplicationRow)ShortTermAppTable.Rows[0]; AFormDataApplicant.EventPartnerKey = AEventPartnerKey.ToString("0000000000"); AFormDataApplicant.ArrivalDate = ShortTermAppRow.Arrival; AFormDataApplicant.ArrivalTime = new DateTime(ShortTermAppRow.Arrival == null ? 0 : ((DateTime)ShortTermAppRow.Arrival).Year, ShortTermAppRow.Arrival == null ? 0 : ((DateTime)ShortTermAppRow.Arrival).Month, ShortTermAppRow.Arrival == null ? 0 : ((DateTime)ShortTermAppRow.Arrival).Day, ShortTermAppRow.ArrivalHour, ShortTermAppRow.ArrivalMinute, 0); AFormDataApplicant.ArrivalFlightNumber = ShortTermAppRow.FromCongTravelInfo; AFormDataApplicant.ArrivalComment = ShortTermAppRow.ArrivalComments; AFormDataApplicant.DepartureDate = ShortTermAppRow.Departure; AFormDataApplicant.DepartureTime = new DateTime(ShortTermAppRow.Departure == null ? 0 : ((DateTime)ShortTermAppRow.Arrival).Year, ShortTermAppRow.Departure == null ? 0 : ((DateTime)ShortTermAppRow.Arrival).Month, ShortTermAppRow.Departure == null ? 0 : ((DateTime)ShortTermAppRow.Arrival).Day, ShortTermAppRow.DepartureHour, ShortTermAppRow.DepartureMinute, 0); AFormDataApplicant.DepartureFlightNumber = ShortTermAppRow.ToCongTravelInfo; AFormDataApplicant.DepartureComment = ShortTermAppRow.DepartureComments; AFormDataApplicant.EventRole = ShortTermAppRow.StCongressCode; AFormDataApplicant.CampaignType = ShortTermAppRow.ConfirmedOptionCode.Substring(5, 6); AFormDataApplicant.FellowshipGroup = ShortTermAppRow.StFgCode; TPartnerClass PartnerClassDummy = new TPartnerClass(); AFormDataApplicant.ChargedFieldKey = ShortTermAppRow.StFieldCharged.ToString("0000000000"); string chargedFieldName = ""; if (!ShortTermAppRow.IsStCurrentFieldNull()) { TPartnerServerLookups.GetPartnerShortName(ShortTermAppRow.StCurrentField, out chargedFieldName, out PartnerClassDummy); } AFormDataApplicant.SendingFieldName = chargedFieldName; /*ApplicantFormData.SendingFieldKey = ShortTermAppRow.StCurrentField.ToString("0000000000"); * * * string sendingFieldName; * TPartnerServerLookups.GetPartnerShortName(ShortTermAppRow.StCurrentField, out sendingFieldName, out PartnerClassDummy); * ApplicantFormData.SendingFieldName = sendingFieldName;*/ //TODO: SendingFieldKey & -name; ReceivingFieldKey & -name PmGeneralApplicationTable GeneralAppTable; PmGeneralApplicationRow GeneralAppRow; GeneralAppTable = PmGeneralApplicationAccess.LoadByPrimaryKey(APartnerKey, ShortTermAppRow.ApplicationKey, ShortTermAppRow.RegistrationOffice, AReadTransaction); if (GeneralAppTable.Count > 0) { GeneralAppRow = (PmGeneralApplicationRow)GeneralAppTable.Rows[0]; AFormDataApplicant.RegistrationDate = GeneralAppRow.GenAppDate; AFormDataApplicant.ApplicationComment = GeneralAppRow.Comment; } } } }
public static TSubmitChangesResult SubmitChangesServerSide(ref IndividualDataTDS AInspectDS, ref PartnerEditTDS APartnerEditInspectDS, TDBTransaction ASubmitChangesTransaction, out TVerificationResultCollection AVerificationResult) { TSubmitChangesResult SubmissionResult; PmJobAssignmentTable PmJobAssignmentTableSubmit; AVerificationResult = new TVerificationResultCollection(); if (AInspectDS != null) { SubmissionResult = TSubmitChangesResult.scrOK; // Job Assignments: make sure that jobs exist for assignments if (AInspectDS.Tables.Contains(PmJobAssignmentTable.GetTableName()) && (AInspectDS.PmJobAssignment.Rows.Count > 0)) { UmJobTable JobTableTemp = new UmJobTable(); UmJobTable JobTableSubmit = new UmJobTable(); UmJobRow JobRow; PmJobAssignmentTableSubmit = AInspectDS.PmJobAssignment; // every job_assignment_row needs to have a row that it references in um_job foreach (PmJobAssignmentRow JobAssignmentRow in PmJobAssignmentTableSubmit.Rows) { if (JobAssignmentRow.RowState != DataRowState.Deleted) { JobTableTemp = UmJobAccess.LoadByPrimaryKey(JobAssignmentRow.UnitKey, JobAssignmentRow.PositionName, JobAssignmentRow.PositionScope, JobAssignmentRow.JobKey, ASubmitChangesTransaction); // if no corresponding job record found then we need to create one // (job key was already set on client side to new value so merging back to the // client does not cause problems because of primary key change) if (JobTableTemp.Count == 0) { JobRow = (UmJobRow)JobTableSubmit.NewRow(); JobRow.UnitKey = JobAssignmentRow.UnitKey; JobRow.PositionName = JobAssignmentRow.PositionName; JobRow.PositionScope = JobAssignmentRow.PositionScope; JobRow.JobKey = JobAssignmentRow.JobKey; JobRow.FromDate = JobAssignmentRow.FromDate; JobRow.ToDate = JobAssignmentRow.ToDate; JobRow.CommitmentPeriod = "None"; JobRow.TrainingPeriod = "None"; // Need to update the JobKey field in job assignment table record from job record JobAssignmentRow.JobKey = JobRow.JobKey; JobTableSubmit.Rows.Add(JobRow); } else { // job record exists: in this case we need to update JobKey in // the Job Assignment Record from Job Row JobAssignmentRow.JobKey = ((UmJobRow)JobTableTemp.Rows[0]).JobKey; } } } // submit table with newly created jobs if (JobTableSubmit.Rows.Count > 0) { UmJobAccess.SubmitChanges(JobTableSubmit, ASubmitChangesTransaction); } } // now submit the whole dataset at once IndividualDataTDSAccess.SubmitChanges(AInspectDS); // Need to merge tables back into APartnerEditInspectDS so the updated s_modification_id_t is returned // correctly to the Partner Edit. // Unfortunately this can't be done simply by using merge method of the dataset since they are two different // types but has to be done per table. if (AInspectDS.Tables.Contains(PmSpecialNeedTable.GetTableName()) && (AInspectDS.PmSpecialNeed.Rows.Count > 0)) { APartnerEditInspectDS.Tables[PmSpecialNeedTable.GetTableName()].Merge(AInspectDS.PmSpecialNeed); } if (AInspectDS.Tables.Contains(PmPersonAbilityTable.GetTableName()) && (AInspectDS.PmPersonAbility.Rows.Count > 0)) { APartnerEditInspectDS.Tables[PmPersonAbilityTable.GetTableName()].Merge(AInspectDS.PmPersonAbility); } if (AInspectDS.Tables.Contains(PmPassportDetailsTable.GetTableName()) && (AInspectDS.PmPassportDetails.Rows.Count > 0)) { APartnerEditInspectDS.Tables[PmPassportDetailsTable.GetTableName()].Merge(AInspectDS.PmPassportDetails); } if (AInspectDS.Tables.Contains(PmPersonalDataTable.GetTableName()) && (AInspectDS.PmPersonalData.Rows.Count > 0)) { APartnerEditInspectDS.Tables[PmPersonalDataTable.GetTableName()].Merge(AInspectDS.PmPersonalData); } if (AInspectDS.Tables.Contains(PmPersonLanguageTable.GetTableName()) && (AInspectDS.PmPersonLanguage.Rows.Count > 0)) { APartnerEditInspectDS.Tables[PmPersonLanguageTable.GetTableName()].Merge(AInspectDS.PmPersonLanguage); } if (AInspectDS.Tables.Contains(PmPersonEvaluationTable.GetTableName()) && (AInspectDS.PmPersonEvaluation.Rows.Count > 0)) { APartnerEditInspectDS.Tables[PmPersonEvaluationTable.GetTableName()].Merge(AInspectDS.PmPersonEvaluation); } if (AInspectDS.Tables.Contains(PmStaffDataTable.GetTableName()) && (AInspectDS.PmStaffData.Rows.Count > 0)) { APartnerEditInspectDS.Tables[PmStaffDataTable.GetTableName()].Merge(AInspectDS.PmStaffData); } if (AInspectDS.Tables.Contains(PmPersonSkillTable.GetTableName()) && (AInspectDS.PmPersonSkill.Rows.Count > 0)) { APartnerEditInspectDS.Tables[PmPersonSkillTable.GetTableName()].Merge(AInspectDS.PmPersonSkill); } if (AInspectDS.Tables.Contains(PmPastExperienceTable.GetTableName()) && (AInspectDS.PmPastExperience.Rows.Count > 0)) { APartnerEditInspectDS.Tables[PmPastExperienceTable.GetTableName()].Merge(AInspectDS.PmPastExperience); } if (AInspectDS.Tables.Contains(PmDocumentTable.GetTableName()) && (AInspectDS.PmDocument.Rows.Count > 0)) { APartnerEditInspectDS.Tables[PmDocumentTable.GetTableName()].Merge(AInspectDS.PmDocument); } if (AInspectDS.Tables.Contains(PmJobAssignmentTable.GetTableName()) && (AInspectDS.PmJobAssignment.Rows.Count > 0)) { APartnerEditInspectDS.Tables[PmJobAssignmentTable.GetTableName()].Merge(AInspectDS.PmJobAssignment); } if (AInspectDS.Tables.Contains(PmGeneralApplicationTable.GetTableName()) && (AInspectDS.PmGeneralApplication.Rows.Count > 0)) { APartnerEditInspectDS.Tables[PmGeneralApplicationTable.GetTableName()].Merge(AInspectDS.PmGeneralApplication); } if (AInspectDS.Tables.Contains(PmShortTermApplicationTable.GetTableName()) && (AInspectDS.PmShortTermApplication.Rows.Count > 0)) { APartnerEditInspectDS.Tables[PmShortTermApplicationTable.GetTableName()].Merge(AInspectDS.PmShortTermApplication); } if (AInspectDS.Tables.Contains(PmYearProgramApplicationTable.GetTableName()) && (AInspectDS.PmYearProgramApplication.Rows.Count > 0)) { APartnerEditInspectDS.Tables[PmYearProgramApplicationTable.GetTableName()].Merge(AInspectDS.PmYearProgramApplication); } } else { TLogging.LogAtLevel(8, "TIndividualDataWebConnector.SubmitChangesServerSide: AInspectDS = nil!"); SubmissionResult = TSubmitChangesResult.scrNothingToBeSaved; } return(SubmissionResult); }
private void LoadDataGrid() { List <long> HomeOfficeKeyList = new List <long>(); FMainDS.PcAttendee.Clear(); FMainDS.PmGeneralApplication.Clear(); FMainDS.PmShortTermApplication.Clear(); FMainDS.PPartner.Clear(); // populate dataset TRemote.MConference.Conference.WebConnectors.GetConferenceApplications(ref FMainDS, FPartnerKey); // Add all homeofficekeys to list as this column will be removed from dataset foreach (PcAttendeeRow Row in FMainDS.PcAttendee.Rows) { if (Row.IsHomeOfficeKeyNull() || (Row.HomeOfficeKey == 0)) { HomeOfficeKeyList.Add(((int)Row.PartnerKey / 1000000) * 1000000); } else { HomeOfficeKeyList.Add(Row.HomeOfficeKey); } } FMainDS.PcAttendee.Columns.Add(PPartnerTable.GetPartnerShortNameDBName(), Type.GetType("System.String")); FMainDS.PcAttendee.Columns.Add(PmShortTermApplicationTable.GetStFieldChargedDBName(), Type.GetType("System.String")); FMainDS.PcAttendee.Columns.Add(PmShortTermApplicationTable.GetStCurrentFieldDBName(), Type.GetType("System.String")); // This column is removed and readded with a different type. This allows the partner short name to be displayed rather than the partner key. FMainDS.PcAttendee.Columns.Remove(PcAttendeeTable.GetHomeOfficeKeyDBName()); FMainDS.PcAttendee.Columns.Add(PcAttendeeTable.GetHomeOfficeKeyDBName(), Type.GetType("System.String")); FMainDS.PcAttendee.DefaultView.AllowNew = false; for (int Counter = 0; Counter < FMainDS.PcAttendee.Rows.Count; ++Counter) { long PartnerKey = ((PcAttendeeRow)FMainDS.PcAttendee.Rows[Counter]).PartnerKey; long HomeOfficeKey = HomeOfficeKeyList[Counter]; long StFieldCharged = 0; long StConfirmedOption = 0; foreach (PmShortTermApplicationRow Row in FMainDS.PmShortTermApplication.Rows) { if (Row.PartnerKey == PartnerKey) { if (Row.IsStFieldChargedNull() || (Row.StFieldCharged == 0)) { if (Row.IsStCurrentFieldNull() || (Row.StCurrentField == 0)) { StFieldCharged = HomeOfficeKey; } else { StFieldCharged = Row.StCurrentField; } } else { StFieldCharged = Row.StFieldCharged; } if (Row.IsStCurrentFieldNull() || (Row.StConfirmedOption == 0)) { FMainDS.PcAttendee.Rows[Counter][PmShortTermApplicationTable.GetStCurrentFieldDBName()] = ((PcAttendeeRow)FMainDS.PcAttendee.Rows[Counter]).OutreachType; } else { StConfirmedOption = Row.StConfirmedOption; } break; } } int PartnersFound = 0; foreach (PPartnerRow Row in FMainDS.PPartner.Rows) { if (Row.PartnerKey == PartnerKey) { FMainDS.PcAttendee.Rows[Counter][PPartnerTable.GetPartnerShortNameDBName()] = Row.PartnerShortName; if (PartnersFound == 3) { break; } else { PartnersFound++; } } // display partner short name rather than the partner key if ((StFieldCharged != 0) && (Row.PartnerKey == StFieldCharged)) { FMainDS.PcAttendee.Rows[Counter][PmShortTermApplicationTable.GetStFieldChargedDBName()] = Row.PartnerShortName; if (PartnersFound == 3) { break; } else { PartnersFound++; } } // display partner short name rather than the partner key if ((StConfirmedOption != 0) && (Row.PartnerKey == StConfirmedOption)) { FMainDS.PcAttendee.Rows[Counter][PmShortTermApplicationTable.GetStCurrentFieldDBName()] = Row.PartnerShortName; if (PartnersFound == 3) { break; } else { PartnersFound++; } } // display partner short name rather than the partner key if ((HomeOfficeKey != 0) && (Row.PartnerKey == HomeOfficeKey)) { FMainDS.PcAttendee.Rows[Counter][PcAttendeeTable.GetHomeOfficeKeyDBName()] = Row.PartnerShortName; if (!(Row.PartnerShortName.Length > 0)) { } if (PartnersFound == 3) { break; } else { PartnersFound++; } } } } // sort order for grid DataView MyDataView = FMainDS.PcAttendee.DefaultView; MyDataView.Sort = "p_partner_short_name_c ASC"; grdAttendees.DataSource = new DevAge.ComponentModel.BoundDataView(MyDataView); }
public static Boolean LoadApplicationsForConverting(ref ApplicationTDS AMainDS, bool AConvertTo, string AOutreachCode, bool AAllOutreaches, bool AAllEvents, string AYear) { string Query = string.Empty; ApplicationTDS MainDS = new ApplicationTDS(); String ShortTermAppTableName = AMainDS.PmShortTermApplication.TableName; List <OdbcParameter> Parameters = new List <OdbcParameter>(); TDBTransaction Transaction = null; DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction( IsolationLevel.ReadCommitted, TEnforceIsolationLevel.eilMinimum, ref Transaction, delegate { Query = "SELECT DISTINCT PUB_pm_short_term_application.*, PUB_pm_general_application.*, PUB_p_partner.p_partner_short_name_c " + "FROM PUB_pm_short_term_application, PUB_pm_general_application, PUB_p_partner, p_unit " + "WHERE "; // if we are looking for a specific event if (!AAllEvents) { if (AOutreachCode.Length == 0) { // load all appicants with no event Query += "PUB_pm_short_term_application.pm_confirmed_option_code_c IS NULL " + "AND "; } else if (AOutreachCode.Length > 0) { // get all outreaches relating to an event if (AAllOutreaches) { OdbcParameter Parameter = new OdbcParameter("eventcode", OdbcType.VarChar, 5); Parameter.Value = AOutreachCode.Substring(0, 5); Parameters.Add(Parameter); Query += "SUBSTRING(PUB_pm_short_term_application.pm_confirmed_option_code_c, 1, 5) = ? " + "AND "; } else { OdbcParameter Parameter = new OdbcParameter("eventcode", OdbcType.VarChar, PmShortTermApplicationTable.GetConfirmedOptionCodeLength()); Parameter.Value = AOutreachCode; Parameters.Add(Parameter); Query += "PUB_pm_short_term_application.pm_confirmed_option_code_c = ? " + "AND "; } } } // if year criteria has been supplied if (!string.IsNullOrEmpty(AYear)) { OdbcParameter Parameter = new OdbcParameter("year", OdbcType.VarChar, 2); Parameter.Value = AYear.ToString().Substring(2, 2); Parameters.Add(Parameter); Query += "SUBSTRING(PUB_pm_short_term_application.pm_confirmed_option_code_c, 3, 2) = ? " + "AND "; } Query += "PUB_pm_general_application.p_partner_key_n = PUB_pm_short_term_application.p_partner_key_n " + "AND PUB_pm_general_application.pm_application_key_i = PUB_pm_short_term_application.pm_application_key_i " + "AND PUB_pm_general_application.pm_registration_office_n = PUB_pm_short_term_application.pm_registration_office_n " + "AND PUB_pm_general_application.pm_gen_application_status_c = 'A' " + "AND PUB_p_partner.p_partner_key_n = PUB_pm_short_term_application.p_partner_key_n " + "AND p_unit.p_outreach_code_c = PUB_pm_short_term_application.pm_confirmed_option_code_c " + "AND "; if (AConvertTo) { // converting to past experience so need to make sure past experience does not already exist Query += "NOT "; } Query += "EXISTS (SELECT * FROM pm_past_experience " + "WHERE pm_past_experience.p_partner_key_n = pm_short_term_application.p_partner_key_n " + "AND pm_past_experience.pm_prev_location_c = PUB_pm_short_term_application.pm_confirmed_option_code_c)"; DBAccess.GDBAccessObj.Select(MainDS, Query, ShortTermAppTableName, Transaction, Parameters.ToArray()); }); AMainDS.Merge(MainDS); return(true); }
public static Boolean LoadShortTermApplications(ref ApplicationTDS AMainDS, string AOutreachCode) { string QueryShortTermApplication = ""; ApplicationTDS MainDS = new ApplicationTDS(); String ShortTermAppTableName = AMainDS.PmShortTermApplication.TableName; List <OdbcParameter> Parameters = new List <OdbcParameter>(); OdbcParameter Parameter = new OdbcParameter("eventcode", OdbcType.VarChar, PmShortTermApplicationTable.GetConfirmedOptionCodeLength()); TDBTransaction Transaction = null; DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadCommitted, TEnforceIsolationLevel.eilMinimum, ref Transaction, delegate { QueryShortTermApplication = "SELECT PUB_pm_short_term_application.*, PUB_pm_general_application.*, PUB_p_partner.p_partner_short_name_c " + "FROM PUB_pm_short_term_application, PUB_pm_general_application, PUB_p_partner "; if (AOutreachCode.Length == 0) { // load all appicants with no event QueryShortTermApplication += "WHERE PUB_pm_short_term_application.pm_confirmed_option_code_c IS NULL "; } else if (AOutreachCode.Length > 0) { Parameter.Value = AOutreachCode.Substring(0, 5); Parameters.Add( Parameter); QueryShortTermApplication += "WHERE SUBSTRING(PUB_pm_short_term_application.pm_confirmed_option_code_c, 1, 5) = ? "; } QueryShortTermApplication += "AND PUB_pm_general_application.p_partner_key_n = PUB_pm_short_term_application.p_partner_key_n " + "AND PUB_pm_general_application.pm_application_key_i = PUB_pm_short_term_application.pm_application_key_i " + "AND PUB_pm_general_application.pm_registration_office_n = PUB_pm_short_term_application.pm_registration_office_n " + "AND PUB_p_partner.p_partner_key_n = PUB_pm_short_term_application.p_partner_key_n"; DBAccess.GDBAccessObj.Select(MainDS, QueryShortTermApplication, ShortTermAppTableName, Transaction, Parameters.ToArray()); }); AMainDS.Merge(MainDS); return(true); }
private long GetPartnerKeySelected() { return(Convert.ToInt64(((DataRowView)grdApplications.SelectedDataRows[0]).Row[PmShortTermApplicationTable.GetPartnerKeyDBName()])); }
// update the grid once the filter is changed private void FilterChange(System.Object sender, EventArgs e) { List <string> Filters = new List <string>(); string FiltersString = ""; DataView MyDataView = FMainDS.PmShortTermApplication.DefaultView; MyDataView.RowFilter = null; if (chkShowAllOutreaches.Enabled && !chkShowAllOutreaches.Checked) { // filter rows so only showing applicants for selected outreach rather than the entire conference FiltersString = PmShortTermApplicationTable.GetConfirmedOptionCodeDBName() + " = '" + FOutreachCode + "'"; } if (rbtGeneral.Checked) { if (!chkAccepted.Checked) { Filters.Add("SUBSTRING(" + PmGeneralApplicationTable.GetGenApplicationStatusDBName() + ",1,1) <> 'A'"); } if (!chkCancelled.Checked) { Filters.Add("SUBSTRING(" + PmGeneralApplicationTable.GetGenApplicationStatusDBName() + ",1,1) <> 'C'"); } if (!chkEnquiry.Checked) { Filters.Add("SUBSTRING(" + PmGeneralApplicationTable.GetGenApplicationStatusDBName() + ",1,1) <> 'E'"); } if (!chkHold.Checked) { Filters.Add("SUBSTRING(" + PmGeneralApplicationTable.GetGenApplicationStatusDBName() + ",1,1) <> 'H'"); } if (!chkRejected.Checked) { Filters.Add("SUBSTRING(" + PmGeneralApplicationTable.GetGenApplicationStatusDBName() + ",1,1) <> 'R'"); } Filters.Add("SUBSTRING(" + PmGeneralApplicationTable.GetGenApplicationStatusDBName() + ",1,1) <> 'P'"); for (int i = 0; i < Filters.Count; i++) { if ((i != 0) || (FiltersString.Length > 0)) { FiltersString += " AND " + Filters[i]; } else { FiltersString += Filters[i]; } } } else if (rbtDetailed.Checked) { string[] DetailedStatuses = txtDetailedStatuses.Text.Split(','); foreach (string Status in DetailedStatuses) { Filters.Add(PmGeneralApplicationTable.GetGenApplicationStatusDBName() + " = '" + Status + "'"); } for (int i = 0; i < Filters.Count; i++) { if ((i == 0) && (FiltersString.Length > 0)) { FiltersString += " AND (" + Filters[i]; } else if ((i == 0) && (FiltersString.Length == 0)) { FiltersString += "(" + Filters[i]; } else { FiltersString += " OR " + Filters[i]; } if (i == Filters.Count - 1) { FiltersString += ")"; } } } MyDataView.RowFilter = FiltersString; grdApplications.DataSource = new DevAge.ComponentModel.BoundDataView(MyDataView); UpdateRecordNumberDisplay(); }
public static Boolean LoadShortTermApplications(ref ApplicationTDS AMainDS, string AOutreachCode) { Boolean NewTransaction; string QueryShortTermApplication = ""; List <OdbcParameter> Parameters = new List <OdbcParameter>(); OdbcParameter Parameter = new OdbcParameter("eventcode", OdbcType.VarChar, PmShortTermApplicationTable.GetConfirmedOptionCodeLength()); TDBTransaction ReadTransaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction( IsolationLevel.ReadCommitted, TEnforceIsolationLevel.eilMinimum, out NewTransaction); try { QueryShortTermApplication = "SELECT PUB_pm_short_term_application.*, PUB_pm_general_application.*, PUB_p_partner.p_partner_short_name_c " + "FROM PUB_pm_short_term_application, PUB_pm_general_application, PUB_p_partner "; if (AOutreachCode.Length == 0) { // load all appicants with no event QueryShortTermApplication += "WHERE PUB_pm_short_term_application.pm_confirmed_option_code_c IS NULL "; } else if (AOutreachCode.Length > 0) { Parameter.Value = AOutreachCode.Substring(0, 5); Parameters.Add(Parameter); QueryShortTermApplication += "WHERE SUBSTRING(PUB_pm_short_term_application.pm_confirmed_option_code_c, 1, 5) = ? "; } QueryShortTermApplication += "AND PUB_pm_general_application.p_partner_key_n = PUB_pm_short_term_application.p_partner_key_n " + "AND PUB_pm_general_application.pm_application_key_i = PUB_pm_short_term_application.pm_application_key_i " + "AND PUB_pm_general_application.pm_registration_office_n = PUB_pm_short_term_application.pm_registration_office_n " + "AND PUB_p_partner.p_partner_key_n = PUB_pm_short_term_application.p_partner_key_n"; DBAccess.GDBAccessObj.Select(AMainDS, QueryShortTermApplication, AMainDS.PmShortTermApplication.TableName, ReadTransaction, Parameters.ToArray()); } finally { if (NewTransaction) { DBAccess.GDBAccessObj.CommitTransaction(); TLogging.LogAtLevel(7, "TConferenceDataReaderWebConnector.LoadShortTermApplications: commit own transaction."); } } return(true); }
/// <summary> /// return a list of all applicants for a given event, /// but if AConferenceOrganisingOffice is false, /// consider only the registration office that the user has permissions for, ie. Module REG-00xx0000000 /// </summary> /// <param name="AMainDS"></param> /// <param name="AEventPartnerKey">The ConferenceKey</param> /// <param name="AEventCode">The OutreachPrefix</param> /// <param name="AApplicationStatus"></param> /// <param name="ARegistrationOffice">if -1, then show all offices that the user has permission for</param> /// <param name="AConferenceOrganisingOffice">if true, all offices are considered</param> /// <param name="ARole"></param> /// <param name="AClearJSONData"></param> /// <returns></returns> public static bool GetApplications( ref ConferenceApplicationTDS AMainDS, Int64 AEventPartnerKey, string AEventCode, string AApplicationStatus, Int64 ARegistrationOffice, bool AConferenceOrganisingOffice, string ARole, bool AClearJSONData) { TDBTransaction Transaction = null; ConferenceApplicationTDS MainDS = new ConferenceApplicationTDS(); DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction( IsolationLevel.ReadCommitted, TEnforceIsolationLevel.eilMinimum, ref Transaction, delegate { // load all attendees of this conference. // only load once: GetApplications might be called for several application stati if (MainDS.PcAttendee.Rows.Count == 0) { PcAttendeeRow templateAttendeeRow = MainDS.PcAttendee.NewRowTyped(false); templateAttendeeRow.ConferenceKey = AEventPartnerKey; PcAttendeeAccess.LoadUsingTemplate(MainDS, templateAttendeeRow, Transaction); MainDS.PcAttendee.DefaultView.Sort = PcAttendeeTable.GetPartnerKeyDBName(); } if (AConferenceOrganisingOffice && (ARegistrationOffice == -1)) { // avoid duplicates, who are registered by one office, but charged to another office GetApplications(ref MainDS, AEventCode, -1, AApplicationStatus, ARole, AClearJSONData, Transaction); } else { List <Int64> AllowedRegistrationOffices = GetRegistrationOfficeKeysOfUser(Transaction); foreach (Int64 RegistrationOffice in AllowedRegistrationOffices) { if ((ARegistrationOffice == RegistrationOffice) || (ARegistrationOffice == -1)) { GetApplications(ref MainDS, AEventCode, RegistrationOffice, AApplicationStatus, ARole, AClearJSONData, Transaction); } } } // required for DefaultView.Find MainDS.PmShortTermApplication.DefaultView.Sort = PmShortTermApplicationTable.GetStConfirmedOptionDBName() + "," + PmShortTermApplicationTable.GetPartnerKeyDBName(); MainDS.PmGeneralApplication.DefaultView.Sort = PmGeneralApplicationTable.GetPartnerKeyDBName() + "," + PmGeneralApplicationTable.GetApplicationKeyDBName() + "," + PmGeneralApplicationTable.GetRegistrationOfficeDBName(); MainDS.PDataLabelValuePartner.DefaultView.Sort = PDataLabelValuePartnerTable.GetDataLabelKeyDBName() + "," + PDataLabelValuePartnerTable.GetPartnerKeyDBName(); MainDS.PDataLabel.DefaultView.Sort = PDataLabelTable.GetTextDBName(); }); AMainDS = MainDS; if (AMainDS.HasChanges()) { AMainDS.EnforceConstraints = false; AMainDS.AcceptChanges(); } return(true); }
private static bool LoadApplicationsFromDB( ref ConferenceApplicationTDS AMainDS, string AEventCode, Int64?ARegisteringOffice, string ARole, Int64?APartnerKey, TDBTransaction ATransaction) { ConferenceApplicationTDS MainDS = new ConferenceApplicationTDS(); List <OdbcParameter> parameters = new List <OdbcParameter>(); OdbcParameter parameter = new OdbcParameter("eventcode", OdbcType.VarChar, PmShortTermApplicationTable.GetConfirmedOptionCodeLength()); parameter.Value = AEventCode.Substring(0, 5); parameters.Add(parameter); string DataLabels = "(PUB_p_data_label.p_text_c = 'MedicalNotes' OR PUB_p_data_label.p_text_c = 'Rebukes')"; string queryShortTermApplication = "SELECT PUB_pm_short_term_application.* " + "FROM PUB_pm_short_term_application " + "WHERE SUBSTRING(PUB_pm_short_term_application.pm_confirmed_option_code_c, 1, 5) = ? "; string queryGeneralApplication = "SELECT PUB_pm_general_application.* " + "FROM PUB_pm_short_term_application, PUB_pm_general_application " + "WHERE SUBSTRING(PUB_pm_short_term_application.pm_confirmed_option_code_c, 1, 5) = ? " + " AND PUB_pm_general_application.p_partner_key_n = PUB_pm_short_term_application.p_partner_key_n " + " AND PUB_pm_general_application.pm_application_key_i = PUB_pm_short_term_application.pm_application_key_i " + " AND PUB_pm_general_application.pm_registration_office_n = PUB_pm_short_term_application.pm_registration_office_n"; string queryPerson = "SELECT DISTINCT PUB_p_person.* " + "FROM PUB_pm_short_term_application, PUB_p_person " + "WHERE SUBSTRING(PUB_pm_short_term_application.pm_confirmed_option_code_c, 1, 5) = ? " + " AND PUB_p_person.p_partner_key_n = PUB_pm_short_term_application.p_partner_key_n"; string queryPartner = "SELECT DISTINCT PUB_p_partner.* " + "FROM PUB_p_partner, PUB_pm_short_term_application " + "WHERE SUBSTRING(PUB_pm_short_term_application.pm_confirmed_option_code_c, 1, 5) = ? " + " AND (PUB_p_partner.p_partner_key_n = PUB_pm_short_term_application.p_partner_key_n" + " OR PUB_p_partner.p_partner_key_n = PUB_pm_short_term_application.pm_st_field_charged_n)"; string queryDataLabel = "SELECT DISTINCT PUB_p_data_label_value_partner.* " + "FROM PUB_pm_short_term_application, PUB_p_data_label_value_partner, PUB_p_data_label " + "WHERE SUBSTRING(PUB_pm_short_term_application.pm_confirmed_option_code_c, 1, 5) = ? " + " AND PUB_p_data_label_value_partner.p_partner_key_n = PUB_pm_short_term_application.p_partner_key_n" + " AND PUB_p_data_label_value_partner.p_data_label_key_i = PUB_p_data_label.p_key_i" + " AND " + DataLabels; if ((ARole != null) && (ARole.Length > 0)) { queryGeneralApplication += " AND PUB_pm_short_term_application.pm_st_congress_code_c LIKE '" + ARole + "%'"; queryShortTermApplication += " AND PUB_pm_short_term_application.pm_st_congress_code_c LIKE '" + ARole + "%'"; queryPerson += " AND PUB_pm_short_term_application.pm_st_congress_code_c LIKE '" + ARole + "%'"; queryDataLabel += " AND PUB_pm_short_term_application.pm_st_congress_code_c LIKE '" + ARole + "%'"; } if (ARegisteringOffice.HasValue && (ARegisteringOffice.Value > 0)) { string queryRegistrationOffice = " AND (PUB_pm_short_term_application.pm_st_field_charged_n = ? OR PUB_pm_short_term_application.pm_registration_office_n = ?)"; queryGeneralApplication += queryRegistrationOffice; queryShortTermApplication += queryRegistrationOffice; queryPerson += queryRegistrationOffice; queryPartner += " AND PUB_pm_short_term_application.pm_st_congress_code_c LIKE '" + ARole + "%'"; queryDataLabel += queryRegistrationOffice; parameter = new OdbcParameter("fieldCharged", OdbcType.Decimal, 10); parameter.Value = ARegisteringOffice.Value; parameters.Add(parameter); parameter = new OdbcParameter("registrationOffice", OdbcType.Decimal, 10); parameter.Value = ARegisteringOffice.Value; parameters.Add(parameter); } if (APartnerKey.HasValue && (APartnerKey.Value > 0)) { queryGeneralApplication += " AND PUB_pm_short_term_application.p_partner_key_n = ?"; queryShortTermApplication += " AND PUB_pm_short_term_application.p_partner_key_n = ?"; queryPerson += " AND PUB_pm_short_term_application.p_partner_key_n = ?"; queryPartner += " AND PUB_pm_short_term_application.p_partner_key_n = ?"; queryDataLabel += " AND PUB_pm_short_term_application.p_partner_key_n = ?"; parameter = new OdbcParameter("partnerkey", OdbcType.Decimal, 10); parameter.Value = APartnerKey.Value; parameters.Add(parameter); } DBAccess.GDBAccessObj.Select(MainDS, queryShortTermApplication, MainDS.PmShortTermApplication.TableName, ATransaction, parameters.ToArray()); DBAccess.GDBAccessObj.Select(MainDS, queryPerson, MainDS.PPerson.TableName, ATransaction, parameters.ToArray()); DBAccess.GDBAccessObj.Select(MainDS, queryPartner, MainDS.PPartner.TableName, ATransaction, parameters.ToArray()); DBAccess.GDBAccessObj.Select(MainDS, queryGeneralApplication, MainDS.PmGeneralApplication.TableName, ATransaction, parameters.ToArray()); DBAccess.GDBAccessObj.Select(MainDS, queryDataLabel, MainDS.PDataLabelValuePartner.TableName, ATransaction, parameters.ToArray()); DBAccess.GDBAccessObj.Select(MainDS, "SELECT * FROM PUB_p_data_label WHERE " + DataLabels, MainDS.PDataLabel.TableName, ATransaction); AMainDS.Merge(MainDS); AMainDS.PDataLabelValuePartner.DefaultView.Sort = PDataLabelValuePartnerTable.GetDataLabelKeyDBName() + "," + PDataLabelValuePartnerTable.GetPartnerKeyDBName(); AMainDS.PDataLabel.DefaultView.Sort = PDataLabelTable.GetTextDBName(); return(true); }
public static bool GetFieldUnits(Int64 AConferenceKey, TUnitTypeEnum AFieldTypes, out DataTable AFieldsTable, out String AConferencePrefix) { TDBTransaction ReadTransaction; Boolean NewTransaction = false; AFieldsTable = new DataTable("Field Units"); AConferencePrefix = ""; PUnitTable UnitTable; DataTable TmpTable; PmShortTermApplicationTable ShortTermerTable = new PmShortTermApplicationTable(); AFieldsTable.Columns.Add("Selection", System.Type.GetType("System.Boolean")); AFieldsTable.Columns.Add("Unit_Key", System.Type.GetType("System.Int64")); AFieldsTable.Columns.Add("Unit_Name", System.Type.GetType("System.String")); AFieldsTable.Columns.Add("Outreach_Code", System.Type.GetType("System.String")); AFieldsTable.Columns.Add("Used_in_Conference", System.Type.GetType("System.Boolean")); AConferencePrefix = TConferenceOptions.GetConferencePrefix(AConferenceKey); switch (AFieldTypes) { case TUnitTypeEnum.utSendingFields: return(TConferenceOptions.GetSendingFields(AConferenceKey, ref AFieldsTable)); case TUnitTypeEnum.utReceivingFields: return(TConferenceOptions.GetReceivingFields(AConferenceKey, ref AFieldsTable)); case TUnitTypeEnum.utOutreachOptions: if (TConferenceOptions.GetOutreachOptions(AConferenceKey, out TmpTable)) { foreach (DataRow Row in TmpTable.Rows) { DataRow NewRow = AFieldsTable.NewRow(); NewRow[SELECTION] = false; NewRow[UNIT_KEY] = Row["Partner Key"]; NewRow[UNIT_NAME] = Row["Unit Name"]; NewRow[CAMPAIGN_CODE] = Row["Outreach Code"]; NewRow[USED_IN_CONFERENCE] = true; AFieldsTable.Rows.Add(NewRow); } return(true); } return(false); default: break; } TLogging.LogAtLevel(9, "TConferenceOptions.GetFieldUnits called!"); TDataBase db = DBAccess.Connect("GetFieldUnits"); ReadTransaction = db.GetNewOrExistingTransaction(IsolationLevel.RepeatableRead, out NewTransaction); try { StringCollection FieldList = new StringCollection(); FieldList.Add(PmShortTermApplicationTable.GetStFieldChargedDBName()); FieldList.Add(PmShortTermApplicationTable.GetConfirmedOptionCodeDBName()); FieldList.Add(PmShortTermApplicationTable.GetRegistrationOfficeDBName()); ShortTermerTable = PmShortTermApplicationAccess.LoadAll(FieldList, ReadTransaction); long LastUnitKey = 0; long NewUnitKey = 0; bool IsUsedInOneConference = false; String ConfirmedOptionCode = ""; System.Type StringType = System.Type.GetType("System.String"); String SearchedColumnName = ""; switch (AFieldTypes) { case TUnitTypeEnum.utChargedFields: SearchedColumnName = PmShortTermApplicationTable.GetStFieldChargedDBName(); break; case TUnitTypeEnum.utRegisteringFields: SearchedColumnName = PmShortTermApplicationTable.GetRegistrationOfficeDBName(); break; default: break; } foreach (DataRow ShortTermerRow in ShortTermerTable.Select("", SearchedColumnName)) { if ((ShortTermerRow[SearchedColumnName] != null) && (ShortTermerRow[SearchedColumnName].ToString().Length > 0)) { NewUnitKey = (long)ShortTermerRow[SearchedColumnName]; } else { continue; } if (LastUnitKey != NewUnitKey) { if ((AFieldsTable.Rows.Count > 0) && (IsUsedInOneConference)) { AFieldsTable.Rows[AFieldsTable.Rows.Count - 1][USED_IN_CONFERENCE] = true; } IsUsedInOneConference = false; } // We have to check from every shorttermer if the charged field is used // in this conference if (IsUsedInOneConference) { continue; } if (ShortTermerRow[PmShortTermApplicationTable.GetConfirmedOptionCodeDBName()].GetType() == StringType) { ConfirmedOptionCode = (string)ShortTermerRow[PmShortTermApplicationTable.GetConfirmedOptionCodeDBName()]; } else { ConfirmedOptionCode = ""; } if (ConfirmedOptionCode.StartsWith(AConferencePrefix)) { IsUsedInOneConference = true; } if (LastUnitKey == NewUnitKey) { continue; } UnitTable = PUnitAccess.LoadByPrimaryKey(NewUnitKey, ReadTransaction); if (UnitTable.Rows.Count > 0) { DataRow ResultRow = AFieldsTable.NewRow(); ResultRow[SELECTION] = false; ResultRow[UNIT_KEY] = NewUnitKey; ResultRow[UNIT_NAME] = UnitTable[0][PUnitTable.GetUnitNameDBName()]; ResultRow[CAMPAIGN_CODE] = ConfirmedOptionCode; ResultRow[USED_IN_CONFERENCE] = IsUsedInOneConference; AFieldsTable.Rows.Add(ResultRow); LastUnitKey = NewUnitKey; } } // Check for the previous entry the "IsUsedInConference" field if ((AFieldsTable.Rows.Count > 0) && (IsUsedInOneConference)) { AFieldsTable.Rows[AFieldsTable.Rows.Count - 1][USED_IN_CONFERENCE] = true; } } finally { if (NewTransaction) { ReadTransaction.Commit(); TLogging.LogAtLevel(7, "TConferenceOptions.GetFieldUnits: committed own transaction."); } } return(true); }
/// <summary> /// Main entry point for calculating the accommodation report. /// This must be called for each partner in each conference. /// </summary> /// <param name="AConferenceKey">Conference Key of the current conference to examine</param> /// <param name="AStartDate">Start date of the conference</param> /// <param name="AEndDate">End date of the conference</param> /// <param name="AFromDate">Start date of the report</param> /// <param name="AToDate">End date of the report</param> /// <param name="APartnerKey">Partner Key of the current partner to examine</param> /// <param name="AReportDetail">Indicator of the details of the report. Possible options: Brief, Full, Detail</param> /// <param name="ASituation">The current report situation</param> /// <returns></returns> public bool CalculatePartnerAccom(long AConferenceKey, DateTime AStartDate, DateTime AEndDate, DateTime AFromDate, DateTime AToDate, long APartnerKey, string AReportDetail, ref TRptSituation ASituation) { PcAttendeeTable AttendeeTable; PcAttendeeRow AttendeeRow = null; PmShortTermApplicationTable ShortTermTable; PmShortTermApplicationTable TmpTable = new PmShortTermApplicationTable(); PmShortTermApplicationRow TemplateRow; TemplateRow = TmpTable.NewRowTyped(false); TemplateRow.PartnerKey = APartnerKey; TemplateRow.StConfirmedOption = AConferenceKey; if (FAccommodationTable == null) { InitAccomTable(AFromDate, AToDate); } AttendeeTable = PcAttendeeAccess.LoadByPrimaryKey(AConferenceKey, APartnerKey, ASituation.GetDatabaseConnection().Transaction); if (AttendeeTable.Rows.Count > 0) { AttendeeRow = (PcAttendeeRow)AttendeeTable.Rows[0]; } ShortTermTable = PmShortTermApplicationAccess.LoadUsingTemplate(TemplateRow, ASituation.GetDatabaseConnection().Transaction); foreach (DataRow Row in ShortTermTable.Rows) { AddPartnerToAccom((PmShortTermApplicationRow)Row, AttendeeRow, AStartDate, AEndDate, AFromDate, AToDate, AReportDetail, ref ASituation); } return true; }
public static bool GetFieldUnits(Int64 AConferenceKey, TUnitTypeEnum AFieldTypes, out DataTable AFieldsTable, out String AConferencePrefix) { TDBTransaction ReadTransaction; Boolean NewTransaction = false; AFieldsTable = new DataTable("Field Units"); AConferencePrefix = ""; PUnitTable UnitTable; DataTable TmpTable; PmShortTermApplicationTable ShortTermerTable = new PmShortTermApplicationTable(); AFieldsTable.Columns.Add("Selection", System.Type.GetType("System.Boolean")); AFieldsTable.Columns.Add("Unit Key", System.Type.GetType("System.Int64")); AFieldsTable.Columns.Add("Unit Name", System.Type.GetType("System.String")); AFieldsTable.Columns.Add("Outreach Code", System.Type.GetType("System.String")); AFieldsTable.Columns.Add("Used_in_Conference", System.Type.GetType("System.Boolean")); AConferencePrefix = TConferenceOptions.GetConferencePrefix(AConferenceKey); switch (AFieldTypes) { case TUnitTypeEnum.utSendingFields: return TConferenceOptions.GetSendingFields(AConferenceKey, ref AFieldsTable); case TUnitTypeEnum.utReceivingFields: return TConferenceOptions.GetReceivingFields(AConferenceKey, ref AFieldsTable); case TUnitTypeEnum.utOutreachOptions: if (TConferenceOptions.GetOutreachOptions(AConferenceKey, out TmpTable)) { foreach (DataRow Row in TmpTable.Rows) { DataRow NewRow = AFieldsTable.NewRow(); NewRow[SELECTION] = false; NewRow[UNIT_KEY] = Row["Partner Key"]; NewRow[UNIT_NAME] = Row["Unit Name"]; NewRow[CAMPAIGN_CODE] = Row["Outreach Code"]; NewRow[USED_IN_CONFERENCE] = true; AFieldsTable.Rows.Add(NewRow); } return true; } return false; default: break; } TLogging.LogAtLevel(9, "TConferenceOptions.GetFieldUnits called!"); ReadTransaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.RepeatableRead, TEnforceIsolationLevel.eilMinimum, out NewTransaction); try { StringCollection FieldList = new StringCollection(); FieldList.Add(PmShortTermApplicationTable.GetStFieldChargedDBName()); FieldList.Add(PmShortTermApplicationTable.GetConfirmedOptionCodeDBName()); FieldList.Add(PmShortTermApplicationTable.GetRegistrationOfficeDBName()); ShortTermerTable = PmShortTermApplicationAccess.LoadAll(FieldList, ReadTransaction); long LastUnitKey = 0; long NewUnitKey = 0; bool IsUsedInOneConference = false; String ConfirmedOptionCode = ""; System.Type StringType = System.Type.GetType("System.String"); String SearchedColumnName = ""; switch (AFieldTypes) { case TUnitTypeEnum.utChargedFields: SearchedColumnName = PmShortTermApplicationTable.GetStFieldChargedDBName(); break; case TUnitTypeEnum.utRegisteringFields: SearchedColumnName = PmShortTermApplicationTable.GetRegistrationOfficeDBName(); break; default: break; } foreach (DataRow ShortTermerRow in ShortTermerTable.Select("", SearchedColumnName)) { if ((ShortTermerRow[SearchedColumnName] != null) && (ShortTermerRow[SearchedColumnName].ToString().Length > 0)) { NewUnitKey = (long)ShortTermerRow[SearchedColumnName]; } else { continue; } if (LastUnitKey != NewUnitKey) { if ((AFieldsTable.Rows.Count > 0) && (IsUsedInOneConference)) { AFieldsTable.Rows[AFieldsTable.Rows.Count - 1][USED_IN_CONFERENCE] = true; } IsUsedInOneConference = false; } // We have to check from every shorttermer if the charged field is used // in this conference if (IsUsedInOneConference) { continue; } if (ShortTermerRow[PmShortTermApplicationTable.GetConfirmedOptionCodeDBName()].GetType() == StringType) { ConfirmedOptionCode = (string)ShortTermerRow[PmShortTermApplicationTable.GetConfirmedOptionCodeDBName()]; } else { ConfirmedOptionCode = ""; } if (ConfirmedOptionCode.StartsWith(AConferencePrefix)) { IsUsedInOneConference = true; } if (LastUnitKey == NewUnitKey) { continue; } UnitTable = PUnitAccess.LoadByPrimaryKey(NewUnitKey, ReadTransaction); if (UnitTable.Rows.Count > 0) { DataRow ResultRow = AFieldsTable.NewRow(); ResultRow[SELECTION] = false; ResultRow[UNIT_KEY] = NewUnitKey; ResultRow[UNIT_NAME] = UnitTable[0][PUnitTable.GetUnitNameDBName()]; ResultRow[CAMPAIGN_CODE] = ConfirmedOptionCode; ResultRow[USED_IN_CONFERENCE] = IsUsedInOneConference; AFieldsTable.Rows.Add(ResultRow); LastUnitKey = NewUnitKey; } } // Check for the previous entry the "IsUsedInConference" field if ((AFieldsTable.Rows.Count > 0) && (IsUsedInOneConference)) { AFieldsTable.Rows[AFieldsTable.Rows.Count - 1][USED_IN_CONFERENCE] = true; } } finally { if (NewTransaction) { DBAccess.GDBAccessObj.CommitTransaction(); TLogging.LogAtLevel(7, "TConferenceOptions.GetFieldUnits: committed own transaction."); } } return true; }