Пример #1
0
        /// <summary>
        /// Open a dialog to select Contact Attributes
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void SelectAttributes(object sender, EventArgs e)
        {
            TFrmContactAttributesDialog ContactAttributesDialog = new TFrmContactAttributesDialog(FPetraUtilsObject.GetForm());

            ContactAttributesDialog.ContactID = FContactDR.ContactLogId;
            ContactAttributesDialog.SelectedContactAttributeTable = FMainDS.PPartnerContactAttribute;

            if (ContactAttributesDialog.ShowDialog() == DialogResult.OK)
            {
                PPartnerContactAttributeTable Changes = ContactAttributesDialog.SelectedContactAttributeTable.GetChangesTyped();

                // if changes were made or a previously added row (unsaved) was deleted
                if ((Changes != null) || ContactAttributesDialog.AddedAttributeDeleted)
                {
                    FMainDS.PPartnerContactAttribute.Clear();
                    FMainDS.PPartnerContactAttribute.Merge(ContactAttributesDialog.SelectedContactAttributeTable);

                    FGridTableDV = ContactAttributesLogic.SetupContactAttributesGrid(ref grdSelectedAttributes,
                                                                                     FMainDS.PPartnerContactAttribute,
                                                                                     true,
                                                                                     FContactDR.ContactLogId);

                    // only enable save if there are actual changes from the original datatable
                    if (Changes != null)
                    {
                        FPetraUtilsObject.SetChangedFlag();
                    }
                }
            }
        }
        private void InitializeManualCode()
        {
            // Initialize 'Helper Class' for handling the Indexes of the DataRows.
            FIndexedGridRowsHelper = new TSgrdDataGrid.IndexedGridRowsHelper(
                grdDetails, PPartnerAttributeTypeTable.ColumnIndexId, btnDemote, btnPromote,
                delegate { FPetraUtilsObject.SetChangedFlag(); });

            // Before we start we set the defaultView RowFilter property to something unlikely.
            // The manual code gets a chance to populate the grid before we get our chance to set the correct rowFilter.
            // So this ensures that the grid does not flicker with the wrong rows before we put the right ones in.
            string FilterStr = String.Format("{0}='@#~?!()'", FMainDS.PPartnerAttributeType.ColumnCategoryCode.ColumnName);

            FMainDS.PPartnerAttributeType.DefaultView.RowFilter = FilterStr;

            lblLinkFormatTip.Text = Catalog.GetString("Enter the URL that should be launched for the Contact Type ( e.g. http://www.facebook.com/" +
                                                      THyperLinkHandling.HYPERLINK_WITH_VALUE_VALUE_PLACEHOLDER_IDENTIFIER + " ).");
            lblLinkFormatTip.Font = new System.Drawing.Font(lblLinkFormatTip.Font.FontFamily, 7, FontStyle.Regular);
            lblLinkFormatTip.Top -= 5;

            pnlDetails.MinimumSize = new Size(700, 145);              // To prevent shrinkage!

            /* fix tab order */
            pnlButtons.TabIndex = grdDetails.TabIndex + 1;

            if (FPetraUtilsObject.SecurityReadOnly)
            {
                btnNew.Enabled = false;
            }
        }
Пример #3
0
        /// <summary>
        /// Make this CostCentre a child of the selected one in the hierarchy (from drag-drop).
        /// </summary>
        /// <param name="AChild"></param>
        /// <param name="ANewParent"></param>
        private void DoReassignment(TreeNode AChild, TreeNode ANewParent)
        {
            if ((AChild != null) && (ANewParent != null))
            {
                CostCentreNodeDetails DraggedCostCentre = (CostCentreNodeDetails)AChild.Tag;

                if (DraggedCostCentre.CostCentreRow.SystemCostCentreFlag)
                {
                    MessageBox.Show(String.Format(Catalog.GetString("{0} is a System Cost Centre and cannot be moved."),
                                                  ((CostCentreNodeDetails)AChild.Tag).CostCentreRow.CostCentreCode),
                                    Catalog.GetString("Re-assign Cost Centre"), MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    ShowNodeSelected(null);
                    return;
                }

                String   PrevParent = AChild.Parent.Text;
                String   NewParentCostCentreCode = ((CostCentreNodeDetails)ANewParent.Tag).CostCentreRow.CostCentreCode;
                TreeNode NewNode = (TreeNode)AChild.Clone();
                DraggedCostCentre.CostCentreRow.CostCentreToReportTo = NewParentCostCentreCode;
                DraggedCostCentre.linkedTreeNode = NewNode;
                InsertInOrder(ANewParent, NewNode);
                NewNode.Expand();
                ANewParent.Expand();
                ((CostCentreNodeDetails)ANewParent.Tag).CostCentreRow.PostingCostCentreFlag = false; // The parent is now a summary CostCentre!
                ANewParent.BackColor = Color.White;
                FParentForm.ShowStatus(String.Format(Catalog.GetString("{0} was moved from {1} to {2}."),
                                                     AChild.Text, PrevParent, ANewParent.Text));
                //Remove Original Node
                AChild.Remove();
                FPetraUtilsObject.SetChangedFlag();
            }
        }
Пример #4
0
        private void DeactivateRecord(object sender, EventArgs e)
        {
            dtpDetailDateExpires.Text = dtpDetailDateEffective.Text;

            FPetraUtilsObject.SetChangedFlag();
            btnDeactivate.Enabled = false;
        }
        /// <summary>
        /// Delete the row in the editor
        /// NOTE: A cost centre with children cannot be deleted.
        /// </summary>
        private void DeleteCostCentre(Object sender, EventArgs e)
        {
            if (FCurrentCostCentre == null)
            {
                return;
            }

            FCurrentCostCentre.GetAttrributes();

            if (FCurrentCostCentre.CanDelete.Value)
            {
                ACostCentreRow SelectedRow = FCurrentCostCentre.CostCentreRow;
                TreeNode DeletedNode = FCurrentCostCentre.linkedTreeNode;
                TreeNode ParentNode = DeletedNode.Parent;
                SelectedRow.Delete();
                ucoCostCentreTree.DeleteSelectedCostCentre();

                // FCurrentCostCentre is now the parent of the CostCentre that was just deleted.
                // If just I added a sub-tree and I decide I don't want it, I might be about to remove the parent too.
                if (FCurrentCostCentre != null)
                {
                    FCurrentCostCentre.GetAttrributes();
                }

                FPetraUtilsObject.SetChangedFlag();
            }
            else
            {
                MessageBox.Show(
                    Catalog.GetString("This Cost Centre Code is in use and cannot be deleted.") + "\n" + FCurrentCostCentre.Msg,
                    Catalog.GetString("Delete Cost Centre"));
            }
        }
Пример #6
0
        private void SetExchangeRateValue(Object sender, EventArgs e)
        {
            TFrmSetupDailyExchangeRate SetupDailyExchangeRate =
                new TFrmSetupDailyExchangeRate(FPetraUtilsObject.GetForm());

            decimal  SelectedExchangeRate;
            DateTime SelectedEffectiveDate;
            int      SelectedEffectiveTime;

            if (SetupDailyExchangeRate.ShowDialog(
                    FLedgerNumber,
                    dtpDetailDateEffective.Date.HasValue ? dtpDetailDateEffective.Date.Value : DateTime.Today,
                    cmbDetailTransactionCurrency.GetSelectedString(),
                    (txtDetailExchangeRateToBase.NumberValueDecimal == null) ? 0.0m : txtDetailExchangeRateToBase.NumberValueDecimal.Value,
                    out SelectedExchangeRate,
                    out SelectedEffectiveDate,
                    out SelectedEffectiveTime) == DialogResult.Cancel)
            {
                return;
            }

            if (FPreviouslySelectedDetailRow.ExchangeRateToBase != SelectedExchangeRate)
            {
                FPreviouslySelectedDetailRow.ExchangeRateToBase = SelectedExchangeRate;
                //Enforce save needed condition
                FPetraUtilsObject.SetChangedFlag();
            }

            txtDetailExchangeRateToBase.NumberValueDecimal = SelectedExchangeRate;
            FPreviouslySelectedDetailRow.ExchangeRateTime  = SelectedEffectiveTime;

            RefreshCurrencyAndExchangeRate();
        }
        private void InitializeManualCode()
        {
            // Initialize 'Helper Class' for handling the Indexes of the DataRows.
            FIndexedGridRowsHelper = new TSgrdDataGrid.IndexedGridRowsHelper(
                grdDetails, PPartnerAttributeCategoryTable.ColumnIndexId, btnDemoteCategory, btnPromoteCategory,
                delegate { FPetraUtilsObject.SetChangedFlag(); });

            // Hook up DataSavingStarted Event to be able to run code before SaveChanges is doing anything
            FPetraUtilsObject.DataSavingStarted += new TDataSavingStartHandler(DataSavingStarted);
            // We need to capture the 'DataSaved' event so we can save our Extra DataSet
            FPetraUtilsObject.DataSaved += new TDataSavedHandler(DataSaved);
            // We need to capture the 'NoMasterDataToSave' event so we can save our Extra DataSet
            // in case that no data was changed in this Forms' pnlDetails
            FPetraUtilsObject.NoMasterDataToSave += NoMasterDataToSave;

            // We also want to know if the UserControl holds no more detail records
            ucoValues.NoMoreDetailRecords += Uco_NoMoreDetailRecords;

            ucoValues.PetraUtilsObject = FPetraUtilsObject;

            grdDetails.Selection.FocusRowLeaving += HandleFocusRowLeaving;

            // We capture the Leave event of the Code TextBox (This is more consistent than LostFocus. - it always occurs
            // before validation, whereas LostFocus occurs before or after depending on mouse or keyboard.)
            txtDetailCategoryCode.Leave += new EventHandler(txtDetailCategoryCode_Leave);

            // Set up Timer that is needed for showing MessageBoxes from a Grid Event
            ShowMessageBoxTimer.Tick    += new EventHandler(ShowTimerDrivenMessageBox);
            ShowMessageBoxTimer.Interval = 100;

            /* fix tab order */
            pnlButtons.TabIndex = grdDetails.TabIndex + 1;
        }
        private void UpdateOnControlChanged(Object sender, EventArgs e)
        {
            if (FIAmUpdating == 0)
            {
                ACostCentreRow Row = GetSelectedDetailRowManual();

                if ((Row != null)
                    && (cmbDetailCostCentreType.GetSelectedString() != Row.CostCentreType))
                {
                    if (Row.SystemCostCentreFlag)
                    {
                        MessageBox.Show(
                            Catalog.GetString(
                                "This is a System Cost Centre and cannot be changed."),
                            Catalog.GetString("Cost Centre Type"),
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Stop);
                        FIAmUpdating++;
                        cmbDetailCostCentreType.SetSelectedString(Row.CostCentreType);
                        FIAmUpdating--;
                    }
                    else // It's not a system Cost Centre, but probably I still shouldn't be changing it...
                    {
                        if (MessageBox.Show(
                                Catalog.GetString(
                                    "Are you sure you want to change this?\n" +
                                    "Changing from Local to foreign, or vice versa,\n" +
                                    "will affect the reporting of foreign ledgers.\n" +
                                    "In OM, Foreign Cost Centres are children of ILT.\n" +
                                    "All other Cost Centres are Local."),
                                Catalog.GetString("Cost Centre Type"),
                                MessageBoxButtons.YesNo,
                                MessageBoxIcon.Stop) == System.Windows.Forms.DialogResult.No)
                        {
                            FIAmUpdating++;
                            cmbDetailCostCentreType.SetSelectedString(Row.CostCentreType);
                            FIAmUpdating--;
                        }
                    }
                }

                if (CheckCostCentreValueChanged())
                {
                    return;
                }  // If not changed, or the rename didn't happen, I can carry on...

                if (
                    (Row.CostCentreActiveFlag != chkDetailCostCentreActiveFlag.Checked)
                    || (Row.CostCentreType != cmbDetailCostCentreType.GetSelectedString())
                    || (Row.CostCentreCode != txtDetailCostCentreCode.Text)
                    || (Row.CostCentreName != txtDetailCostCentreName.Text)
                    )
                {
                    FPetraUtilsObject.SetChangedFlag();
                }

                GetDataFromControlsManual();
                ucoCostCentreTree.SetNodeLabel(Row);
            }
        } // UpdateOnControlChanged
        /// <summary>
        /// Verify and if necessary update partner data in an extract
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void VerifyAndUpdateExtract(System.Object sender, EventArgs e)
        {
            bool ChangesMade;
            ExtractTDSMExtractTable ExtractTable = FMainDS.MExtract;

            TFrmExtractMaster.VerifyAndUpdateExtract(FindForm(), ref ExtractTable, out ChangesMade);

            if (ChangesMade)
            {
                FPetraUtilsObject.SetChangedFlag();

                MessageBox.Show(String.Format(Catalog.GetString("Verification and Update of Extract {0} was successful. \n\r" +
                                                                "Please press the Save button to save the changes."), FExtractName),
                                Catalog.GetString("Verify and Update Extract"),
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show(String.Format(Catalog.GetString("Extract {0} was already up to date"), FExtractName),
                                Catalog.GetString("Verify and Update Extract"),
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
            }
        }
        private void LookupExchangeRate(Object sender, EventArgs e)
        {
            TFrmSetupDailyExchangeRate setupDailyExchangeRate =
                new TFrmSetupDailyExchangeRate(FPetraUtilsObject.GetForm());

            decimal  selectedExchangeRate;
            DateTime selectedEffectiveDate;
            int      selectedEffectiveTime;

            if (setupDailyExchangeRate.ShowDialog(
                    FDocumentLedgerNumber,
                    DateTime.Now,
                    txtSupplierCurrency.Text,
                    1.0m,
                    out selectedExchangeRate,
                    out selectedEffectiveDate,
                    out selectedEffectiveTime) == DialogResult.Cancel)
            {
                return;
            }

            if (txtExchangeRateToBase.NumberValueDecimal != selectedExchangeRate)
            {
                //Enforce save needed condition
                FPetraUtilsObject.SetChangedFlag();
            }

            txtExchangeRateToBase.NumberValueDecimal = selectedExchangeRate;
        }
Пример #11
0
        private void RetireUnretireUser(Object Sender, EventArgs e)
        {
            DialogResult UserAnswer = MessageBox.Show(String.Format(StrAccountStateChangeQuestion,
                                                                    GetSelectedDetailRow().Retired ? "unretire" : "retire", txtDetailUserId.Text,
                                                                    GetSelectedDetailRow().Retired ? "retired" : "not retired"),
                                                      Catalog.GetString("Retire/Unretire User Account?"),
                                                      MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);

            if (UserAnswer == DialogResult.Yes)
            {
                chkDetailRetired.Checked       = !chkDetailRetired.Checked;
                GetSelectedDetailRow().Retired = !GetSelectedDetailRow().Retired;
                FPetraUtilsObject.SetChangedFlag();

                MessageBox.Show(String.Format(StrAccountStateChangeConfirmation,
                                              chkDetailRetired.Checked ? Catalog.GetString("retired") : Catalog.GetString("unretired"),
                                              txtDetailUserId.Text, chkDetailRetired.Checked ? StrWillNotBeAbleToLogin :
                                              (!chkDetailAccountLocked.Checked ? StrWillBeAbleToLogin : String.Format(StrWillBeStillNotBeAbleToLogin,
                                                                                                                      Catalog.GetString("the User Account is Locked"))
                                              )),
                                String.Format(StrAccountStateChangeConfirmationTitle, Catalog.GetString("Retired State")),
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show(Catalog.GetString("Retired state of User Account did not get changed."),
                                Catalog.GetString("User Account: Retired State Not Changed"), MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Пример #12
0
        private void SetExchangeRateValue(Object sender, EventArgs e)
        {
            TFrmSetupDailyExchangeRate setupDailyExchangeRate =
                new TFrmSetupDailyExchangeRate(FPetraUtilsObject.GetForm());

            decimal  selectedExchangeRate;
            DateTime selectedEffectiveDate;
            int      selectedEffectiveTime;

            if (setupDailyExchangeRate.ShowDialog(
                    FLedgerNumber,
                    dtpDetailGlEffectiveDate.Date.Value,
                    cmbDetailCurrencyCode.GetSelectedString(),
                    DEFAULT_CURRENCY_EXCHANGE,
                    out selectedExchangeRate,
                    out selectedEffectiveDate,
                    out selectedEffectiveTime) == DialogResult.Cancel)
            {
                return;
            }

            if (FPreviouslySelectedDetailRow.ExchangeRateToBase != selectedExchangeRate)
            {
                FPreviouslySelectedDetailRow.ExchangeRateToBase = selectedExchangeRate;
                RecalculateTransactionAmounts(selectedExchangeRate);

                //Enforce save needed condition
                FPetraUtilsObject.SetChangedFlag();
            }

            RefreshCurrencyAndExchangeRateControls();
        }
Пример #13
0
        private void LockUnlockUser(Object Sender, EventArgs e)
        {
            DialogResult UserAnswer = MessageBox.Show(String.Format(StrAccountStateChangeQuestion,
                                                                    GetSelectedDetailRow().AccountLocked ? "unlock" : "lock", txtDetailUserId.Text,
                                                                    GetSelectedDetailRow().AccountLocked ? "locked" : "not locked"),
                                                      Catalog.GetString("Lock/Unlock User Account?"),
                                                      MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);

            if (UserAnswer == DialogResult.Yes)
            {
                chkDetailAccountLocked.Checked       = !chkDetailAccountLocked.Checked;
                GetSelectedDetailRow().AccountLocked = !GetSelectedDetailRow().AccountLocked;
                GetSelectedDetailRow().FailedLogins  = 0;
                FPetraUtilsObject.SetChangedFlag();

                MessageBox.Show(String.Format(StrAccountStateChangeConfirmation,
                                              chkDetailAccountLocked.Checked ? Catalog.GetString("locked") : Catalog.GetString(
                                                  "unlocked and the user's Failed Login count was reset to 0"),
                                              txtDetailUserId.Text, chkDetailAccountLocked.Checked ? StrWillNotBeAbleToLogin :
                                              (!chkDetailRetired.Checked ? StrWillBeAbleToLogin : String.Format(StrWillBeStillNotBeAbleToLogin,
                                                                                                                Catalog.GetString("the user is retired"))
                                              )),
                                String.Format(StrAccountStateChangeConfirmationTitle, Catalog.GetString("Locked State")),
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show(Catalog.GetString("Lock state of User Account did not get changed."),
                                Catalog.GetString("User Account: Lock State Not Changed"), MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        private void DoReassignment(TreeNode Child, TreeNode NewParent)
        {
            if ((Child != null) && (NewParent != null))
            {
                String   PrevParent = Child.Parent.Text;
                TreeNode NewNode    = (TreeNode)Child.Clone();
                ((UnitHierarchyNode)NewNode.Tag).ParentUnitKey = ((UnitHierarchyNode)NewParent.Tag).MyUnitKey;
                InsertAlphabetically(NewParent, NewNode);
                NewNode.Expand();
                NewParent.Expand();
                NewParent.BackColor = Color.White;
                FChangedParents.Add(new Tuple <string, long, long>(
                                        ((UnitHierarchyNode)NewParent.Tag).Description,
                                        ((UnitHierarchyNode)NewNode.Tag).MyUnitKey,
                                        ((UnitHierarchyNode)NewNode.Tag).ParentUnitKey));
                FStatus += String.Format(Catalog.GetString("{0} was moved from {1} to {2}.\r\n"),
                                         Child.Text, PrevParent, NewParent.Text);
                txtStatus.Text = FStatus;

                //Select the New Node in the tree view
                SelectNode(NewNode);
                trvUnits.SelectedNode = NewNode;

                //Remove Original Node
                Child.Remove();
                FPetraUtilsObject.SetChangedFlag();
            }
        }
Пример #15
0
        private void AddAllocations(Object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;

            if (cmbDetailTransactionTypeCode.GetSelectedString() == CommonAccountingTransactionTypesEnum.ALLOC.ToString())
            {
                TFrmAllocationJournalDialog AddAllocationJournal = new TFrmAllocationJournalDialog(this.FindForm());
                AddAllocationJournal.Journal = this.GetSelectedDetailRow();

                // open as a modal form
                if (AddAllocationJournal.ShowDialog() == DialogResult.OK)
                {
                    FMainDS.Merge(AddAllocationJournal.MainDS);

                    // manually enable save button (otherwise this doesn't happen)
                    FPetraUtilsObject.SetChangedFlag();
                }
            }
            else if (cmbDetailTransactionTypeCode.GetSelectedString() == CommonAccountingTransactionTypesEnum.REALLOC.ToString())
            {
                TFrmReallocationJournalDialog AddReallocationJournal = new TFrmReallocationJournalDialog(this.FindForm());
                AddReallocationJournal.Journal = this.GetSelectedDetailRow();

                // open as a modal form
                if (AddReallocationJournal.ShowDialog() == DialogResult.OK)
                {
                    FMainDS.Merge(AddReallocationJournal.MainDS);

                    // manually enable save button (otherwise this doesn't happen)
                    FPetraUtilsObject.SetChangedFlag();
                }
            }

            Cursor = Cursors.Default;
        }
Пример #16
0
        /// <summary>
        /// called from APMain when adding new supplier;
        /// initialises a new dataset
        /// </summary>
        /// <param name="APartnerKey"></param>
        public void CreateNewSupplier(Int64 APartnerKey)
        {
            // TODO: let the server do that? what about messages on failure?

            // check for existing supplier record
            if (FUIConnector.CanFindSupplier(APartnerKey))
            {
                MessageBox.Show(Catalog.GetString("There is already a supplier record for this partner!"));
                EditSupplier(APartnerKey);
                return;
            }

            FPetraUtilsObject.SetChangedFlag();

            AApSupplierRow row = FMainDS.AApSupplier.NewRowTyped();

            row.PartnerKey = APartnerKey;

            row.CurrencyCode           = FLedgerRow.BaseCurrency;
            row.DefaultApAccount       = "9100"; // If the user doesn't want this, she should have a good reason..
            row.DefaultCreditTerms     = 28;     // 28 credit might not be universal, but it's better than 0.
            row.PreferredScreenDisplay = 36;     // show my invoices for 36 months
            FMainDS.AApSupplier.Rows.Add(row);

            ShowData(row);

            // Make PartnerKey Readonly again -
            // ShowData makes it writeable because it is the Primary Key of the Table and we are adding a record!
            txtPartnerKey.ReadOnly = true;
        }
Пример #17
0
        private void AddNewAccount(Object sender, EventArgs e)
        {
            if (FCurrentAccount == null)
            {
                MessageBox.Show(Catalog.GetString("You can only add a new account after selecting a parent account"));
                return;
            }

            ValidateAllData(true, false);
            string newName         = FNameForNewAccounts;
            Int32  countNewAccount = 0;

            if (FMainDS.AAccount.Rows.Find(new object[] { FLedgerNumber, newName }) != null)
            {
                while (FMainDS.AAccount.Rows.Find(new object[] { FLedgerNumber, newName + countNewAccount.ToString() }) != null)
                {
                    countNewAccount++;
                }

                newName += countNewAccount.ToString();
            }

            // ChangeAccountCodeValue() needs this value!
            strOldDetailAccountCode = newName;

            AAccountRow parentAccount = FCurrentAccount.AccountRow;

            GLSetupTDSAAccountRow newAccountRow = FMainDS.AAccount.NewRowTyped();

            newAccountRow.AccountCode          = newName;
            newAccountRow.LedgerNumber         = FLedgerNumber;
            newAccountRow.AccountActiveFlag    = true;
            newAccountRow.DebitCreditIndicator = parentAccount.DebitCreditIndicator;
            newAccountRow.AccountType          = parentAccount.AccountType;
            newAccountRow.ValidCcCombo         = parentAccount.ValidCcCombo;
            newAccountRow.PostingStatus        = true;
            FMainDS.AAccount.Rows.Add(newAccountRow);

            AAccountHierarchyDetailRow hierarchyDetailRow = FMainDS.AAccountHierarchyDetail.NewRowTyped();

            hierarchyDetailRow.LedgerNumber          = FLedgerNumber;
            hierarchyDetailRow.AccountHierarchyCode  = FSelectedHierarchy;
            hierarchyDetailRow.AccountCodeToReportTo = parentAccount.AccountCode;
            hierarchyDetailRow.ReportingAccountCode  = newName;

            // change posting/summary flag of parent account if it was previously a leaf
            parentAccount.PostingStatus = false; // The parent is now a summary account!

            hierarchyDetailRow.ReportOrder = ucoAccountsTree.GetLastChildReportingOrder() + 1;
            FMainDS.AAccountHierarchyDetail.Rows.Add(hierarchyDetailRow);
            FIAmUpdating++;
            ShowDetails(newAccountRow);
            FIAmUpdating--;
            ucoAccountsTree.AddNewAccount(newAccountRow, hierarchyDetailRow);

            txtDetailAccountCode.Focus();
            FPetraUtilsObject.SetChangedFlag();
        }
        private void DeleteRecord(Object sender, EventArgs e)
        {
            int gridRow = grdDetails.Selection.ActivePosition.Row;

            FselectedRow.Delete();
            FselectedRow = null;
            grdDetails.SelectRowInGrid(gridRow, true);
            FPetraUtilsObject.SetChangedFlag();
        }
Пример #19
0
        private void Import(System.Object sender, EventArgs e)
        {
            if (ValidateAllData(true, true))
            {
                TVerificationResultCollection results = FPetraUtilsObject.VerificationResultCollection;

                int nRowsImported = TImportExchangeRates.ImportCurrencyExRates(FMainDS.ACorporateExchangeRate, "Corporate", results);

                if (results.Count > 0)
                {
                    string formatter;

                    if (nRowsImported == 0)
                    {
                        formatter = MCommonResourcestrings.StrExchRateImportNoRows;
                    }
                    else if (nRowsImported == 1)
                    {
                        formatter = MCommonResourcestrings.StrExchRateImportOneRow;
                    }
                    else
                    {
                        formatter = MCommonResourcestrings.StrExchRateImportMultiRow;
                    }

                    formatter += "{0}{0}{1}{0}{0}{3}{0}{0}{4}";
                    MessageBox.Show(String.Format(formatter,
                                                  Environment.NewLine,
                                                  results[0].ResultText,
                                                  nRowsImported,
                                                  MCommonResourcestrings.StrExchRateImportTryAgain,
                                                  results[0].ResultCode),
                                    MCommonResourcestrings.StrExchRateImportTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);

                    results.Clear();
                }
                else if (nRowsImported == 0)
                {
                    MessageBox.Show(MCommonResourcestrings.StrExchRateImportNoRows, MCommonResourcestrings.StrExchRateImportTitle);
                }
                else if (nRowsImported == 1)
                {
                    MessageBox.Show(MCommonResourcestrings.StrExchRateImportOneRowSuccess, MCommonResourcestrings.StrExchRateImportTitle);
                }
                else
                {
                    MessageBox.Show(String.Format(MCommonResourcestrings.StrExchRateImportMultiRowSuccess,
                                                  nRowsImported), MCommonResourcestrings.StrExchRateImportTitle);
                }

                if (nRowsImported > 0)
                {
                    FPetraUtilsObject.SetChangedFlag();
                }
            }
        }
Пример #20
0
 /// <summary>
 /// Update the Batch total from the transactions values
 /// </summary>
 /// <param name="ABatchTotal"></param>
 /// <param name="ABatchNumber"></param>
 public void UpdateBatchTotal(decimal ABatchTotal, Int32 ABatchNumber)
 {
     if (FPreviouslySelectedDetailRow == null)
     {
         return;
     }
     else if (FPreviouslySelectedDetailRow.BatchNumber == ABatchNumber)
     {
         FPreviouslySelectedDetailRow.BatchTotal = ABatchTotal;
         FPetraUtilsObject.SetChangedFlag();
     }
 }
        private void NewRecord(Object sender, EventArgs e)
        {
            GetDataFromControls();
            DataRow newRow = FesrDefaults.NewRow();

            newRow["a_motiv_group_s"] = "GIFT";
            FesrDefaults.Rows.Add(newRow);
            grdDetails.SelectRowInGrid(1, true);
            txtPartnerKey.Focus();

            FPetraUtilsObject.SetChangedFlag();
        }
Пример #22
0
 /// <summary>
 /// Update the Batch total from the transactions values
 /// </summary>
 /// <param name="ABatchTotal"></param>
 /// <param name="ABatchNumber"></param>
 public void UpdateBatchTotal(decimal ABatchTotal, Int32 ABatchNumber)
 {
     if ((FPreviouslySelectedDetailRow == null) || (FPreviouslySelectedDetailRow.BatchStatus != MFinanceConstants.BATCH_UNPOSTED))
     {
         return;
     }
     else if ((FPreviouslySelectedDetailRow.BatchNumber == ABatchNumber) && (FPreviouslySelectedDetailRow.BatchTotal != ABatchTotal))
     {
         FPreviouslySelectedDetailRow.BatchTotal = ABatchTotal;
         FPetraUtilsObject.SetChangedFlag();
     }
 }
        // Called with Remove button. Removes a venue from conference.
        private void RemoveVenue(object sender, EventArgs e)
        {
            if (grdVenues.SelectedDataRows.Length == 1)
            {
                long SelectedVenueKey;

                SelectedVenueKey = (Int64)((DataRowView)grdVenues.SelectedDataRows[0]).Row[PcConferenceVenueTable.GetVenueKeyDBName()];

                DataRow RowToRemove = FMainDS.PcConferenceVenue.Rows.Find(new object[] { FPartnerKey, SelectedVenueKey });
                RowToRemove.Delete();
                FPetraUtilsObject.SetChangedFlag();
            }
        }
Пример #24
0
        /// <summary>
        /// Make this account a child of the selected one in the hierarchy (from drag-drop).
        /// </summary>
        /// <param name="AChild"></param>
        /// <param name="ANewParent"></param>
        private void DoReassignment(TreeNode AChild, TreeNode ANewParent)
        {
            if ((AChild != null) && (ANewParent != null))
            {
                if (((AccountNodeDetails)AChild.Tag).AccountRow.SystemAccountFlag)
                {
                    MessageBox.Show(String.Format(Catalog.GetString("{0} is a System Account and cannot be moved."),
                                                  ((AccountNodeDetails)AChild.Tag).AccountRow.AccountCode),
                                    Catalog.GetString("Re-assign Account"), MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    ShowNodeSelected(null);
                    return;
                }

                AAccountRow newParentRow = ((AccountNodeDetails)ANewParent.Tag).AccountRow;

                if (newParentRow.PostingStatus)
                {
                    if (MessageBox.Show(String.Format(Catalog.GetString("Do you want to promote {0} to a summary Account?"),
                                                      newParentRow.AccountCode), Catalog.GetString("Move Account"), MessageBoxButtons.YesNo)
                        == System.Windows.Forms.DialogResult.No)
                    {
                        ShowNodeSelected(null);
                        return;
                    }
                }

                FParentForm.SetSelectedAccount(null);
                String             PrevParent     = AChild.Parent.Text;
                AccountNodeDetails DraggedAccount = (AccountNodeDetails)AChild.Tag;

                TreeNode NewNode = (TreeNode)AChild.Clone(); // A new TreeNode is made (and the previous will be deleted),
                                                             // but the actual DataRows are only tweaked to show the new parent.

                DraggedAccount.linkedTreeNode = NewNode;
                DraggedAccount.DetailRow.AccountCodeToReportTo = newParentRow.AccountCode;
                InsertInOrder(ANewParent, NewNode);
                NewNode.Expand();
                ANewParent.Expand();
                newParentRow.PostingStatus = false; // The parent is now a summary account!
                ((AccountNodeDetails)ANewParent.Tag).CanDelete = false;
                ANewParent.BackColor = Color.White;
                FParentForm.ShowStatus(String.Format(Catalog.GetString("{0} was moved from {1} to {2}."),
                                                     AChild.Text, PrevParent, ANewParent.Text));

                AChild.Remove();
                FPetraUtilsObject.SetChangedFlag();
                FParentForm.SetSelectedAccount(DraggedAccount);
//              SetSelectionUsingTimer(DraggedAccount); // Calling SetSelectedAccount directly doesn't work
                // because Remove(), above, has left a selection "in the queue".
            }
        }
        private void GetDataFromControlsManual()
        {
            if (FselectedRow != null)
            {
                Int64 partnerKey;

                if (Int64.TryParse(txtPartnerKey.Text, out partnerKey))
                {
                    if (FselectedRow["a_partner_key_n"].ToString() != txtPartnerKey.Text)
                    {
                        FselectedRow["a_partner_key_n"] = partnerKey;
                        FPetraUtilsObject.SetChangedFlag();
                    }

                    Int64 newPartnerKey = partnerKey;

                    if (Int64.TryParse(txtNewPartnerKey.Text, out newPartnerKey))
                    {
                        if ((FselectedRow["a_new_partner_key_n"] == System.DBNull.Value) ||
                            (Convert.ToInt64(FselectedRow["a_new_partner_key_n"]) != newPartnerKey))
                        {
                            FselectedRow["a_new_partner_key_n"] = newPartnerKey;
                            FPetraUtilsObject.SetChangedFlag();
                        }
                    }

                    String SelString = cmbMotivGroup.GetSelectedString();

                    if (FselectedRow["a_motiv_group_s"].ToString() != SelString)
                    {
                        FselectedRow["a_motiv_group_s"] = SelString;
                        FPetraUtilsObject.SetChangedFlag();
                    }

                    SelString = cmbMotivDetail.GetSelectedString();

                    if (FselectedRow["a_motiv_detail_s"].ToString() != SelString)
                    {
                        FselectedRow["a_motiv_detail_s"] = SelString;
                        FPetraUtilsObject.SetChangedFlag();
                    }
                }
                else
                {
                    MessageBox.Show("Error: PartnerKey is empty. Please delete unused row.",
                                    "ESR Defaults", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtPartnerKey.Text = FselectedRow["a_partner_key_n"].ToString();
                }
            }
        }
        private void PromoteOrDemoteRecord(Boolean APromote)
        {
            // Get the display index of the current row
            int curIndex = FPreviouslySelectedDetailRow.DisplayIndex;

            // Create a view on this display index and the neighbouring one
            DataView dv = new DataView(FMainDS.PAddressLayoutCode,
                                       String.Format("{0}={1} OR {0}={2}",
                                                     PAddressLayoutCodeTable.GetDisplayIndexDBName(),
                                                     curIndex,
                                                     APromote ? curIndex - 1 : curIndex + 1),
                                       String.Format("{0} ASC", PAddressLayoutCodeTable.GetDisplayIndexDBName()),
                                       DataViewRowState.CurrentRows);

            // We should have two rows
            if (dv.Count == 2)
            {
                PAddressLayoutCodeRow row1 = (PAddressLayoutCodeRow)dv[0].Row;
                PAddressLayoutCodeRow row2 = (PAddressLayoutCodeRow)dv[1].Row;

                row1.DisplayIndex = row1.DisplayIndex + 1;
                row2.DisplayIndex = row2.DisplayIndex - 1;

                FMainDS.PAddressLayoutCode.DefaultView.Sort = String.Format("{0} ASC", PAddressLayoutCodeTable.GetDisplayIndexDBName());

                if (APromote)
                {
                    SelectRowInGrid(GetSelectedRowIndex() - 1);
                }
                else
                {
                    SelectRowInGrid(GetSelectedRowIndex() + 1);
                }

                FPetraUtilsObject.SetChangedFlag();
            }
            else
            {
                // The display index values in the database have got mixed up.
                // Either there is a break in the sequence or there are two rows with the same index
                MessageBox.Show(Catalog.GetString(
                                    "The application encountered a problem with the record order, but has attempted to fix it.  Please try clicking the button again."),
                                Catalog.GetString("Layout Code Order"), MessageBoxButtons.OK, MessageBoxIcon.Information);

                // We can use the same code we use after deleting rows to restore a sequential display order
                FixDisplayIndexValues();
            }
        }
        // Called with Add button. Adds new venue to conference.
        private void AddVenue(object sender, EventArgs e)
        {
            long          ResultVenueKey;
            String        ResultVenueName;
            TPartnerClass?PartnerClass;
            TLocationPK   ResultLocationPK;

            DataRow[] ExistingVenueDataRows;

            // the user has to select an existing venue to make that venue a conference venue
            try
            {
                // launches partner find screen and returns true if a venue is selected
                if (TPartnerFindScreenManager.OpenModalForm("VENUE", out ResultVenueKey, out ResultVenueName, out PartnerClass, out ResultLocationPK,
                                                            this))
                {
                    // search for selected venue in dataset
                    ExistingVenueDataRows = FMainDS.PcConferenceVenue.Select(ConferenceSetupTDSPcConferenceVenueTable.GetVenueKeyDBName() +
                                                                             " = " + ResultVenueKey.ToString());

                    // if venue does not already exist for venue
                    if (ExistingVenueDataRows.Length == 0)
                    {
                        ConferenceSetupTDSPcConferenceVenueRow AddedVenue = FMainDS.PcConferenceVenue.NewRowTyped(true);
                        AddedVenue.ConferenceKey = FPartnerKey;
                        AddedVenue.VenueKey      = ResultVenueKey;
                        AddedVenue.VenueName     = ResultVenueName;
                        FMainDS.PcConferenceVenue.Rows.Add(AddedVenue);
                        FPetraUtilsObject.SetChangedFlag();
                    }
                    // if venue does already exist for venue
                    else
                    {
                        MessageBox.Show(Catalog.GetString("This venue is already included for this conference"),
                                        Catalog.GetString("Add Venue to Conference"),
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Information);
                    }
                }
            }
            catch (Exception exp)
            {
                throw new EOPAppException("Exception occured while calling VenueFindScreen!", exp);
            }
        }
        private void DataSaved(object Sender, TDataSavedEventArgs e)
        {
            TTypedDataTable ChildDTWhoseDataGotSaved;

            // Save the changes in the user control
            if ((e.Success) &&
                (!FDataSavedInNoMasterDataToSaveEvent))
            {
                FPetraUtilsObject.SetChangedFlag();

                ucoValues.SaveChanges(out ChildDTWhoseDataGotSaved);

                FPetraUtilsObject.DisableSaveButton();
            }

            // Ensure Filter functionality is enabled (might have been disabled in Method 'Uco_NoMoreDetailRecords')
            ActionEnabledEvent(null, new ActionEventArgs("cndFindFilterAvailable", true));
        }
        /// <summary>
        /// add a new short term application
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void NewRowShortTermApp(System.Object sender, EventArgs e)
        {
            // Clear any validation errors so that the following call to ValidateAllData starts with a 'clean slate'.
            FPetraUtilsObject.VerificationResultCollection.Clear();

            if (ValidateAllData(true, TErrorProcessingMode.Epm_IgnoreNonCritical))
            {
                // we create the table locally, no dataset
                IndividualDataTDSPmGeneralApplicationRow NewRowGeneralApp = FMainDS.PmGeneralApplication.NewRowTyped(true);
                PmShortTermApplicationRow NewRowShortTermApp = FMainDS.PmShortTermApplication.NewRowTyped(true);

                NewRowGeneralApp.PartnerKey                 = FMainDS.PPerson[0].PartnerKey;
                NewRowGeneralApp.ApplicationKey             = GetNextApplicationKey();
                NewRowGeneralApp.RegistrationOffice         = TSystemDefaults.GetSiteKeyDefault();
                NewRowGeneralApp.GenAppDate                 = DateTime.Today;
                NewRowGeneralApp.ApplicationForEventOrField = Catalog.GetString("Event");

                //TODO temp, needs to be changed
                NewRowGeneralApp.AppTypeName = "CONFERENCE";
                NewRowGeneralApp.OldLink     =
                    TSystemDefaults.GetSiteKeyDefault().ToString() + ";" + NewRowGeneralApp.ApplicationKey.ToString();
                NewRowGeneralApp.GenApplicantType = "Participant";

                NewRowShortTermApp.PartnerKey         = NewRowGeneralApp.PartnerKey;
                NewRowShortTermApp.ApplicationKey     = NewRowGeneralApp.ApplicationKey;
                NewRowShortTermApp.RegistrationOffice = NewRowGeneralApp.RegistrationOffice;
                NewRowShortTermApp.StAppDate          = NewRowGeneralApp.GenAppDate;

                //TODO temp, needs to be changed
                NewRowShortTermApp.StApplicationType = "A";
                NewRowShortTermApp.StBasicOutreachId = NewRowGeneralApp.OldLink;

                FMainDS.PmGeneralApplication.Rows.Add(NewRowGeneralApp);
                FMainDS.PmShortTermApplication.Rows.Add(NewRowShortTermApp);

                FPetraUtilsObject.SetChangedFlag();

                grdDetails.DataSource = null;
                grdDetails.DataSource = new DevAge.ComponentModel.BoundDataView(FMainDS.PmGeneralApplication.DefaultView);

                SelectDetailRowByDataTableIndex(FMainDS.PmGeneralApplication.Rows.Count - 1);
            }
        }
Пример #30
0
        /// <summary>
        /// add a new long term application
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void NewRowLongTermApp(System.Object sender, EventArgs e)
        {
            // Clear any validation errors so that the following call to ValidateAllData starts with a 'clean slate'.
            FPetraUtilsObject.VerificationResultCollection.Clear();

            if (ValidateAllData(true, true))
            {
                // we create the table locally, no dataset
                IndividualDataTDSPmGeneralApplicationRow NewRowGeneralApp = FMainDS.PmGeneralApplication.NewRowTyped(true);
                PmYearProgramApplicationRow NewRowLongTermApp             = FMainDS.PmYearProgramApplication.NewRowTyped(true);

                NewRowGeneralApp.PartnerKey                 = FMainDS.PPerson[0].PartnerKey;
                NewRowGeneralApp.ApplicationKey             = GetNextApplicationKey();
                NewRowGeneralApp.RegistrationOffice         = Convert.ToInt64(TSystemDefaults.GetSystemDefault(SharedConstants.SYSDEFAULT_SITEKEY, ""));
                NewRowGeneralApp.GenAppDate                 = DateTime.Today;
                NewRowGeneralApp.ApplicationForEventOrField = Catalog.GetString("Field");

                //TODO temp, needs to be changed
                NewRowGeneralApp.AppTypeName = "FIELD";
                NewRowGeneralApp.OldLink     =
                    TSystemDefaults.GetSystemDefault(SharedConstants.SYSDEFAULT_SITEKEY, "") + ";" + NewRowGeneralApp.ApplicationKey.ToString();;
                NewRowGeneralApp.GenApplicantType = "Participant";

                NewRowLongTermApp.PartnerKey         = NewRowGeneralApp.PartnerKey;
                NewRowLongTermApp.ApplicationKey     = NewRowGeneralApp.ApplicationKey;
                NewRowLongTermApp.RegistrationOffice = NewRowGeneralApp.RegistrationOffice;

                //TODO temp, needs to be changed
                NewRowLongTermApp.YpAppDate      = NewRowGeneralApp.GenAppDate;
                NewRowLongTermApp.YpBasicAppType = "Field";

                FMainDS.PmGeneralApplication.Rows.Add(NewRowGeneralApp);
                FMainDS.PmYearProgramApplication.Rows.Add(NewRowLongTermApp);

                FPetraUtilsObject.SetChangedFlag();

                grdDetails.DataSource = null;
                grdDetails.DataSource = new DevAge.ComponentModel.BoundDataView(FMainDS.PmGeneralApplication.DefaultView);

                SelectDetailRowByDataTableIndex(FMainDS.PmGeneralApplication.Rows.Count - 1);
            }
        }