/// <summary> /// Gets the AddressOrder (p_address_order_i DB field) of a certain Country. /// </summary> /// <param name="ACountryCode">CountryCode (ISO Code) of a Country</param> /// <returns>AddressOrder for that Country (0 if Country cannot be found).</returns> public static Int32 GetAddressOrder(String ACountryCode) { PCountryTable DataCacheCountryDT = (PCountryTable)TDataCache.TMCommon.GetCacheableCommonTable(TCacheableCommonTablesEnum.CountryList); PCountryRow CountryDR = (PCountryRow)DataCacheCountryDT.Rows.Find(ACountryCode); return((CountryDR != null) ? CountryDR.AddressOrder : 0); }
private void InitUserControlsManually() { // set controls in filter to default values ucoFilter.InitialiseUserControl(); // Hook up EventFilterChanged Event to be able to react to changed filter ucoFilter.EventFilterChanged += new TEventHandlerEventFilterChanged(this.EventFilterChanged); //grdEvent.AutoSizeCells(); // now the filter is initialized we can load the initial data LoadEventListData(); grdEvent.Columns.Clear(); grdEvent.AddTextColumn("Event Name", FEventTable.Columns[PPartnerTable.GetPartnerShortNameDBName()]); grdEvent.AddTextColumn("Event Code", FEventTable.Columns[PUnitTable.GetOutreachCodeDBName()]); grdEvent.AddTextColumn("Country", FEventTable.Columns[PCountryTable.GetCountryNameDBName()]); grdEvent.AddDateColumn("Start Date", FEventTable.Columns[PPartnerLocationTable.GetDateEffectiveDBName()]); grdEvent.AddDateColumn("End Date", FEventTable.Columns[PPartnerLocationTable.GetDateGoodUntilDBName()]); grdEvent.AddPartnerKeyColumn("Event Key", FEventTable.Columns[PPartnerTable.GetPartnerKeyDBName()]); grdEvent.AddTextColumn("Event Type", FEventTable.Columns[PUnitTable.GetUnitTypeCodeDBName()]); FEventTable.DefaultView.AllowDelete = false; FEventTable.DefaultView.AllowEdit = false; FEventTable.DefaultView.AllowNew = false; grdEvent.Selection.EnableMultiSelection = false; grdEvent.AutoResizeGrid(); grdEvent.Selection.SelectRow(1, true); }
/// find the current best address for the partner public static bool GetBestAddress(Int64 APartnerKey, out PLocationTable AAddress, out string ACountryNameLocal, TDBTransaction ATransaction, bool AOnlySendMail = false) { AAddress = null; ACountryNameLocal = ""; DataSet PartnerLocationsDS = new DataSet(); PartnerLocationsDS.Tables.Add(new PPartnerLocationTable()); PartnerLocationsDS.Tables.Add(new PCountryTable()); DataTable PartnerLocationTable = PartnerLocationsDS.Tables[PPartnerLocationTable.GetTableName()]; PCountryTable CountryTable = (PCountryTable)PartnerLocationsDS.Tables[PCountryTable.GetTableName()]; CountryTable.DefaultView.Sort = PCountryTable.GetCountryCodeDBName(); // add special column BestAddress and Icon PartnerLocationTable.Columns.Add(new System.Data.DataColumn("BestAddress", typeof(Boolean))); PartnerLocationTable.Columns.Add(new System.Data.DataColumn("Icon", typeof(Int32))); // find all locations of the partner, put it into a dataset PPartnerLocationAccess.LoadViaPPartner(PartnerLocationsDS, APartnerKey, ATransaction); Calculations.DeterminePartnerLocationsDateStatus(PartnerLocationsDS); Calculations.DetermineBestAddress(PartnerLocationsDS); foreach (PPartnerLocationRow row in PartnerLocationTable.Rows) { if (AOnlySendMail && !Convert.ToBoolean(row[PPartnerLocationTable.GetSendMailDBName()])) { // ignore addresses that are not set for receiving mail. continue; } // find the row with BestAddress = 1 if (Convert.ToInt32(row["BestAddress"]) == 1) { // we also want the post address, need to load the p_location table: AAddress = PLocationAccess.LoadByPrimaryKey(row.SiteKey, row.LocationKey, ATransaction); // watch out for empty country codes if (AAddress[0].CountryCode.Trim().Length > 0) { if (CountryTable.DefaultView.Find(AAddress[0].CountryCode) == -1) { CountryTable.Merge(PCountryAccess.LoadByPrimaryKey(AAddress[0].CountryCode, ATransaction)); } ACountryNameLocal = CountryTable[CountryTable.DefaultView.Find(AAddress[0].CountryCode)].CountryNameLocal; } break; } } return(AAddress != null); }
/// <summary> /// get the best email address that is valid today, with some location details /// </summary> public static string GetBestEmailAddressWithDetails(Int64 APartnerKey, out PLocationTable AAddress, out string ACountryNameLocal) { string EmailAddress = ""; PLocationTable Address = null; string CountryNameLocal = ""; TDBTransaction Transaction = null; DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadCommitted, ref Transaction, delegate { DataSet PartnerLocationsDS = new DataSet(); PartnerLocationsDS.Tables.Add(new PPartnerLocationTable()); PartnerLocationsDS.Tables.Add(new PCountryTable()); DataTable PartnerLocationTable = PartnerLocationsDS.Tables[PPartnerLocationTable.GetTableName()]; PCountryTable CountryTable = (PCountryTable)PartnerLocationsDS.Tables[PCountryTable.GetTableName()]; CountryTable.DefaultView.Sort = PCountryTable.GetCountryCodeDBName(); // add special column BestAddress and Icon PartnerLocationTable.Columns.Add(new System.Data.DataColumn("BestAddress", typeof(Boolean))); PartnerLocationTable.Columns.Add(new System.Data.DataColumn("Icon", typeof(Int32))); // find all locations of the partner, put it into a dataset PPartnerLocationAccess.LoadViaPPartner(PartnerLocationsDS, APartnerKey, Transaction); Ict.Petra.Shared.MPartner.Calculations.DeterminePartnerLocationsDateStatus(PartnerLocationsDS); Ict.Petra.Shared.MPartner.Calculations.DetermineBestAddress(PartnerLocationsDS); foreach (PPartnerLocationRow row in PartnerLocationTable.Rows) { // find the row with BestAddress = 1 if (Convert.ToInt32(row["BestAddress"]) == 1) { if (!row.IsEmailAddressNull()) { EmailAddress = row.EmailAddress; } // we also want the post address, need to load the p_location table: Address = PLocationAccess.LoadByPrimaryKey(row.SiteKey, row.LocationKey, Transaction); if (CountryTable.DefaultView.Find(Address[0].CountryCode) == -1) { CountryTable.Merge(PCountryAccess.LoadByPrimaryKey(Address[0].CountryCode, Transaction)); } CountryNameLocal = CountryTable[CountryTable.DefaultView.Find(Address[0].CountryCode)].CountryNameLocal; } } }); AAddress = Address; ACountryNameLocal = CountryNameLocal; return(EmailAddress); }
/// <summary> /// Get the printable name for this country /// </summary> /// <param name="CountryCode"></param> /// <param name="ATransaction"></param> /// <returns></returns> public static string GetCountryName(string CountryCode, TDBTransaction ATransaction) { PCountryTable Tbl = PCountryAccess.LoadByPrimaryKey(CountryCode, ATransaction); if (Tbl.Rows.Count > 0) { return(Tbl[0].CountryName); } else { return(""); } }
private String GetCountryName(String ACountryCode, ref TRptSituation ASituation) { PCountryTable CountryTable; CountryTable = PCountryAccess.LoadByPrimaryKey(ACountryCode, ASituation.GetDatabaseConnection().Transaction); if (CountryTable.Rows.Count > 0) { return((String)CountryTable.Rows[0][PCountryTable.GetCountryNameDBName()]); } return("Unknown"); }
private DataTable GetCountryListFromExistingLocationsTable(TDBTransaction AReadTransaction, string ATableName) { // Used eg. in Report Gift Data Export for finding donors. return(DBAccess.GDBAccessObj.SelectDT("SELECT DISTINCT " + "PUB." + PCountryTable.GetTableDBName() + '.' + PCountryTable.GetCountryCodeDBName() + ", " + PCountryTable.GetCountryNameDBName() + " FROM PUB." + PCountryTable.GetTableDBName() + " c, PUB." + PLocationTable.GetTableDBName() + " l " + " WHERE " + PLocationTable.GetCountyDBName() + " IS NOT NULL AND NOT " + PLocationTable.GetCountyDBName() + " = ''" + " AND c." + PCountryTable.GetCountryCodeDBName() + " = l." + PLocationTable.GetCountryCodeDBName(), ATableName, AReadTransaction)); }
private DataTable GetConferenceListTable(TDBTransaction AReadTransaction, string ATableName) { DataTable Table; DataColumn[] Key = new DataColumn[1]; // Used eg. Select Event Dialog Table = DBAccess.GetDBAccessObj(AReadTransaction).SelectDT( "SELECT DISTINCT " + PPartnerTable.GetPartnerShortNameDBName() + ", " + PPartnerTable.GetPartnerClassDBName() + ", " + PUnitTable.GetOutreachCodeDBName() + ", " + PCountryTable.GetTableDBName() + "." + PCountryTable.GetCountryNameDBName() + ", " + PPartnerLocationTable.GetTableDBName() + "." + PPartnerLocationTable.GetDateEffectiveDBName() + ", " + PPartnerLocationTable.GetTableDBName() + "." + PPartnerLocationTable.GetDateGoodUntilDBName() + ", " + PPartnerTable.GetTableDBName() + "." + PPartnerTable.GetPartnerKeyDBName() + ", " + PUnitTable.GetUnitTypeCodeDBName() + " FROM PUB." + PPartnerTable.GetTableDBName() + ", PUB." + PUnitTable.GetTableDBName() + ", PUB." + PLocationTable.GetTableDBName() + ", PUB." + PPartnerLocationTable.GetTableDBName() + ", PUB." + PCountryTable.GetTableDBName() + " WHERE " + PPartnerTable.GetTableDBName() + "." + PPartnerTable.GetPartnerKeyDBName() + " = " + PUnitTable.GetTableDBName() + "." + PUnitTable.GetPartnerKeyDBName() + " AND " + PPartnerTable.GetTableDBName() + "." + PPartnerTable.GetPartnerKeyDBName() + " = " + PPartnerLocationTable.GetTableDBName() + "." + PPartnerLocationTable.GetPartnerKeyDBName() + " AND " + PLocationTable.GetTableDBName() + "." + PLocationTable.GetSiteKeyDBName() + " = " + PPartnerLocationTable.GetTableDBName() + "." + PPartnerLocationTable.GetSiteKeyDBName() + " AND " + PLocationTable.GetTableDBName() + "." + PLocationTable.GetLocationKeyDBName() + " = " + PPartnerLocationTable.GetTableDBName() + "." + PPartnerLocationTable.GetLocationKeyDBName() + " AND " + PCountryTable.GetTableDBName() + "." + PCountryTable.GetCountryCodeDBName() + " = " + PLocationTable.GetTableDBName() + "." + PLocationTable.GetCountryCodeDBName() + " AND " + PPartnerTable.GetStatusCodeDBName() + " = 'ACTIVE' AND " + PPartnerTable.GetPartnerClassDBName() + " = 'UNIT' AND (" + PUnitTable.GetUnitTypeCodeDBName() + " LIKE '%CONF%' OR " + PUnitTable.GetUnitTypeCodeDBName() + " LIKE '%CONG%')" , ATableName, AReadTransaction); Key[0] = Table.Columns[PPartnerTable.GetPartnerKeyDBName()]; Table.PrimaryKey = Key; return(Table); }
/// <summary> /// link the fields in the current ledger /// </summary> /// <param name="AFieldCSVFile"></param> public static void GenerateFieldsFinanceOnly(string AFieldCSVFile) { XmlDocument doc = TCsv2Xml.ParseCSV2Xml(AFieldCSVFile, ","); XmlNode RecordNode = doc.FirstChild.NextSibling.FirstChild; GLSetupTDS GLSetupDS = new GLSetupTDS(); PCountryTable CountryTable = null; TDBTransaction Transaction = null; DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadCommitted, TEnforceIsolationLevel.eilMinimum, ref Transaction, delegate { CountryTable = PCountryAccess.LoadAll(Transaction); }); while (RecordNode != null) { long id = 100 + Convert.ToInt64(TXMLParser.GetAttribute(RecordNode, "id")); string CountryCode = TXMLParser.GetAttribute(RecordNode, "Name"); string UnitName = ((PCountryRow)CountryTable.Rows.Find(CountryCode)).CountryName; Int64 PartnerKey = id * 1000000; // create cost centre ACostCentreRow CostCentreRow = GLSetupDS.ACostCentre.NewRowTyped(); CostCentreRow.LedgerNumber = FLedgerNumber; CostCentreRow.CostCentreCode = (id * 100).ToString("0000"); CostCentreRow.CostCentreName = UnitName; CostCentreRow.CostCentreToReportTo = MFinanceConstants.INTER_LEDGER_HEADING; CostCentreRow.CostCentreType = MFinanceConstants.FOREIGN_CC_TYPE; GLSetupDS.ACostCentre.Rows.Add(CostCentreRow); // create foreign ledger, cost centre link validledgernumber AValidLedgerNumberRow ValidLedgerNumber = GLSetupDS.AValidLedgerNumber.NewRowTyped(); ValidLedgerNumber.LedgerNumber = FLedgerNumber; ValidLedgerNumber.PartnerKey = PartnerKey; ValidLedgerNumber.CostCentreCode = CostCentreRow.CostCentreCode; ValidLedgerNumber.IltProcessingCentre = Convert.ToInt64(MFinanceConstants.ICH_COST_CENTRE) * 10000; GLSetupDS.AValidLedgerNumber.Rows.Add(ValidLedgerNumber); RecordNode = RecordNode.NextSibling; } GLSetupTDSAccess.SubmitChanges(GLSetupDS); }
// // Put Methods for the validation of Cacheable DataTables in this code file. // partial void ValidateCountryListManual(ref TVerificationResultCollection AVerificationResult, TTypedDataTable ASubmitTable) { TValidationControlsDict ValidationControlsDict = new TValidationControlsDict(); ValidationControlsDict.Add(ASubmitTable.Columns[PCountryTable.ColumnInternatTelephoneCodeId], new TValidationControlsData(null, PCountryTable.GetInternatTelephoneCodeDBName())); ValidationControlsDict.Add(ASubmitTable.Columns[PCountryTable.ColumnInternatPostalTypeCodeId], new TValidationControlsData(null, PCountryTable.GetInternatAccessCodeDBName())); ValidationControlsDict.Add(ASubmitTable.Columns[PCountryTable.ColumnTimeZoneMinimumId], new TValidationControlsData(null, PCountryTable.GetTimeZoneMinimumDBName(), null, PCountryTable.GetTimeZoneMaximumDBName())); for (int Counter = 0; Counter < ASubmitTable.Rows.Count; Counter++) { TSharedValidation_CacheableDataTables.ValidateCountrySetupManual(this.GetType().Name + " (Error in Row #" + Counter.ToString() + ")", // No translation of message text since the server's messages should be all in English (PCountryRow)ASubmitTable.Rows[Counter], ref AVerificationResult, ValidationControlsDict); } }
private String GetLedgerInfo(Int32 ALedgerNumber) { ALedgerRow ledger = ((ALedgerTable)TDataCache.TMFinance.GetCacheableFinanceTable( TCacheableFinanceTablesEnum.LedgerDetails, ALedgerNumber))[0]; String strBaseCurrency = ledger.BaseCurrency; String strCountryCode = ledger.CountryCode; PCountryTable DataCacheCountryDT = (PCountryTable)TDataCache.TMCommon.GetCacheableCommonTable( TCacheableCommonTablesEnum.CountryList); PCountryRow CountryDR = (PCountryRow)DataCacheCountryDT.Rows.Find(strCountryCode); String strLedgerName = FLedgerNumber.ToString(); if (CountryDR != null) { strLedgerName += (" - " + CountryDR.CountryName); } strLedgerName += (" [" + strBaseCurrency + "]"); return(strLedgerName); }
public static DataTable GetEventUnits() { List <OdbcParameter> SqlParameterList = new List <OdbcParameter>(); DataColumn[] Key = new DataColumn[3]; DataTable Events = new DataTable(); if (TLogging.DL >= 9) { Console.WriteLine("GetEventUnits called!"); } TDBTransaction Transaction = null; DBAccess.GDBAccessObj.BeginAutoReadTransaction(IsolationLevel.ReadCommitted, ref Transaction, delegate { string SqlStmt = "SELECT DISTINCT " + PPartnerTable.GetPartnerShortNameDBName() + ", " + PPartnerTable.GetPartnerClassDBName() + ", " + PUnitTable.GetOutreachCodeDBName() + ", " + PCountryTable.GetTableDBName() + "." + PCountryTable.GetCountryNameDBName() + ", " + PPartnerLocationTable.GetTableDBName() + "." + PPartnerLocationTable.GetSiteKeyDBName() + ", " + PPartnerLocationTable.GetTableDBName() + "." + PPartnerLocationTable.GetLocationKeyDBName() + ", " + PPartnerLocationTable.GetTableDBName() + "." + PPartnerLocationTable.GetDateEffectiveDBName() + ", " + PPartnerLocationTable.GetTableDBName() + "." + PPartnerLocationTable.GetDateGoodUntilDBName() + ", " + PPartnerTable.GetTableDBName() + "." + PPartnerTable.GetPartnerKeyDBName() + ", " + PUnitTable.GetUnitTypeCodeDBName() + ", " + PUnitTable.GetUnitNameDBName() + " FROM pub_" + PPartnerTable.GetTableDBName() + ", pub_" + PUnitTable.GetTableDBName() + ", pub_" + PLocationTable.GetTableDBName() + ", pub_" + PPartnerLocationTable.GetTableDBName() + ", pub_" + PCountryTable.GetTableDBName() + " WHERE " + PPartnerTable.GetTableDBName() + "." + PPartnerTable.GetPartnerKeyDBName() + " = " + PUnitTable.GetTableDBName() + "." + PUnitTable.GetPartnerKeyDBName() + " AND " + PPartnerTable.GetTableDBName() + "." + PPartnerTable.GetPartnerKeyDBName() + " = " + PPartnerLocationTable.GetTableDBName() + "." + PPartnerLocationTable.GetPartnerKeyDBName() + " AND " + PLocationTable.GetTableDBName() + "." + PLocationTable.GetSiteKeyDBName() + " = " + PPartnerLocationTable.GetTableDBName() + "." + PPartnerLocationTable.GetSiteKeyDBName() + " AND " + PLocationTable.GetTableDBName() + "." + PLocationTable.GetLocationKeyDBName() + " = " + PPartnerLocationTable.GetTableDBName() + "." + PPartnerLocationTable.GetLocationKeyDBName() + " AND " + PCountryTable.GetTableDBName() + "." + PCountryTable.GetCountryCodeDBName() + " = " + PLocationTable.GetTableDBName() + "." + PLocationTable.GetCountryCodeDBName() + " AND " + PPartnerTable.GetStatusCodeDBName() + " = 'ACTIVE' " + " AND " + PPartnerTable.GetPartnerClassDBName() + " = 'UNIT' "; // sort rows according to name SqlStmt = SqlStmt + " ORDER BY " + PPartnerTable.GetPartnerShortNameDBName(); Events = DBAccess.GDBAccessObj.SelectDT(SqlStmt, "events", Transaction, SqlParameterList.ToArray()); Key[0] = Events.Columns[PPartnerTable.GetPartnerKeyDBName()]; Key[1] = Events.Columns[PPartnerLocationTable.GetSiteKeyDBName()]; Key[2] = Events.Columns[PPartnerLocationTable.GetLocationKeyDBName()]; Events.PrimaryKey = Key; }); return(Events); }
public static void GetData(string ATablename, TSearchCriteria[] ASearchCriteria, out TTypedDataTable AResultTable, TDBTransaction AReadTransaction) { AResultTable = null; string context = string.Format("GetData {0}", SharedConstants.MODULE_ACCESS_MANAGER); // check access permissions for the current user TModuleAccessManager.CheckUserPermissionsForTable(ATablename, TTablePermissionEnum.eCanRead); // TODO: auto generate if (ATablename == AApSupplierTable.GetTableDBName()) { AResultTable = AApSupplierAccess.LoadUsingTemplate(ASearchCriteria, AReadTransaction); } else if (ATablename == AApDocumentTable.GetTableDBName()) { AResultTable = AApDocumentAccess.LoadUsingTemplate(ASearchCriteria, AReadTransaction); } else if (ATablename == ATransactionTypeTable.GetTableDBName()) { AResultTable = ATransactionTypeAccess.LoadUsingTemplate(ASearchCriteria, AReadTransaction); } else if (ATablename == ACurrencyTable.GetTableDBName()) { AResultTable = ACurrencyAccess.LoadAll(AReadTransaction); } else if (ATablename == ADailyExchangeRateTable.GetTableDBName()) { AResultTable = ADailyExchangeRateAccess.LoadAll(AReadTransaction); } else if (ATablename == ACorporateExchangeRateTable.GetTableDBName()) { AResultTable = ACorporateExchangeRateAccess.LoadAll(AReadTransaction); } else if (ATablename == ACurrencyLanguageTable.GetTableDBName()) { AResultTable = ACurrencyLanguageAccess.LoadAll(AReadTransaction); } else if (ATablename == AFeesPayableTable.GetTableDBName()) { AResultTable = AFeesPayableAccess.LoadAll(AReadTransaction); } else if (ATablename == AFeesReceivableTable.GetTableDBName()) { AResultTable = AFeesReceivableAccess.LoadAll(AReadTransaction); } else if (ATablename == AAnalysisTypeTable.GetTableDBName()) { AResultTable = AAnalysisTypeAccess.LoadUsingTemplate(ASearchCriteria, AReadTransaction); } else if (ATablename == AGiftBatchTable.GetTableDBName()) { AResultTable = AGiftBatchAccess.LoadAll(AReadTransaction); } else if (ATablename == AJournalTable.GetTableDBName()) { AResultTable = AJournalAccess.LoadAll(AReadTransaction); } else if (ATablename == ALedgerTable.GetTableDBName()) { AResultTable = ALedgerAccess.LoadAll(AReadTransaction); } else if (ATablename == MExtractMasterTable.GetTableDBName()) { if (ASearchCriteria == null) { AResultTable = MExtractMasterAccess.LoadAll(AReadTransaction); } else { AResultTable = MExtractMasterAccess.LoadUsingTemplate(ASearchCriteria, AReadTransaction); } } else if (ATablename == MExtractTable.GetTableDBName()) { // it does not make sense to load ALL extract rows for all extract masters so search criteria needs to be set if (ASearchCriteria != null) { AResultTable = MExtractAccess.LoadUsingTemplate(ASearchCriteria, AReadTransaction); } } else if (ATablename == PcAttendeeTable.GetTableDBName()) { AResultTable = PcAttendeeAccess.LoadUsingTemplate(ASearchCriteria, AReadTransaction); } else if (ATablename == PcConferenceCostTable.GetTableDBName()) { AResultTable = PcConferenceCostAccess.LoadUsingTemplate(ASearchCriteria, AReadTransaction); } else if (ATablename == PcEarlyLateTable.GetTableDBName()) { AResultTable = PcEarlyLateAccess.LoadUsingTemplate(ASearchCriteria, AReadTransaction); } else if (ATablename == PcSupplementTable.GetTableDBName()) { AResultTable = PcSupplementAccess.LoadUsingTemplate(ASearchCriteria, AReadTransaction); } else if (ATablename == PcDiscountTable.GetTableDBName()) { AResultTable = PcDiscountAccess.LoadUsingTemplate(ASearchCriteria, AReadTransaction); } else if (ATablename == PCountryTable.GetTableDBName()) { AResultTable = PCountryAccess.LoadAll(AReadTransaction); } else if (ATablename == PFormTable.GetTableDBName()) { string[] columns = TTypedDataTable.GetColumnStringList(PFormTable.TableId); StringCollection fieldList = new StringCollection(); for (int i = 0; i < columns.Length; i++) { // Do not load the template document - we don't display it and it is big! if (columns[i] != PFormTable.GetTemplateDocumentDBName()) { fieldList.Add(columns[i]); } } AResultTable = PFormAccess.LoadAll(fieldList, AReadTransaction); } else if (ATablename == PInternationalPostalTypeTable.GetTableDBName()) { AResultTable = PInternationalPostalTypeAccess.LoadAll(AReadTransaction); } else if (ATablename == PtApplicationTypeTable.GetTableDBName()) { AResultTable = PtApplicationTypeAccess.LoadAll(AReadTransaction); } else if (ATablename == PFormalityTable.GetTableDBName()) { AResultTable = PFormalityAccess.LoadAll(AReadTransaction); } else if (ATablename == PMailingTable.GetTableDBName()) { AResultTable = PMailingAccess.LoadAll(AReadTransaction); } else if (ATablename == PPartnerGiftDestinationTable.GetTableDBName()) { AResultTable = PPartnerGiftDestinationAccess.LoadUsingTemplate(ASearchCriteria, AReadTransaction); } else if (ATablename == PmDocumentTypeTable.GetTableDBName()) { AResultTable = PmDocumentTypeAccess.LoadAll(AReadTransaction); } else if (ATablename == SGroupTable.GetTableDBName()) { TSecurityChecks.CheckUserModulePermissions(SharedConstants.PETRAMODULE_SYSADMIN, context); AResultTable = SGroupAccess.LoadAll(AReadTransaction); } else if (ATablename == SSystemDefaultsTable.GetTableDBName()) { TSecurityChecks.CheckUserModulePermissions(SharedConstants.PETRAMODULE_SYSADMIN, context); AResultTable = SSystemDefaultsAccess.LoadAll(AReadTransaction); } else if (ATablename == SSystemDefaultsGuiTable.GetTableDBName()) { AResultTable = SSystemDefaultsGuiAccess.LoadAll(AReadTransaction); } else { throw new Exception("TCommonDataReader.GetData: unknown table " + ATablename); } // Accept row changes here so that the Client gets 'unmodified' rows AResultTable.AcceptChanges(); }
/// <summary> /// Parses certain p_partner_location data columns' content into a data structure that is p_parnter_attribute /// representation. /// </summary> /// <remarks>Similar to code found in \csharp\ICT\BuildTools\DataDumpPetra2\FixData.cs, Method 'FixData', /// in the code section that starts with the comment 'Process p_partner_location records and migrate certain values /// of p_partner_location records to 'Contact Detail' records'.</remarks> /// <param name="AMainDS">Typed DataSet that holds the p_partner_location records that are to be parsed.</param> /// <param name="ATransaction">Instantiated DB Transaction.</param> public static void ParsePartnerLocationsForContactDetails(PartnerImportExportTDS AMainDS, TDBTransaction ATransaction) { DataTable PartnerLocationsDT; DataRow NewPartnerLocationDR; string TelephoneNumber = String.Empty; string FaxNumber = String.Empty; string PhoneExtension; string FaxExtension; // collect the partner classes foreach (PPartnerRow PartnerDR in AMainDS.PPartner.Rows) { TPartnerContactDetails.PartnerClassInformation[PartnerDR.PartnerKey] = PartnerDR.PartnerClass; } SortedList <long, DataTable> PartnerLocationsTables = new SortedList <long, DataTable>(); for (int counter = 0; counter < TPartnerContactDetails.NumberOfTables; counter++) { PartnerLocationsTables[counter] = TPartnerContactDetails.BestAddressHelper.GetNewPPartnerLocationTableInstance(); } TPartnerContactDetails.PartnerLocationRecords = PartnerLocationsTables; foreach (PPartnerLocationRow PartnerLocationDR in AMainDS.PPartnerLocation.Rows) { PartnerLocationsDT = PartnerLocationsTables[Math.Abs(PartnerLocationDR.PartnerKey) % TPartnerContactDetails.NumberOfTables]; DataRow LocationDR = AMainDS.PLocation.Rows.Find(new object[] { PartnerLocationDR.SiteKey, PartnerLocationDR.LocationKey }); // Phone Extension: Ignore if value in the dumped data is either null or 0 if (PartnerLocationDR.IsExtensionNull()) { PhoneExtension = String.Empty; } PhoneExtension = PartnerLocationDR.Extension.ToString(); if (PhoneExtension == "0") { PhoneExtension = String.Empty; } // Fax Extension: Ignore if value in the dumped data is either null or 0 if (PartnerLocationDR.IsFaxExtensionNull()) { FaxExtension = String.Empty; } FaxExtension = PartnerLocationDR.FaxExtension.ToString(); if (FaxExtension == "0") { FaxExtension = String.Empty; } if (!PartnerLocationDR.IsTelephoneNumberNull()) { // Concatenate Phone Number and Phone Extension ONLY if both of them aren't null and Phone Extension isn't 0 either. TelephoneNumber = PartnerLocationDR.TelephoneNumber + PhoneExtension; } if (!PartnerLocationDR.IsFaxNumberNull()) { // Concatenate Fax Number and Fax Extension ONLY if both of them aren't null and Fax Extension isn't 0 either. FaxNumber = PartnerLocationDR.FaxNumber + FaxExtension; } // Create representation of key data of the p_partner_location row and add it to the TPartnerContactDetails.PartnerLocationRecords Data Structure NewPartnerLocationDR = PartnerLocationsDT.NewRow(); NewPartnerLocationDR["p_partner_key_n"] = PartnerLocationDR.PartnerKey; NewPartnerLocationDR["p_site_key_n"] = PartnerLocationDR.SiteKey; NewPartnerLocationDR["p_location_key_i"] = PartnerLocationDR.LocationKey; if (!PartnerLocationDR.IsDateEffectiveNull()) { NewPartnerLocationDR["p_date_effective_d"] = PartnerLocationDR.DateEffective; } else { PartnerLocationDR.SetDateEffectiveNull(); } if (!PartnerLocationDR.IsDateGoodUntilNull()) { NewPartnerLocationDR["p_date_good_until_d"] = PartnerLocationDR.DateGoodUntil; } else { PartnerLocationDR.SetDateGoodUntilNull(); } NewPartnerLocationDR["p_location_type_c"] = PartnerLocationDR.LocationType; NewPartnerLocationDR["p_send_mail_l"] = PartnerLocationDR.SendMail; NewPartnerLocationDR["p_telephone_number_c"] = TelephoneNumber; NewPartnerLocationDR["p_fax_number_c"] = FaxNumber; NewPartnerLocationDR["p_mobile_number_c"] = PartnerLocationDR.MobileNumber; NewPartnerLocationDR["p_alternate_telephone_c"] = PartnerLocationDR.AlternateTelephone; NewPartnerLocationDR["p_email_address_c"] = PartnerLocationDR.EmailAddress; NewPartnerLocationDR["p_url_c"] = PartnerLocationDR.Url; NewPartnerLocationDR["p_value_country_c"] = LocationDR["p_country_code_c"]; PartnerLocationsDT.Rows.Add(NewPartnerLocationDR); } // get data for entire country table PCountryTable CountryTable = PCountryAccess.LoadAll(ATransaction); string InternatAccessCode = null; string SiteCountryCode = TAddressTools.GetCountryCodeFromSiteLedger(ATransaction); DataRow SiteCountryRow = CountryTable.Rows.Find(SiteCountryCode); // get InternatAccessCode for site country if (SiteCountryRow != null) { InternatAccessCode = SiteCountryRow[PCountryTable.GetInternatAccessCodeDBName()].ToString(); } TPartnerContactDetails.CreateContactDetailsRow = CreatePartnerContactDetailRecord; TPartnerContactDetails.EmptyStringIndicator = String.Empty; TPartnerContactDetails.PartnerAttributeHoldingDataSet = AMainDS; TPartnerContactDetails.CountryTable = CountryTable; TPartnerContactDetails.SiteCountryCode = SiteCountryCode; TPartnerContactDetails.SiteInternatAccessCode = InternatAccessCode; TPartnerContactDetails.PopulatePPartnerAttribute(); Ict.Petra.Shared.MPartner.Calculations.DeterminePartnerContactDetailAttributes(AMainDS.PPartnerAttribute); }
/// <summary> /// generate the units /// </summary> /// <param name="AFieldCSVFile"></param> public static void GenerateFields(string AFieldCSVFile) { XmlDocument doc = TCsv2Xml.ParseCSVFile2Xml(AFieldCSVFile, ","); XmlNode RecordNode = doc.FirstChild.NextSibling.FirstChild; PartnerImportExportTDS PartnerDS = new PartnerImportExportTDS(); GLSetupTDS GLSetupDS = new GLSetupTDS(); PCountryTable CountryTable = null; TDBTransaction Transaction = new TDBTransaction(); DBAccess.ReadTransaction( ref Transaction, delegate { CountryTable = PCountryAccess.LoadAll(Transaction); }); while (RecordNode != null) { PUnitRow UnitRow = PartnerDS.PUnit.NewRowTyped(); long id = 100 + Convert.ToInt64(TXMLParser.GetAttribute(RecordNode, "id")); UnitRow.PartnerKey = id * 1000000; string CountryCode = TXMLParser.GetAttribute(RecordNode, "Name"); UnitRow.UnitName = ((PCountryRow)CountryTable.Rows.Find(CountryCode)).CountryName; UnitRow.UnitTypeCode = "F"; PartnerDS.PUnit.Rows.Add(UnitRow); PPartnerRow PartnerRow = PartnerDS.PPartner.NewRowTyped(); PartnerRow.PartnerKey = UnitRow.PartnerKey; PartnerRow.PartnerShortName = UnitRow.UnitName; PartnerRow.PartnerClass = MPartnerConstants.PARTNERCLASS_UNIT; PartnerRow.StatusCode = MPartnerConstants.PARTNERSTATUS_ACTIVE; PartnerDS.PPartner.Rows.Add(PartnerRow); // add empty location so that the partner can be found in the Partner Find screen PPartnerLocationRow PartnerLocationRow = PartnerDS.PPartnerLocation.NewRowTyped(); PartnerLocationRow.PartnerKey = UnitRow.PartnerKey; PartnerLocationRow.LocationKey = 0; PartnerLocationRow.SiteKey = 0; PartnerDS.PPartnerLocation.Rows.Add(PartnerLocationRow); // create unit hierarchy UmUnitStructureRow UnitStructureRow = PartnerDS.UmUnitStructure.NewRowTyped(); UnitStructureRow.ParentUnitKey = 1000000; UnitStructureRow.ChildUnitKey = UnitRow.PartnerKey; PartnerDS.UmUnitStructure.Rows.Add(UnitStructureRow); // create special type PPartnerTypeRow PartnerTypeRow = PartnerDS.PPartnerType.NewRowTyped(); PartnerTypeRow.PartnerKey = UnitRow.PartnerKey; PartnerTypeRow.TypeCode = MPartnerConstants.PARTNERTYPE_LEDGER; PartnerDS.PPartnerType.Rows.Add(PartnerTypeRow); // create cost centre ACostCentreRow CostCentreRow = GLSetupDS.ACostCentre.NewRowTyped(); CostCentreRow.LedgerNumber = FLedgerNumber; CostCentreRow.CostCentreCode = (id * 100).ToString("0000"); CostCentreRow.CostCentreName = UnitRow.UnitName; CostCentreRow.CostCentreToReportTo = MFinanceConstants.INTER_LEDGER_HEADING; CostCentreRow.CostCentreType = MFinanceConstants.FOREIGN_CC_TYPE; GLSetupDS.ACostCentre.Rows.Add(CostCentreRow); // create foreign ledger, cost centre link validledgernumber AValidLedgerNumberRow ValidLedgerNumber = GLSetupDS.AValidLedgerNumber.NewRowTyped(); ValidLedgerNumber.LedgerNumber = FLedgerNumber; ValidLedgerNumber.PartnerKey = UnitRow.PartnerKey; ValidLedgerNumber.CostCentreCode = CostCentreRow.CostCentreCode; ValidLedgerNumber.IltProcessingCentre = Convert.ToInt64(MFinanceConstants.ICH_COST_CENTRE) * 10000; GLSetupDS.AValidLedgerNumber.Rows.Add(ValidLedgerNumber); RecordNode = RecordNode.NextSibling; } PartnerImportExportTDSAccess.SubmitChanges(PartnerDS); GLSetupTDSAccess.SubmitChanges(GLSetupDS); }
public static DataTable GetEventUnits(bool AIncludeConferenceUnits, bool AIncludeOutreachUnits, string AEventName, bool AIncludeLocationData, bool ACurrentAndFutureEventsOnly) { TDBTransaction ReadTransaction; Boolean NewTransaction = false; List <OdbcParameter> SqlParameterList = new List <OdbcParameter>(); DataColumn[] Key = new DataColumn[1]; DataTable Events = new DataTable(); if (AEventName == "*") { AEventName = ""; } else if (AEventName.EndsWith("*")) { AEventName = AEventName.Substring(0, AEventName.Length - 1); } if (TLogging.DL >= 9) { Console.WriteLine("GetEventUnits called!"); } ReadTransaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.RepeatableRead, TEnforceIsolationLevel.eilMinimum, out NewTransaction); try { string SqlStmt = "SELECT DISTINCT " + PPartnerTable.GetPartnerShortNameDBName() + ", " + PPartnerTable.GetPartnerClassDBName() + ", " + PUnitTable.GetOutreachCodeDBName(); if (AIncludeLocationData || ACurrentAndFutureEventsOnly) { SqlStmt = SqlStmt + ", " + PCountryTable.GetTableDBName() + "." + PCountryTable.GetCountryNameDBName() + ", " + PPartnerLocationTable.GetTableDBName() + "." + PPartnerLocationTable.GetDateEffectiveDBName() + ", " + PPartnerLocationTable.GetTableDBName() + "." + PPartnerLocationTable.GetDateGoodUntilDBName(); } SqlStmt = SqlStmt + ", " + PPartnerTable.GetTableDBName() + "." + PPartnerTable.GetPartnerKeyDBName() + ", " + PUnitTable.GetUnitTypeCodeDBName() + " FROM pub_" + PPartnerTable.GetTableDBName() + ", pub_" + PUnitTable.GetTableDBName(); if (AIncludeLocationData || ACurrentAndFutureEventsOnly) { SqlStmt = SqlStmt + ", pub_" + PLocationTable.GetTableDBName() + ", pub_" + PPartnerLocationTable.GetTableDBName() + ", pub_" + PCountryTable.GetTableDBName(); } SqlStmt = SqlStmt + " WHERE " + PPartnerTable.GetTableDBName() + "." + PPartnerTable.GetPartnerKeyDBName() + " = " + PUnitTable.GetTableDBName() + "." + PUnitTable.GetPartnerKeyDBName() + " AND "; if (AIncludeLocationData || ACurrentAndFutureEventsOnly) { SqlStmt = SqlStmt + PPartnerTable.GetTableDBName() + "." + PPartnerTable.GetPartnerKeyDBName() + " = " + PPartnerLocationTable.GetTableDBName() + "." + PPartnerLocationTable.GetPartnerKeyDBName() + " AND " + PLocationTable.GetTableDBName() + "." + PLocationTable.GetSiteKeyDBName() + " = " + PPartnerLocationTable.GetTableDBName() + "." + PPartnerLocationTable.GetSiteKeyDBName() + " AND " + PLocationTable.GetTableDBName() + "." + PLocationTable.GetLocationKeyDBName() + " = " + PPartnerLocationTable.GetTableDBName() + "." + PPartnerLocationTable.GetLocationKeyDBName() + " AND " + PCountryTable.GetTableDBName() + "." + PCountryTable.GetCountryCodeDBName() + " = " + PLocationTable.GetTableDBName() + "." + PLocationTable.GetCountryCodeDBName() + " AND "; } SqlStmt = SqlStmt + PPartnerTable.GetStatusCodeDBName() + " = 'ACTIVE' " + " AND " + PPartnerTable.GetPartnerClassDBName() + " = 'UNIT' "; // add criteria for conference and/or outreach String ConferenceWhereClause = "(" + PUnitTable.GetUnitTypeCodeDBName() + " LIKE '%CONF%' OR " + PUnitTable.GetUnitTypeCodeDBName() + " LIKE '%CONG%')"; String OutreachWhereClause = PUnitTable.GetOutreachCodeDBName() + " IS NOT NULL AND " + PUnitTable.GetOutreachCodeDBName() + " <> '' AND (" + PUnitTable.GetUnitTypeCodeDBName() + " NOT LIKE '%CONF%' AND " + PUnitTable.GetUnitTypeCodeDBName() + " NOT LIKE '%CONG%')"; if (AIncludeConferenceUnits && AIncludeOutreachUnits) { SqlStmt = SqlStmt + " AND ((" + ConferenceWhereClause + ") OR (" + OutreachWhereClause + "))"; } else if (AIncludeConferenceUnits) { SqlStmt = SqlStmt + " AND (" + ConferenceWhereClause + ")"; } else if (AIncludeOutreachUnits) { SqlStmt = SqlStmt + " AND (" + OutreachWhereClause + ")"; } // add criteria for event name filter if (AEventName.Length > 0) { // in case there is a filter set for the event name AEventName = AEventName.Replace('*', '%') + "%"; SqlStmt = SqlStmt + " AND " + PUnitTable.GetUnitNameDBName() + " LIKE '" + AEventName + "'"; } if (ACurrentAndFutureEventsOnly) { SqlStmt = SqlStmt + " AND " + PPartnerLocationTable.GetDateGoodUntilDBName() + " >= ?"; SqlParameterList.Add(new OdbcParameter("param_date", OdbcType.Date) { Value = DateTime.Today.Date }); } // sort rows according to name SqlStmt = SqlStmt + " ORDER BY " + PPartnerTable.GetPartnerShortNameDBName(); Events = DBAccess.GDBAccessObj.SelectDT(SqlStmt, "events", ReadTransaction, SqlParameterList.ToArray()); Key[0] = Events.Columns[PPartnerTable.GetPartnerKeyDBName()]; Events.PrimaryKey = Key; } catch (Exception e) { TLogging.Log(e.ToString()); } finally { if (NewTransaction) { DBAccess.GDBAccessObj.CommitTransaction(); if (TLogging.DL >= 7) { Console.WriteLine("GetEventUnits: committed own transaction."); } } } return(Events); }
public static void FillFormDataFromPersonnel(Int64 APartnerKey, TFormDataPerson AFormDataPerson, TFormLetterInfo AFormLetterInfo, TDBTransaction AReadTransaction, Int64 ASiteKey = 0, Int32 ALocationKey = 0) { TPartnerClass PartnerClass; String ShortName; TStdPartnerStatusCode PartnerStatusCode; if (AFormDataPerson == null) { return; } if (MCommonMain.RetrievePartnerShortName(APartnerKey, out ShortName, out PartnerClass, out PartnerStatusCode, AReadTransaction)) { // first retrieve all partner information // we cannot reference MPartner connect because of SimplePartnerEdit, cyclic dependencies #if DISABLED_TP_20180623 TFormLettersWebConnector.FillFormDataFromPerson(APartnerKey, AFormDataPerson, AFormLetterInfo, AReadTransaction, ASiteKey, ALocationKey); #endif // retrieve Special Needs information if (AFormLetterInfo.IsRetrievalRequested(TFormDataRetrievalSection.eSpecialNeeds)) { PmSpecialNeedTable SpecialNeedTable; PmSpecialNeedRow SpecialNeedRow; SpecialNeedTable = PmSpecialNeedAccess.LoadViaPPerson(APartnerKey, AReadTransaction); if (SpecialNeedTable.Count > 0) { SpecialNeedRow = (PmSpecialNeedRow)SpecialNeedTable.Rows[0]; AFormDataPerson.DietaryNeeds = SpecialNeedRow.DietaryComment; AFormDataPerson.MedicalNeeds = SpecialNeedRow.MedicalComment; AFormDataPerson.OtherNeeds = SpecialNeedRow.OtherSpecialNeed; AFormDataPerson.Vegetarian = SpecialNeedRow.VegetarianFlag; } } // retrieve Personal Data information if (AFormLetterInfo.IsRetrievalRequested(TFormDataRetrievalSection.ePersonalData)) { PmPersonalDataTable PersonalDataTable; PmPersonalDataRow PersonalDataRow; PersonalDataTable = PmPersonalDataAccess.LoadViaPPerson(APartnerKey, AReadTransaction); if (PersonalDataTable.Count > 0) { PersonalDataRow = (PmPersonalDataRow)PersonalDataTable.Rows[0]; if (!PersonalDataRow.IsBelieverSinceYearNull() && (PersonalDataRow.BelieverSinceYear != 0)) { AFormDataPerson.YearsBeliever = (DateTime.Today.Year - PersonalDataRow.BelieverSinceYear).ToString(); } AFormDataPerson.CommentBeliever = PersonalDataRow.BelieverSinceComment; } } // retrieve Passport information if (AFormLetterInfo.IsRetrievalRequested(TFormDataRetrievalSection.ePassport)) { PmPassportDetailsTable PassportTable; TFormDataPassport PassportRecord; PassportTable = PmPassportDetailsAccess.LoadViaPPerson(APartnerKey, AReadTransaction); Boolean MainPassportFound = false; foreach (PmPassportDetailsRow PassportRow in PassportTable.Rows) { // only list "full" passports that have not expired yet if ((PassportRow.IsDateOfExpirationNull() || (PassportRow.DateOfExpiration >= DateTime.Today)) && (PassportRow.PassportDetailsType == "P")) { PassportRecord = new TFormDataPassport(); PassportRecord.IsMainPassport = PassportRow.MainPassport; PassportRecord.Number = PassportRow.PassportNumber; PassportRecord.PassportName = PassportRow.FullPassportName; PassportRecord.NationalityCode = PassportRow.PassportNationalityCode; // retrieve country name from country table TCacheable CachePopulator = new TCacheable(); PCountryTable CountryTable = (PCountryTable)CachePopulator.GetCacheableTable(TCacheableCommonTablesEnum.CountryList); PCountryRow CountryRow = (PCountryRow)CountryTable.Rows.Find(new object[] { PassportRow.PassportNationalityCode }); if (CountryRow != null) { PassportRecord.NationalityName = CountryRow.CountryName; } PassportRecord.TypeCode = PassportRow.PassportDetailsType; // retrieve passport type name from type table TPersonnelCacheable PersonnelCachePopulator = new TPersonnelCacheable(); PtPassportTypeTable TypeTable = (PtPassportTypeTable)PersonnelCachePopulator.GetCacheableTable(TCacheablePersonTablesEnum. PassportTypeList); PtPassportTypeRow TypeRow = (PtPassportTypeRow)TypeTable.Rows.Find(new object[] { PassportRow.PassportDetailsType }); if (TypeRow != null) { PassportRecord.TypeDescription = TypeRow.Description; } PassportRecord.DateOfIssue = PassportRow.DateOfIssue; PassportRecord.PlaceOfIssue = PassportRow.PlaceOfIssue; PassportRecord.DateOfExpiry = PassportRow.DateOfExpiration; PassportRecord.PlaceOfBirth = PassportRow.PlaceOfBirth; // set number and nationality in main record (only for main passport or if there is just one) if (PassportRow.MainPassport || (PassportTable.Count == 1)) { AFormDataPerson.PassportNumber = PassportRecord.Number; AFormDataPerson.PassportNationality = PassportRecord.NationalityName; AFormDataPerson.PassportNationalityCode = PassportRecord.NationalityCode; AFormDataPerson.PassportName = PassportRecord.PassportName; AFormDataPerson.PassportDateOfIssue = PassportRecord.DateOfIssue; AFormDataPerson.PassportPlaceOfIssue = PassportRecord.PlaceOfIssue; AFormDataPerson.PassportDateOfExpiry = PassportRecord.DateOfExpiry; AFormDataPerson.PassportPlaceOfBirth = PassportRecord.PlaceOfBirth; MainPassportFound = true; } // If the PassportName has not been set yet then make sure it is set on Person level from at least one passport // (this will not be necessary any longer once the tick box for "Main Passport" is implemented) if (!MainPassportFound) { AFormDataPerson.PassportName = PassportRecord.PassportName; } AFormDataPerson.AddPassport(PassportRecord); } } } // retrieve Language information if (AFormLetterInfo.IsRetrievalRequested(TFormDataRetrievalSection.eLanguage)) { PmPersonLanguageTable PersonLanguageTable; TFormDataLanguage PersonLanguageRecord; PersonLanguageTable = PmPersonLanguageAccess.LoadViaPPerson(APartnerKey, AReadTransaction); foreach (PmPersonLanguageRow PersonLanguageRow in PersonLanguageTable.Rows) { PersonLanguageRecord = new TFormDataLanguage(); PersonLanguageRecord.Code = PersonLanguageRow.LanguageCode; // retrieve language name from language table TCacheable CachePopulator = new TCacheable(); PLanguageTable LanguageTable = (PLanguageTable)CachePopulator.GetCacheableTable(TCacheableCommonTablesEnum.LanguageCodeList); PLanguageRow LanguageRow = (PLanguageRow)LanguageTable.Rows.Find(new object[] { PersonLanguageRow.LanguageCode }); if (LanguageRow != null) { PersonLanguageRecord.Name = LanguageRow.LanguageDescription; } PersonLanguageRecord.Level = PersonLanguageRow.LanguageLevel.ToString(); // retrieve language level name from language level table TPersonnelCacheable CachePopulatorPersonnel = new TPersonnelCacheable(); PtLanguageLevelTable LanguageLevelTable = (PtLanguageLevelTable)CachePopulatorPersonnel.GetCacheableTable(TCacheablePersonTablesEnum.LanguageLevelList); PtLanguageLevelRow LanguageLevelRow = (PtLanguageLevelRow)LanguageLevelTable.Rows.Find(new object[] { PersonLanguageRow.LanguageLevel }); if (LanguageLevelRow != null) { PersonLanguageRecord.LevelDesc = LanguageLevelRow.LanguageLevelDescr; } PersonLanguageRecord.Comment = PersonLanguageRow.Comment; AFormDataPerson.AddLanguage(PersonLanguageRecord); } } // retrieve Skill information if (AFormLetterInfo.IsRetrievalRequested(TFormDataRetrievalSection.eSkill)) { PmPersonSkillTable PersonSkillTable; TFormDataSkill PersonSkillRecord; TFormDataDegree PersonDegreeRecord; PersonSkillTable = PmPersonSkillAccess.LoadViaPPerson(APartnerKey, AReadTransaction); foreach (PmPersonSkillRow PersonSkillRow in PersonSkillTable.Rows) { PersonSkillRecord = new TFormDataSkill(); PersonSkillRecord.Category = PersonSkillRow.SkillCategoryCode; PersonSkillRecord.Description = PersonSkillRow.DescriptionEnglish; // if no description in local language then use english PersonSkillRecord.DescriptionLocalOrDefault = PersonSkillRow.DescriptionLocal; if (PersonSkillRow.DescriptionLocal != "") { PersonSkillRecord.DescriptionLocalOrDefault = PersonSkillRow.DescriptionEnglish; } PersonSkillRecord.Level = PersonSkillRow.SkillLevel; // retrieve skill level name from skill level table TPersonnelCacheable CachePopulatorPersonnel = new TPersonnelCacheable(); PtSkillLevelTable SkillLevelTable = (PtSkillLevelTable)CachePopulatorPersonnel.GetCacheableTable(TCacheablePersonTablesEnum.SkillLevelList); PtSkillLevelRow SkillLevelRow = (PtSkillLevelRow)SkillLevelTable.Rows.Find(new object[] { PersonSkillRow.SkillLevel }); if (SkillLevelRow != null) { PersonSkillRecord.LevelDesc = SkillLevelRow.Description; } PersonSkillRecord.YearsExp = PersonSkillRow.YearsOfExperience; PersonSkillRecord.Professional = PersonSkillRow.ProfessionalSkill; PersonSkillRecord.Degree = PersonSkillRow.Degree; PersonSkillRecord.Comment = PersonSkillRow.Comment; AFormDataPerson.AddSkill(PersonSkillRecord); // now add a degree record if a degree is mentioned if (!PersonSkillRow.IsDegreeNull() && (PersonSkillRow.Degree.Length > 0)) { PersonDegreeRecord = new TFormDataDegree(); PersonDegreeRecord.Name = PersonSkillRow.Degree; PersonDegreeRecord.Year = PersonSkillRow.YearOfDegree.ToString(); AFormDataPerson.AddDegree(PersonDegreeRecord); } } } // retrieve past work experience information if (AFormLetterInfo.IsRetrievalRequested(TFormDataRetrievalSection.eWorkExperience)) { TFormDataWorkExperience PersonExpRecord; /* * currently we don't include application records in the work experience data * * String UnitShortName; * TPartnerClass UnitClass; * * // retrieve applications for short term events * String SqlStmt = TDataBase.ReadSqlFile("Personnel.FormLetters.GetAppTravelDates.sql"); * * OdbcParameter[] parameters = new OdbcParameter[1]; * parameters[0] = new OdbcParameter("PartnerKey", OdbcType.BigInt); * parameters[0].Value = APartnerKey; * * DataTable travelData = DBAccess.GDBAccessObj.SelectDT(SqlStmt, "TravelDates", ReadTransaction, parameters); * * for (int i = 0; i < travelData.Rows.Count; i++) * { * PersonExpRecord = new TFormDataWorkExperience(); * * if ((travelData.Rows[i][0]).GetType() == typeof(DateTime)) * { * PersonExpRecord.StartDate = (DateTime?)travelData.Rows[i][0]; * } * * if ((travelData.Rows[i][1]).GetType() == typeof(DateTime)) * { * PersonExpRecord.EndDate = (DateTime?)travelData.Rows[i][1]; * } * * PersonExpRecord.Organisation = ""; * PersonExpRecord.Role = ""; * PersonExpRecord.Category = ""; * PersonExpRecord.SameOrg = true; * PersonExpRecord.SimilarOrg = true; * PersonExpRecord.Comment = ""; * * // check if unit exists and use unit name as location * if (TPartnerServerLookups.GetPartnerShortName((Int64)travelData.Rows[i][2], out UnitShortName, out UnitClass)) * { * PersonExpRecord.Location = UnitShortName; * } * else * { * PersonExpRecord.Location = travelData.Rows[i][3].ToString(); * } * * AFormDataPerson.AddWorkExperience(PersonExpRecord); * } */ // retrieve actual past experience records PmPastExperienceTable PersonExpTable; PersonExpTable = PmPastExperienceAccess.LoadViaPPerson(APartnerKey, AReadTransaction); PUnitTable UnitTable; PUnitRow UnitRow; foreach (PmPastExperienceRow PersonExpRow in PersonExpTable.Rows) { PersonExpRecord = new TFormDataWorkExperience(); PersonExpRecord.StartDate = PersonExpRow.StartDate; PersonExpRecord.EndDate = PersonExpRow.EndDate; PersonExpRecord.Location = PersonExpRow.PrevLocation; PersonExpRecord.Organisation = PersonExpRow.OtherOrganisation; PersonExpRecord.Role = PersonExpRow.PrevRole; PersonExpRecord.Category = PersonExpRow.Category; PersonExpRecord.SameOrg = PersonExpRow.PrevWorkHere; PersonExpRecord.SimilarOrg = PersonExpRow.PrevWork; PersonExpRecord.Comment = PersonExpRow.PastExpComments; // check if previous experience came from an event with location set to event code // -> in this case don't set event code as location but rather the event name PUnitRow template = new PUnitTable().NewRowTyped(false); template.OutreachCode = PersonExpRow.PrevLocation; UnitTable = PUnitAccess.LoadUsingTemplate(template, AReadTransaction); if (UnitTable.Rows.Count > 0) { UnitRow = (PUnitRow)UnitTable.Rows[0]; PersonExpRecord.Location = UnitRow.UnitName; } AFormDataPerson.AddWorkExperience(PersonExpRecord); } } // retrieve Commitment information if (AFormLetterInfo.IsRetrievalRequested(TFormDataRetrievalSection.eCommitment) || AFormLetterInfo.IsRetrievalRequested(TFormDataRetrievalSection.eFutureCommitment)) { String FieldName; TPartnerClass FieldPartnerClass; PmStaffDataTable PersonCommitmentTable; PmStaffDataRow PersonCommitmentRow; TFormDataCommitment PersonCommitmentRecord; PersonCommitmentTable = PmStaffDataAccess.LoadViaPPerson(APartnerKey, AReadTransaction); PersonCommitmentTable.DefaultView.Sort = PmStaffDataTable.GetStartOfCommitmentDBName() + " DESC"; if (AFormLetterInfo.IsRetrievalRequested(TFormDataRetrievalSection.eCommitment)) { foreach (DataRowView rv in PersonCommitmentTable.DefaultView) { PersonCommitmentRow = (PmStaffDataRow)rv.Row; PersonCommitmentRecord = new TFormDataCommitment(); PersonCommitmentRecord.StartDate = PersonCommitmentRow.StartOfCommitment; PersonCommitmentRecord.EndDate = PersonCommitmentRow.EndOfCommitment; PersonCommitmentRecord.Status = PersonCommitmentRow.StatusCode; PersonCommitmentRecord.ReceivingFieldKey = PersonCommitmentRow.ReceivingField.ToString("0000000000"); TPartnerServerLookups.GetPartnerShortName(PersonCommitmentRow.ReceivingField, out FieldName, out FieldPartnerClass); PersonCommitmentRecord.ReceivingFieldName = FieldName; PersonCommitmentRecord.SendingFieldKey = PersonCommitmentRow.HomeOffice.ToString("0000000000"); TPartnerServerLookups.GetPartnerShortName(PersonCommitmentRow.HomeOffice, out FieldName, out FieldPartnerClass); PersonCommitmentRecord.SendingFieldName = FieldName; PersonCommitmentRecord.RecruitingFieldKey = PersonCommitmentRow.OfficeRecruitedBy.ToString("0000000000"); TPartnerServerLookups.GetPartnerShortName(PersonCommitmentRow.OfficeRecruitedBy, out FieldName, out FieldPartnerClass); PersonCommitmentRecord.RecruitingFieldName = FieldName; PersonCommitmentRecord.Comment = PersonCommitmentRow.StaffDataComments; AFormDataPerson.AddCommitment(PersonCommitmentRecord); } } if (AFormLetterInfo.IsRetrievalRequested(TFormDataRetrievalSection.eFutureCommitment)) { foreach (DataRowView rv in PersonCommitmentTable.DefaultView) { PersonCommitmentRow = (PmStaffDataRow)rv.Row; if (PersonCommitmentRow.StartOfCommitment >= DateTime.Today) { TPartnerServerLookups.GetPartnerShortName(PersonCommitmentRow.ReceivingField, out FieldName, out FieldPartnerClass); AFormDataPerson.FutureFieldName = FieldName; AFormDataPerson.FutureCommitStartDate = PersonCommitmentRow.StartOfCommitment; AFormDataPerson.FutureCommitEndDate = PersonCommitmentRow.EndOfCommitment; // only use the first commitment (list is sorted by start date) break; } } } } } }
/// <summary> /// Passes data as a Typed DataSet to the caller, containing a DataTable that corresponds with <paramref name="AIndivDataItem"></paramref>. /// </summary> /// <param name="APartnerKey">PartnerKey of the Person to load data for.</param> /// <param name="AIndivDataItem">The Individual Data Item for which data should be returned.</param> /// <param name="AReadTransaction">Open Database transaction.</param> /// <returns>A Typed DataSet containing a DataTable that corresponds with <paramref name="AIndivDataItem"></paramref>.</returns> private static IndividualDataTDS GetData(Int64 APartnerKey, TIndividualDataItemEnum AIndivDataItem, TDBTransaction AReadTransaction) { IndividualDataTDS IndividualDataDS = new IndividualDataTDS("IndividualData"); // create the IndividualDataTDS DataSet that will later be passed to the Client IndividualDataTDSMiscellaneousDataTable MiscellaneousDataDT; IndividualDataTDSMiscellaneousDataRow MiscellaneousDataDR; #region Create 'Miscellaneous' DataRow MiscellaneousDataDT = IndividualDataDS.MiscellaneousData; MiscellaneousDataDR = MiscellaneousDataDT.NewRowTyped(false); MiscellaneousDataDR.PartnerKey = APartnerKey; MiscellaneousDataDT.Rows.Add(MiscellaneousDataDR); #endregion switch (AIndivDataItem) { case TIndividualDataItemEnum.idiSummary: BuildSummaryData(APartnerKey, ref IndividualDataDS, AReadTransaction); DetermineItemCounts(MiscellaneousDataDR, AReadTransaction); break; case TIndividualDataItemEnum.idiPersonalLanguages: PmPersonLanguageAccess.LoadViaPPerson(IndividualDataDS, APartnerKey, AReadTransaction); PLanguageTable LanguageTable = (PLanguageTable)TSharedDataCache.TMCommon.GetCacheableCommonTable( TCacheableCommonTablesEnum.LanguageCodeList); PLanguageRow LanguageRow; foreach (IndividualDataTDSPmPersonLanguageRow PersonLanguageRow in IndividualDataDS.PmPersonLanguage.Rows) { LanguageRow = (PLanguageRow)LanguageTable.Rows.Find(new object[] { PersonLanguageRow.LanguageCode }); if (LanguageRow != null) { PersonLanguageRow.LanguageDescription = LanguageRow.LanguageDescription; } } break; case TIndividualDataItemEnum.idiSpecialNeeds: PmSpecialNeedAccess.LoadByPrimaryKey(IndividualDataDS, APartnerKey, AReadTransaction); break; case TIndividualDataItemEnum.idiPreviousExperiences: PmPastExperienceAccess.LoadViaPPerson(IndividualDataDS, APartnerKey, AReadTransaction); PUnitTable UnitTable; PUnitRow UnitRow; // For outreaches the event code is currently stored in the location field. Try to retrieve the correct // outreach event and return it's actual name (as the event does not mean much to anybody). foreach (IndividualDataTDSPmPastExperienceRow PastExpRow in IndividualDataDS.PmPastExperience.Rows) { PUnitRow template = new PUnitTable().NewRowTyped(false); template.OutreachCode = PastExpRow.PrevLocation; UnitTable = PUnitAccess.LoadUsingTemplate(template, AReadTransaction); if (UnitTable.Rows.Count > 0) { UnitRow = (PUnitRow)UnitTable.Rows[0]; PastExpRow.EventName = UnitRow.UnitName; } } break; case TIndividualDataItemEnum.idiPersonalDocuments: PmDocumentAccess.LoadViaPPerson(IndividualDataDS, APartnerKey, AReadTransaction); break; case TIndividualDataItemEnum.idiJobAssignments: PmJobAssignmentAccess.LoadViaPPartner(IndividualDataDS, APartnerKey, AReadTransaction); break; case TIndividualDataItemEnum.idiLocalPersonnelData: // TODO: Fix this so LocalPersonnelData can actually load some data bool labelsAvailable; TOfficeSpecificDataLabelsUIConnector OfficeSpecificDataLabelsUIConnector; OfficeSpecificDataLabelsUIConnector = new TOfficeSpecificDataLabelsUIConnector(APartnerKey, TOfficeSpecificDataLabelUseEnum.Personnel); IndividualDataDS.Merge(OfficeSpecificDataLabelsUIConnector.GetDataLocalPartnerDataValues(APartnerKey, out labelsAvailable, false, AReadTransaction)); break; case TIndividualDataItemEnum.idiProgressReports: PmPersonEvaluationAccess.LoadViaPPerson(IndividualDataDS, APartnerKey, AReadTransaction); break; case TIndividualDataItemEnum.idiCommitmentPeriods: PmStaffDataAccess.LoadViaPPerson(IndividualDataDS, APartnerKey, AReadTransaction); break; case TIndividualDataItemEnum.idiPersonSkills: PmPersonSkillAccess.LoadViaPPerson(IndividualDataDS, APartnerKey, AReadTransaction); break; case TIndividualDataItemEnum.idiPersonalAbilities: PmPersonAbilityAccess.LoadViaPPerson(IndividualDataDS, APartnerKey, AReadTransaction); break; case TIndividualDataItemEnum.idiPassportDetails: PmPassportDetailsAccess.LoadViaPPerson(IndividualDataDS, APartnerKey, AReadTransaction); PCountryTable CountryTable = (PCountryTable)TSharedDataCache.TMCommon.GetCacheableCommonTable( TCacheableCommonTablesEnum.CountryList); PCountryRow CountryRow; foreach (IndividualDataTDSPmPassportDetailsRow PassportRow in IndividualDataDS.PmPassportDetails.Rows) { CountryRow = (PCountryRow)CountryTable.Rows.Find(new object[] { PassportRow.PassportNationalityCode }); if (CountryRow != null) { PassportRow.PassportNationalityName = CountryRow.CountryName; } } break; case TIndividualDataItemEnum.idiPersonalData: PmPersonalDataAccess.LoadByPrimaryKey(IndividualDataDS, APartnerKey, AReadTransaction); break; case TIndividualDataItemEnum.idiEmergencyData: PmPersonalDataAccess.LoadByPrimaryKey(IndividualDataDS, APartnerKey, AReadTransaction); break; case TIndividualDataItemEnum.idiApplications: PmGeneralApplicationAccess.LoadViaPPersonPartnerKey(IndividualDataDS, APartnerKey, AReadTransaction); PmShortTermApplicationAccess.LoadViaPPerson(IndividualDataDS, APartnerKey, AReadTransaction); PmYearProgramApplicationAccess.LoadViaPPerson(IndividualDataDS, APartnerKey, AReadTransaction); IndividualDataTDSPmGeneralApplicationRow GenAppRow; TPartnerClass PartnerClass; TStdPartnerStatusCode PartnerStatus; String EventOrFieldName; //TODO: now go through all short and long term apps and set the // two fields in general app for EventOrFieldName and ApplicationForEventOrField foreach (PmShortTermApplicationRow ShortTermRow in IndividualDataDS.PmShortTermApplication.Rows) { GenAppRow = (IndividualDataTDSPmGeneralApplicationRow)IndividualDataDS.PmGeneralApplication.Rows.Find (new object[] { ShortTermRow.PartnerKey, ShortTermRow.ApplicationKey, ShortTermRow.RegistrationOffice }); GenAppRow.ApplicationForEventOrField = Catalog.GetString("Event"); if (!ShortTermRow.IsStConfirmedOptionNull()) { Ict.Petra.Server.MCommon.MCommonMain.RetrievePartnerShortName (ShortTermRow.StConfirmedOption, out EventOrFieldName, out PartnerClass, out PartnerStatus); GenAppRow.EventOrFieldName = EventOrFieldName; } } foreach (PmYearProgramApplicationRow LongTermRow in IndividualDataDS.PmYearProgramApplication.Rows) { GenAppRow = (IndividualDataTDSPmGeneralApplicationRow)IndividualDataDS.PmGeneralApplication.Rows.Find (new object[] { LongTermRow.PartnerKey, LongTermRow.ApplicationKey, LongTermRow.RegistrationOffice }); GenAppRow.ApplicationForEventOrField = Catalog.GetString("Field"); if (!GenAppRow.IsGenAppPossSrvUnitKeyNull()) { Ict.Petra.Server.MCommon.MCommonMain.RetrievePartnerShortName (GenAppRow.GenAppPossSrvUnitKey, out EventOrFieldName, out PartnerClass, out PartnerStatus); GenAppRow.EventOrFieldName = EventOrFieldName; } } break; // TODO: work on all cases/load data for all Individual Data items } return(IndividualDataDS); }