/// <summary> /// Gets called in regular intervals from a Timer in Class TTimedProcessing. /// </summary> /// <param name="ADataBaseObj">Instantiated DB Access object with opened DB connection.</param> /// <param name="ARunManually">this is true if the process was called manually from the server admin console</param> public static void Process(TDataBase ADataBaseObj, bool ARunManually) { // only check once a day (or as specified in config file), if not manually called if (!ARunManually) { DateTime LastRun = TVariant.DecodeFromString( TSystemDefaults.GetStringDefault( PROCESSDATACHECK_LAST_RUN, new TVariant(DateTime.MinValue).EncodeToString())).ToDate(); if (LastRun.AddDays(TAppSettingsManager.GetInt16("DataChecks.RunEveryXDays", 1)) > DateTime.Now) { // do not run the data check more than once a day or a week (depending on configuration setting), too many emails TLogging.LogAtLevel(1, "TProcessDataChecks.Process: not running, since last run was at " + LastRun.ToString()); return; } } Errors_SinceDate = DateTime.Today.AddDays(-1 * SENDREPORTFORDAYS_TOUSERS); TLogging.LogAtLevel(1, "TProcessDataChecks.Process: Checking Modules"); CheckModule(ADataBaseObj, "DataCheck.MPartner."); TSystemDefaults.SetSystemDefault(PROCESSDATACHECK_LAST_RUN, new TVariant(DateTime.Now).EncodeToString()); }
private void InitializeManualCode() { // set the number of days to default according to settings used in System Manager String NumberOfDays = TSystemDefaults.GetStringDefault (SharedConstants.SYSDEFAULT_PURGEEXTRACTS, "no,365").Split(',')[1]; txtNumberOfDays.NumberValueInt = Convert.ToInt32(NumberOfDays); FPurgingSuccessful = false; }
/// <summary> /// If the wrapper didn't initialise, the caller can call this. /// </summary> public void ShowErrorPopup() { // in OpenPetra OpenSource, we do not use the FastReport DLLs return; // Note from AlanP: This method will show an appropriate Fast Reports error message box depending on the InitState // We want to show this error if FastReports is supposed to be used but is not installed. // We do not want to show it if FastReports is NOT supposed to be used.... // If FastReports is not supposed to be used the database will have an entry: USEXMLREPORTS (in system defaults table) // However the only quirk to this simple arrangement is that in OM we do want to use FastReports - but it does not HAVE to be installed // in many circumstances. It may well not be installed on our continuous integration server for example. // When the CI server runs the test suite, one of the tests is to open all the main screens from the main menu. // It does this on a 'new', 'blank' database which will not have 'USEXMLREPORTS' in the defaults table. // As a result the test fails because an unexpected modal dialog appears that is not dealt with // So we would like to know if the method is being run in the context of a test or not. // We achieve this by the first line of code in the method. // If FPetraUtilsObject is null, this wrapper has been created using the constructor that specifies the ReportName. // This is never used (at present anyway) in the context of a test. // If FPetraUtilsObject is non-null, we can always (at present) detect the difference between a screen opened from the main menu and a screen opened for a test // because, in the latter case, the CallerForm will be null. // If, in the future, this 'workaround' can no longer be used (because we start to use a FastReports test?), we will have to do things differently. Boolean IsTestContext = (FPetraUtilsObject != null) && (FPetraUtilsObject.GetCallerForm() == null); if ((TSystemDefaults.GetStringDefault("USEXMLREPORTS", "Not Specified") == "Not Specified") && !IsTestContext) { String Msg = ""; switch (FInitState) { case TInitState.LoadTemplate: { Msg = String.Format("no reporting template found for {0}.", FReportName); break; } case TInitState.InitSystem: { Msg = "the DLL failed to initialise."; break; } default: { return; // Anything else is not an error... } } MessageBox.Show("The FastReports subsystem did not initialise:\r\n" + Msg + "\r\n(To suppress this message, set USEXMLREPORTS in SystemDefaults.)", "Reporting engine"); } }
private void InitializeManualCode() { // set the number of days to default according to settings used in System Manager String NumberOfDays = TSystemDefaults.GetStringDefault (SharedConstants.SYSDEFAULT_PURGEEXTRACTS, "no,365").Split(',')[1]; txtNumberOfDays.NumberValueInt = Convert.ToInt32(NumberOfDays); if ((UserInfo.GUserInfo.IsInModule("PTNRADMIN") == false) && (TSystemDefaults.GetBooleanDefault(SharedConstants.SYSDEFAULT_MODIFY_PUBLIC_EXTRACTS_REQUIRES_ADMIN, false) == true)) { FRestrictToCurrentClient = true; chkAllUsers.Enabled = false; cmbUser.SetSelectedString(UserInfo.GUserInfo.UserID); cmbUser.Enabled = false; } FPurgingSuccessful = false; }
private void InitializeManualCode() { FTaxGovIdLabel = TSystemDefaults.GetStringDefault(SharedConstants.SYSDEFAULT_GOVID_LABEL, string.Empty); FTaxGovIdKeyName = TSystemDefaults.GetStringDefault(SharedConstants.SYSDEFAULT_GOVID_DB_KEY_NAME, string.Empty); if (FTaxGovIdLabel != string.Empty) { this.Text = string.Format("{0} ({1})", this.Text, FTaxGovIdLabel); } nudPartnerKeyColumn.Minimum = 1; nudPartnerKeyColumn.Maximum = 25; nudPartnerKeyColumn.Increment = 1; nudTaxCodeColumn.Minimum = 1; nudTaxCodeColumn.Maximum = 25; nudTaxCodeColumn.Increment = 1; }
/// <summary> /// todoComment /// </summary> /// <param name="ALabelText"></param> /// <param name="AName"></param> public static void GetLocStrCounty(out String ALabelText, out String AName) { String LocalisedCountyLabel; LocalisedCountyLabel = TSystemDefaults.GetStringDefault(SharedConstants.SYSDEFAULT_LOCALISEDCOUNTYLABEL); if (LocalisedCountyLabel.Trim() != String.Empty) { if (!LocalisedCountyLabel.EndsWith(":")) { LocalisedCountyLabel = LocalisedCountyLabel + ':'; } ALabelText = LocalisedCountyLabel; } else { ALabelText = StrCountyDefaultLabel; } // Remove & and : from the LabelText to get the 'Name' of the field AName = ALabelText.Replace("&", ""); AName = AName.Replace(":", ""); }
/// <summary> /// Looks for gifts where the recipient is an ExWorker and asks the user if they want to continue. /// (Make sure GetDataFromControls is called before this method so that AMainDS is up-to-date.) /// </summary> /// <param name="AAction">Why this method is being called</param> /// <param name="AMainDS"></param> /// <param name="APetraUtilsObject"></param> /// <param name="APostingGiftDetails">Only used when being called in order to carry out a batch posting</param> /// <returns>Returns true if saving/posting can continue</returns> public static bool CanContinueWithAnyExWorkers(GiftBatchAction AAction, GiftBatchTDS AMainDS, TFrmPetraEditUtils APetraUtilsObject, DataTable APostingGiftDetails = null) { DataTable ExWorkers = null; string Msg = string.Empty; int BatchNumber = -1; int ExWorkerGifts = 0; string ExWorkerSpecialType = TSystemDefaults.GetStringDefault(SharedConstants.SYSDEFAULT_EXWORKERSPECIALTYPE, "EX-WORKER"); // first check for Ex-Workers in the batch that is being posted/submitted (if a batch is being posted/submitted) if ((APostingGiftDetails != null) && (APostingGiftDetails.Rows.Count > 0)) { ExWorkers = TRemote.MFinance.Gift.WebConnectors.FindGiftRecipientExWorker(APostingGiftDetails, BatchNumber); ExWorkerGifts += ExWorkers.Rows.Count; Msg = GetExWorkersString(AAction, ExWorkerSpecialType, ExWorkers); if (ExWorkers.Rows.Count > 0) { BatchNumber = (int)APostingGiftDetails.Rows[0][GiftBatchTDSAGiftDetailTable.GetBatchNumberDBName()]; } } // check for Ex-Workers in all added and modified data if (APetraUtilsObject.HasChanges) { DataTable Changes = new DataTable(); if (AMainDS.AGiftDetail.GetChangesTyped() != null) { Changes.Merge(AMainDS.AGiftDetail.GetChangesTyped()); } else if (AMainDS.ARecurringGiftDetail.GetChangesTyped() != null) { Changes.Merge(AMainDS.ARecurringGiftDetail.GetChangesTyped()); } if ((Changes != null) && (Changes.Rows.Count > 0)) { ExWorkers = TRemote.MFinance.Gift.WebConnectors.FindGiftRecipientExWorker(Changes, BatchNumber); ExWorkerGifts += ExWorkers.Rows.Count; Msg += GetExWorkersString(null, ExWorkerSpecialType, ExWorkers); } } // alert the user to any recipients who are Ex-Workers if (Msg != string.Empty) { if (AAction == GiftBatchAction.SAVING) { Msg += Environment.NewLine + Environment.NewLine; Msg += Catalog.GetString("Do you want to continue with saving anyway?"); } else { Msg += Environment.NewLine + Environment.NewLine; Msg += Catalog.GetString("(any changes will also need to be saved before "); if (AAction == GiftBatchAction.NEWBATCH) { Msg += Catalog.GetString("a new batch can be created"); } else //POSTING, CANCELLING, SUBMITTING, DELETING { Msg += Catalog.GetString("this batch continues with " + AAction.ToString().ToLower()); } Msg += ")" + Environment.NewLine + Environment.NewLine; Msg += Catalog.GetString("Do you want to continue?"); } TFrmExtendedMessageBox extendedMessageBox = new TFrmExtendedMessageBox(APetraUtilsObject.GetForm()); if (extendedMessageBox.ShowDialog(Msg, Catalog.GetString("Ex-Workers Found"), string.Empty, TFrmExtendedMessageBox.TButtons.embbYesNo, TFrmExtendedMessageBox.TIcon.embiWarning) == TFrmExtendedMessageBox.TResult.embrNo) { return(false); } } return(true); }
public static Boolean GetMotivationGroupAndDetail(Int64 APartnerKey, ref String AMotivationGroup, ref String AMotivationDetail) { Boolean PartnerKeyIsValid = false; if (APartnerKey != 0) { string MotivationGroup = MFinanceConstants.MOTIVATION_GROUP_GIFT; string MotivationDetail = AMotivationDetail; TDBTransaction readTransaction = null; DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadCommitted, TEnforceIsolationLevel.eilMinimum, ref readTransaction, delegate { PPartnerTable myPPartnerTable = null; myPPartnerTable = PPartnerAccess.LoadByPrimaryKey(APartnerKey, readTransaction); if (myPPartnerTable.Rows.Count == 1) { // Entry for partnerKey is valid PartnerKeyIsValid = true; PPartnerRow partnerRow = null; partnerRow = (PPartnerRow)myPPartnerTable.Rows[0]; // Change motivationDetail if ColumnPartnerClass is UNIT if (partnerRow.PartnerClass.Equals(MPartnerConstants.PARTNERCLASS_UNIT)) { // AND KEY-MIN bool KeyMinFound = false; // first check if a motivation detail is linked to this potential key min AMotivationDetailTable MotivationDetailTable = null; MotivationDetailTable = AMotivationDetailAccess.LoadViaPPartner(APartnerKey, readTransaction); if ((MotivationDetailTable != null) && (MotivationDetailTable.Rows.Count > 0)) { foreach (AMotivationDetailRow Row in MotivationDetailTable.Rows) { if (Row.MotivationStatus) { MotivationGroup = MotivationDetailTable[0].MotivationGroupCode; MotivationDetail = MotivationDetailTable[0].MotivationDetailCode; KeyMinFound = true; break; } } } // second check to see if this is a key min if (!KeyMinFound) { PUnitTable pUnitTable = null; pUnitTable = PUnitAccess.LoadByPrimaryKey(APartnerKey, readTransaction); if (pUnitTable.Rows.Count == 1) { PUnitRow unitRow = null; unitRow = (PUnitRow)pUnitTable.Rows[0]; if (unitRow.UnitTypeCode.Equals(MPartnerConstants.UNIT_TYPE_KEYMIN)) { MotivationDetail = MFinanceConstants.GROUP_DETAIL_KEY_MIN; } else { MotivationDetail = TSystemDefaults.GetStringDefault(SharedConstants.SYSDEFAULT_DEFAULTFIELDMOTIVATION, MFinanceConstants.GROUP_DETAIL_FIELD); // if system default is empty then set to FIELD if (string.IsNullOrEmpty(MotivationDetail)) { MotivationDetail = MFinanceConstants.GROUP_DETAIL_FIELD; } } } } } else { MotivationDetail = MFinanceConstants.GROUP_DETAIL_SUPPORT; } } }); AMotivationGroup = MotivationGroup; AMotivationDetail = MotivationDetail; } return(PartnerKeyIsValid); }
} // Load Hosa Report Data private Boolean LoadStewardshipReportData(TRptCalculator ACalc) { Dictionary <String, TVariant> paramsDictionary = InitialiseDictionary(ACalc); DataTable ReportTable = TRemote.MReporting.WebConnectors.GetReportDataTable("Stewardship", paramsDictionary); if (this.IsDisposed) { return(false); } if (ReportTable == null) { FPetraUtilsObject.WriteToStatusBar("Report Cancelled."); return(false); } MyFastReportsPlugin.RegisterData(ReportTable, "Stewardship"); Boolean HasData = (ReportTable.Rows.Count > 0); if (!HasData) { FStatusMsg += Catalog.GetString("No Stewardship entries found for selected Run Number."); } TParameterList Params = ACalc.GetParameters(); if ((!Params.Get("param_design_template").ToBool()) && (rbtEmailStewardship.Checked)) { // This gets email defaults from the user settings table TUC_EmailPreferences.LoadEmailDefaults(); // This gets some of the settings from the server configuration. We no longer get these items from local PC. // SmtpUsername and SmtpPassword will usually be null string smtpHost, smtpUsername, smtpPassword; int smtpPort; bool smtpUseSSL; TRemote.MSysMan.Application.WebConnectors.GetServerSmtpSettings(out smtpHost, out smtpPort, out smtpUseSSL, out smtpUsername, out smtpPassword); if ((smtpHost == string.Empty) || (smtpPort < 0)) { FStatusMsg += Catalog.GetString( "\r\nCannot send email because 'smtpHost' and/or 'smtpPort' are not configured in the OP server configuration file."); return(false); } TSmtpSender EmailSender = new TSmtpSender(smtpHost, smtpPort, smtpUseSSL, smtpUsername, smtpPassword, ""); EmailSender.CcEverythingTo = TUserDefaults.GetStringDefault("SmtpCcTo"); EmailSender.ReplyTo = TUserDefaults.GetStringDefault("SmtpReplyTo"); if (!EmailSender.FInitOk) { FStatusMsg += String.Format( Catalog.GetString( "\r\nFailed to set up the email server.\n Please check the settings in Preferences / Email.\n Message returned: \"{0}\""), EmailSender.FErrorStatus ); return(false); } String MyCostCentreCode = String.Format("{0:##00}00", FLedgerNumber); String PeriodEnd = Params.Get("param_end_date").ToDate().ToString("dd/MM/yyyy"); Int32 RunNumber = Params.Get("param_cmbICHNumber").ToInt32(); String CsvAttachment = String.Format("\"{0}\",{1},\"{2}\",{3},\"{4}\",{5}\n", // "** Header **",30/11/2014,\"0200\",09/12/2014,\"USD\",0" "** Header **", // software originator and version ID PeriodEnd, MyCostCentreCode, // Field Cost Centre Code DateTime.Now.ToString("dd/MM/yyyy"), FLedgerRow.BaseCurrency, // Stewardship Report CSV always in Base Currency RunNumber // Run number ); foreach (DataRow Row in ReportTable.Rows) { CsvAttachment += String.Format("\"{0}\",{1},{2},{3}\n", Row["CostCentreCode"].ToString(), Convert.ToDecimal(Row["Income"]).ToString("0.00", CultureInfo.InvariantCulture), // Stewardship Report CSV always in Base Currency Convert.ToDecimal(Row["Expense"]).ToString("0.00", CultureInfo.InvariantCulture), Convert.ToDecimal(Row["Xfer"]).ToString("0.00", CultureInfo.InvariantCulture) ); } // Andrea wants this systemj default to be manually added to database when we are ready for a system to send ICH emails if (!TSystemDefaults.IsSystemDefaultDefined(STEWARDSHIP_EMAIL_ADDRESS)) { FStatusMsg += Catalog.GetString("\r\n Stewardship email address not configured in System Defaults."); return(false); } String EmailRecipient = TSystemDefaults.GetStringDefault(STEWARDSHIP_EMAIL_ADDRESS); String EmailBody = TUserDefaults.GetStringDefault("SmtpEmailBody"); EmailSender.AttachFromStream(new MemoryStream(Encoding.ASCII.GetBytes(CsvAttachment)), "Stewardship_" + MyCostCentreCode + ".csv"); Boolean SentOk = EmailSender.SendEmail( TUserDefaults.GetStringDefault("SmtpFromAccount"), TUserDefaults.GetStringDefault("SmtpDisplayName"), EmailRecipient, //[email protected] "Stewardship Report [" + MyCostCentreCode + "] Period end: " + PeriodEnd + " Run#: " + RunNumber, EmailBody); if (SentOk) { FStatusMsg += Catalog.GetString("\r\nStewardship report emailed to ICH."); } else { FStatusMsg += Catalog.GetString("\r\nFailed to send Stewardship email to ICH."); } return(false); } return(HasData); } // Load Stewardship Report Data
/// <summary> /// Create new partner, family, location and PartnerLocation records in MainDS /// </summary> private static Int64 CreateNewFamily(XmlNode ANode, out int ALocationKey, ref PartnerImportExportTDS AMainDS, TDBTransaction ATransaction) { PPartnerRow newPartner = AMainDS.PPartner.NewRowTyped(); AMainDS.PPartner.Rows.Add(newPartner); newPartner.PartnerKey = (AMainDS.PPartner.Rows.Count + 1) * -1; newPartner.PartnerClass = MPartnerConstants.PARTNERCLASS_FAMILY; newPartner.StatusCode = MPartnerConstants.PARTNERSTATUS_ACTIVE; newPartner.Comment = TXMLParser.GetAttribute(ANode, MPartnerConstants.PARTNERIMPORT_NOTESFAMILY); String AcquisitionCode = TXMLParser.GetAttribute(ANode, MPartnerConstants.PARTNERIMPORT_AQUISITION); newPartner.AcquisitionCode = (AcquisitionCode.Length > 0) ? AcquisitionCode : MPartnerConstants.PARTNERIMPORT_AQUISITION_DEFAULT; newPartner.AddresseeTypeCode = MPartnerConstants.ADDRESSEETYPE_DEFAULT; if (TXMLParser.HasAttribute(ANode, MPartnerConstants.PARTNERIMPORT_ADDRESSEE_TYPE)) { newPartner.AddresseeTypeCode = TXMLParser.GetAttribute(ANode, MPartnerConstants.PARTNERIMPORT_ADDRESSEE_TYPE); } else { string gender = GetGenderCode(ANode); if (gender == MPartnerConstants.GENDER_MALE) { newPartner.AddresseeTypeCode = MPartnerConstants.ADDRESSEETYPE_MALE; } else if (gender == MPartnerConstants.GENDER_FEMALE) { newPartner.AddresseeTypeCode = MPartnerConstants.ADDRESSEETYPE_FEMALE; } } if (TXMLParser.HasAttribute(ANode, MPartnerConstants.PARTNERIMPORT_LANGUAGE)) { newPartner.LanguageCode = TXMLParser.GetAttribute(ANode, MPartnerConstants.PARTNERIMPORT_LANGUAGE); } else if (TUserDefaults.HasDefault(MSysManConstants.PARTNER_LANGUAGECODE)) { newPartner.LanguageCode = TUserDefaults.GetStringDefault(MSysManConstants.PARTNER_LANGUAGECODE); } string[] giftReceiptingDefaults = TSystemDefaults.GetStringDefault("GiftReceiptingDefaults", ",no").Split(new char[] { ',' }); newPartner.ReceiptLetterFrequency = giftReceiptingDefaults[0]; newPartner.ReceiptEachGift = giftReceiptingDefaults[1] == "YES" || giftReceiptingDefaults[1] == "TRUE"; PFamilyRow newFamily = AMainDS.PFamily.NewRowTyped(); AMainDS.PFamily.Rows.Add(newFamily); newFamily.PartnerKey = newPartner.PartnerKey; newFamily.FirstName = TXMLParser.GetAttribute(ANode, MPartnerConstants.PARTNERIMPORT_FIRSTNAME); newFamily.FamilyName = TXMLParser.GetAttribute(ANode, MPartnerConstants.PARTNERIMPORT_FAMILYNAME); newFamily.MaritalStatus = GetMaritalStatusCode(ANode, ATransaction); newFamily.Title = TXMLParser.GetAttribute(ANode, MPartnerConstants.PARTNERIMPORT_TITLE); if (TXMLParser.HasAttribute(ANode, MPartnerConstants.PARTNERIMPORT_LANGUAGE)) { newPartner.LanguageCode = TXMLParser.GetAttribute(ANode, MPartnerConstants.PARTNERIMPORT_LANGUAGE); } newPartner.PartnerShortName = Calculations.DeterminePartnerShortName(newFamily.FamilyName, newFamily.Title, newFamily.FirstName); PLocationRow newLocation = AMainDS.PLocation.NewRowTyped(true); AMainDS.PLocation.Rows.Add(newLocation); newLocation.LocationKey = TPartnerImportCSV.FLocationKey; newLocation.Locality = TXMLParser.GetAttribute(ANode, MPartnerConstants.PARTNERIMPORT_LOCALITY); newLocation.StreetName = TXMLParser.GetAttribute(ANode, MPartnerConstants.PARTNERIMPORT_STREETNAME); newLocation.Address3 = TXMLParser.GetAttribute(ANode, MPartnerConstants.PARTNERIMPORT_ADDRESS); newLocation.PostalCode = TXMLParser.GetAttribute(ANode, MPartnerConstants.PARTNERIMPORT_POSTALCODE); newLocation.City = TXMLParser.GetAttribute(ANode, MPartnerConstants.PARTNERIMPORT_CITY); newLocation.County = TXMLParser.GetAttribute(ANode, MPartnerConstants.PARTNERIMPORT_COUNTY); newLocation.CountryCode = TXMLParser.GetAttribute(ANode, MPartnerConstants.PARTNERIMPORT_COUNTRYCODE); PPartnerLocationRow partnerlocation = AMainDS.PPartnerLocation.NewRowTyped(true); TPartnerContactDetails_LocationConversionHelper.AddOldDBTableColumnsToPartnerLocation(AMainDS.PPartnerLocation); partnerlocation.LocationKey = TPartnerImportCSV.FLocationKey; partnerlocation.SiteKey = 0; partnerlocation.PartnerKey = newPartner.PartnerKey; partnerlocation.DateEffective = DateTime.Now.Date; partnerlocation.LocationType = MPartnerConstants.LOCATIONTYPE_HOME; partnerlocation.SendMail = true; partnerlocation["p_email_address_c"] = TXMLParser.GetAttribute(ANode, MPartnerConstants.PARTNERIMPORT_EMAIL); // Important: Do not use 'partnerlocation.EmailAddress' as this Column will get removed once Contact Details conversion is finished! partnerlocation["p_telephone_number_c"] = TXMLParser.GetAttribute(ANode, MPartnerConstants.PARTNERIMPORT_PHONE); // Important: Do not use 'partnerlocation.TelephoneNumber' as this Column will get removed once Contact Details conversion is finished! partnerlocation["p_mobile_number_c"] = TXMLParser.GetAttribute(ANode, MPartnerConstants.PARTNERIMPORT_MOBILEPHONE); // Important: Do not use 'partnerlocation.MobileNumber' as this Column will get removed once Contact Details conversion is finished! AMainDS.PPartnerLocation.Rows.Add(partnerlocation); ALocationKey = TPartnerImportCSV.FLocationKey; TPartnerImportCSV.FLocationKey--; return(newPartner.PartnerKey); }
/// <summary> /// Looks for gifts where the recipient is an ExWorker and asks the user if they want to continue. /// (Make sure GetDataFromControls is called before this method so that AMainDS is up-to-date.) /// </summary> /// <param name="AAction">Why this method is being called</param> /// <param name="AMainDS"></param> /// <param name="APetraUtilsObject"></param> /// <param name="APostingGiftDetails">Only used when being called in order to carry out a batch posting</param> /// <returns>Returns true if saving/posting can continue</returns> public static bool CanContinueWithAnyExWorkers(GiftBatchAction AAction, GiftBatchTDS AMainDS, TFrmPetraEditUtils APetraUtilsObject, DataTable APostingGiftDetails = null) { DataTable ExWorkers = null; string Msg = string.Empty; int BatchNumber = -1; int ExWorkerGifts = 0; string ExWorkerSpecialType = TSystemDefaults.GetStringDefault(SharedConstants.SYSDEFAULT_EXWORKERSPECIALTYPE, "EX-WORKER"); // first check for Ex-Workers in the batch that is being posted/submitted (if a batch is being posted/submitted) if ((APostingGiftDetails != null) && (APostingGiftDetails.Rows.Count > 0)) { ExWorkers = TRemote.MFinance.Gift.WebConnectors.FindGiftRecipientExWorker(APostingGiftDetails, BatchNumber); ExWorkerGifts += ExWorkers.Rows.Count; Msg = GetExWorkersString(AAction, ExWorkerSpecialType, ExWorkers); if (ExWorkers.Rows.Count > 0) { BatchNumber = (int)APostingGiftDetails.Rows[0][GiftBatchTDSAGiftDetailTable.GetBatchNumberDBName()]; } } // check for Ex-Workers in all added and modified data if (APetraUtilsObject.HasChanges) { DataTable Changes = new DataTable(); if (AMainDS.AGiftDetail.GetChangesTyped() != null) { Changes.Merge(AMainDS.AGiftDetail.GetChangesTyped()); } else if (AMainDS.ARecurringGiftDetail.GetChangesTyped() != null) { Changes.Merge(AMainDS.ARecurringGiftDetail.GetChangesTyped()); } if ((Changes != null) && (Changes.Rows.Count > 0)) { ExWorkers = TRemote.MFinance.Gift.WebConnectors.FindGiftRecipientExWorker(Changes, BatchNumber); ExWorkerGifts += ExWorkers.Rows.Count; Msg += GetExWorkersString(null, ExWorkerSpecialType, ExWorkers); } } // alert the user to any recipients who are Ex-Workers if (Msg != string.Empty) { if (AAction == GiftBatchAction.SAVING) { Msg += Catalog.GetString("Do you want to continue with saving anyway?"); } else { // singular if (ExWorkerGifts == 1) { if (AAction == GiftBatchAction.POSTING) { Msg += Catalog.GetString("This gift will need to be saved before this batch can be posted."); } else if (AAction == GiftBatchAction.NEWBATCH) { Msg += Catalog.GetString("This gift will need to be saved before a new batch can be created."); } else if (AAction == GiftBatchAction.CANCELLING) { Msg += Catalog.GetString("This gift will need to be saved before this batch can be cancelled."); } else if (AAction == GiftBatchAction.SUBMITTING) { Msg += Catalog.GetString("This gift will need to be saved before this batch can be submitted."); } else if (AAction == GiftBatchAction.DELETING) { Msg += Catalog.GetString("This gift will need to be saved before this batch can be deleted."); } } // plural else { if (AAction == GiftBatchAction.POSTING) { Msg += Catalog.GetString("These gifts will need to be saved before this batch can be posted."); } else if (AAction == GiftBatchAction.NEWBATCH) { Msg += Catalog.GetString("These gifts will need to be saved before a new batch can be created."); } else if (AAction == GiftBatchAction.CANCELLING) { Msg += Catalog.GetString("These gifts will need to be saved before this batch can be cancelled."); } else if (AAction == GiftBatchAction.SUBMITTING) { Msg += Catalog.GetString("These gifts will need to be saved before this batch can be submitted."); } else if (AAction == GiftBatchAction.DELETING) { Msg += Catalog.GetString("These gifts will need to be saved before this batch can be deleted."); } } Msg += " " + Catalog.GetString("Do you want to continue?"); } if (MessageBox.Show( Msg, string.Format(Catalog.GetString("{0} Warning"), ExWorkerSpecialType), MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) { return(false); } } return(true); }
/// <summary> /// get the details of the last gift of the partner /// </summary> /// <param name="APartnerKey"></param> /// <param name="ALastGiftDate"></param> /// <param name="AGiftInfo"></param> public static void GetLastGiftDetails(Int64 APartnerKey, out DateTime ALastGiftDate, out String AGiftInfo) { Boolean LastGiftAvailable; DateTime LastGiftDate; decimal LastGiftAmount; Int64 LastGiftGivenToPartnerKey; Int64 LastGiftRecipientLedger; String LastGiftCurrencyCode; String LastGiftDisplayFormat; String LastGiftGivenToShortName; String LastGiftRecipientLedgerShortName; Boolean RestrictedGiftAccessDenied; AGiftInfo = ""; ALastGiftDate = DateTime.MinValue; TSystemDefaults SystemDefaults = new TSystemDefaults(); LastGiftAvailable = GetLastGiftDetails(APartnerKey, out LastGiftDate, out LastGiftAmount, out LastGiftGivenToPartnerKey, out LastGiftRecipientLedger, out LastGiftCurrencyCode, out LastGiftDisplayFormat, out LastGiftGivenToShortName, out LastGiftRecipientLedgerShortName, out RestrictedGiftAccessDenied); if (LastGiftAvailable) { ALastGiftDate = LastGiftDate; if (SystemDefaults.GetStringDefault(SharedConstants.SYSDEFAULT_DISPLAYGIFTAMOUNT).ToLower() == "true") { // Check OpenPetra Module access to FINANCE-1 or Financial Development if (UserInfo.GetUserInfo().IsInModule(SharedConstants.PETRAMODULE_FINANCE1) || UserInfo.GetUserInfo().IsInModule(SharedConstants.PETRAMODULE_DEVUSER)) { if (LastGiftCurrencyCode != "") { AGiftInfo = LastGiftCurrencyCode + ' ' + StringHelper.FormatCurrency(LastGiftAmount, LastGiftDisplayFormat) + " "; } else { AGiftInfo = LastGiftAmount.ToString() + " "; } } } if (LastGiftGivenToPartnerKey == -1) { // Split Gift if ((SystemDefaults.GetBooleanDefault(SharedConstants.SYSDEFAULT_DISPLAYGIFTRECIPIENT)) || (SystemDefaults.GetBooleanDefault(SharedConstants.SYSDEFAULT_DISPLAYGIFTFIELD))) { AGiftInfo = AGiftInfo + StrSplitGift; } } else { // Not a Split Gift if (SystemDefaults.GetBooleanDefault(SharedConstants.SYSDEFAULT_DISPLAYGIFTRECIPIENT)) { if (LastGiftGivenToPartnerKey != -1) { AGiftInfo = AGiftInfo + LastGiftGivenToShortName; } else { AGiftInfo = AGiftInfo + LastGiftGivenToPartnerKey.ToString(); } } if (SystemDefaults.GetBooleanDefault(SharedConstants.SYSDEFAULT_DISPLAYGIFTFIELD)) { if (LastGiftRecipientLedger != -1) { AGiftInfo = AGiftInfo + " (" + LastGiftRecipientLedgerShortName + ')'; } else { AGiftInfo = AGiftInfo + " (" + LastGiftRecipientLedger.ToString() + ')'; } } } } else { if (!RestrictedGiftAccessDenied) { ALastGiftDate = TSaveConvert.ObjectToDate(LastGiftDate); AGiftInfo = ""; } else { AGiftInfo = Catalog.GetString("** confidential **"); } } }