/// <summary>
        /// Post document as a GL Batch
        /// See very similar function in TFrmAPSupplierTransactions
        /// </summary>
        private void PostDocument(object sender, EventArgs e)
        {
            if (FPetraUtilsObject.HasChanges)
            {
                MessageBox.Show(Catalog.GetString("Document should be saved before posting."), Catalog.GetString(
                                    "Post Document"), MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            GetDataFromControls(FMainDS.AApDocument[0]);

            // TODO: make sure that there are uptodate exchange rates

            if (!ApDocumentCanPost(FMainDS, FMainDS.AApDocument[0]))
            {
                return;
            }

            List <Int32> TaggedDocuments = new List <Int32>();

            TaggedDocuments.Add(FMainDS.AApDocument[0].ApDocumentId);

            if (PostApDocumentList(FMainDS, FMainDS.AApDocument[0].LedgerNumber, TaggedDocuments, this))
            {
                // TODO: print reports on successfully posted batch
                MessageBox.Show(Catalog.GetString("The AP document has been posted successfully!"));

                //
                // Refresh by re-loading the document from the server
                Int32 DocumentId = FMainDS.AApDocument[0].ApDocumentId;
                FMainDS.Clear();
                FPreviouslySelectedDetailRow = null;
                LoadAApDocument(FDocumentLedgerNumber, DocumentId);

                //
                // Also refresh the opener?
                TFormsMessage broadcastMessage = new TFormsMessage(TFormsMessageClassEnum.mcAPTransactionChanged);
                broadcastMessage.SetMessageDataAPTransaction(lblSupplierName.Text);
                TFormsList.GFormsList.BroadcastFormMessage(broadcastMessage);
            }
        }
Exemple #2
0
        private void ImportHierarchy(object sender, EventArgs e)
        {
            // TODO: open file; only will work if there are no GLM records and transactions yet
            XmlDocument doc;

            try
            {
                doc = TImportExportDialogs.ImportWithDialog(Catalog.GetString("Load Account Hierarchy from file"));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Catalog.GetString("Load Account Hierarchy from file"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (doc == null)
            {
                // was cancelled
                return;
            }

            if (!TRemote.MFinance.Setup.WebConnectors.ImportAccountHierarchy(FLedgerNumber, FSelectedHierarchy, TXMLParser.XmlToString(doc)))
            {
                MessageBox.Show(Catalog.GetString(
                                    "Import of new Account Hierarchy failed; perhaps there were already balances? Try with a new ledger!"),
                                Catalog.GetString("Error"), MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                // refresh the screen
                FMainDS.Clear();
                FMainDS.Merge(TRemote.MFinance.Setup.WebConnectors.LoadAccountHierarchies(FLedgerNumber));
                ucoAccountsTree.PopulateTreeView(FMainDS, FLedgerNumber, FSelectedHierarchy);

                MessageBox.Show("Import of new Account Hierarchy has been successful",
                                Catalog.GetString("Success"), MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemple #3
0
        private Boolean CheckAccountCodeValueChanged()
        {
            String strNewDetailAccountCode = txtDetailAccountCode.Text;
            String strAccountShortDescr    = txtDetailEngAccountCodeShortDesc.Text;

            bool changeAccepted = false;

            if (strNewDetailAccountCode != FRecentlyUpdatedDetailAccountCode)
            {
                if (strNewDetailAccountCode != strOldDetailAccountCode)
                {
                    if (strOldDetailAccountCode.IndexOf(FNameForNewAccounts) < 0) // If they're just changing this from the initial value, don't show warning.
                    {
                        if (MessageBox.Show(String.Format(Catalog.GetString(
                                                              "You have changed the Account Code from '{0}' to '{1}'.\r\n\r\n" +
                                                              "Please confirm that you want to rename this account by choosing 'OK'.\r\n\r\n" +
                                                              "(Renaming will take a few moments, then the form will be re-loaded.)"),
                                                          strOldDetailAccountCode,
                                                          strNewDetailAccountCode),
                                            Catalog.GetString("Rename Account: Confirmation"), MessageBoxButtons.OKCancel,
                                            MessageBoxIcon.Warning) != DialogResult.OK)
                        {
                            txtDetailAccountCode.Text = strOldDetailAccountCode;
                            return(false);
                        }
                    }

                    this.Cursor = Cursors.WaitCursor;
                    this.Refresh();  // Just to get the Wait Cursor to display...

                    FRecentlyUpdatedDetailAccountCode = strNewDetailAccountCode;

                    changeAccepted = ProtectedChangeOfPrimaryKey(FCurrentAccount);

                    if (changeAccepted)
                    {
                        ucoAccountsTree.SetNodeLabel(strNewDetailAccountCode, strAccountShortDescr);

                        if (FCurrentAccount.IsNew)
                        {
                            // This is the code for changes in "un-committed" nodes:
                            // there are no references to this new row yet, apart from children nodes, so I can just change them here and carry on!
                            ucoAccountsTree.FixupChildrenAfterAccountNameChange();

                            strOldDetailAccountCode                  = strNewDetailAccountCode;
                            FPetraUtilsObject.HasChanges             = true;
                            ucoAccountAnalysisAttributes.AccountCode = strNewDetailAccountCode;
                        }
                        else
                        {
                            ShowStatus(Catalog.GetString("Updating Account Code change - please wait."));
                            TVerificationResultCollection VerificationResults;

                            // If this code was previously in the DB, I need to assume that there may be transactions posted to it.
                            // There's a server call I need to use, and after the call I need to re-load this page.
                            // (No other changes will be lost, because the txtDetailAccountCode_TextChanged would
                            // have disallowed the change if there were already changes.)
                            bool Success = TRemote.MFinance.Setup.WebConnectors.RenameAccountCode(strOldDetailAccountCode,
                                                                                                  strNewDetailAccountCode,
                                                                                                  FLedgerNumber,
                                                                                                  out VerificationResults); // This call takes ages..

                            if (Success)
                            {
                                FIAmUpdating++;
                                FMainDS.Clear();
                                FMainDS.Merge(TRemote.MFinance.Setup.WebConnectors.LoadAccountHierarchies(FLedgerNumber));      // and this also takes a while!
                                strOldDetailAccountCode = "";
                                FPetraUtilsObject.SuppressChangeDetection = true;
                                ucoAccountsTree.PopulateTreeView(FMainDS, FLedgerNumber, FSelectedHierarchy);
                                ucoAccountsList.PopulateListView(FMainDS, FLedgerNumber, FSelectedHierarchy);
                                ShowDetailsManual(null);
                                ClearStatus();
                                FIAmUpdating--;
                                FPetraUtilsObject.SuppressChangeDetection = false;
                                ucoAccountsTree.SelectNodeByName(FRecentlyUpdatedDetailAccountCode);

                                ShowStatus(String.Format(Catalog.GetString("Account Code changed to '{0}'."), strNewDetailAccountCode));
                                TDataCache.TMFinance.RefreshCacheableFinanceTable(Shared.TCacheableFinanceTablesEnum.AccountList, FLedgerNumber);
                            }
                            else
                            {
                                MessageBox.Show(VerificationResults.BuildVerificationResultString(), Catalog.GetString("Rename Account"));
                            }

                            changeAccepted = false; // Actually the change was accepted, but processed here, so there's nothing left to do.
                            FPetraUtilsObject.HasChanges = false;
                        }

                        btnRename.Visible = false;
                    } // if changeAccepted

                    this.Cursor = Cursors.Default;
                } // if changed
            }     // if not handling the same change as before (prevents this method running several times for a single change!)

            return(changeAccepted);
        }
        private void InitializeManualCode()
        {
            string ConferenceName;

            // load data into dataset
            FMainDS.Clear();
            FMainDS.Merge(TRemote.MConference.Conference.WebConnectors.LoadConferenceSettings(FPartnerKey, out ConferenceName));

            // display conference name
            this.Text = this.Text + " [" + ConferenceName + "]";
            txtConferenceName.Text = ConferenceName;

            // display campaign code prefix
            txtCampaignPrefixCode.Text = ((PcConferenceRow)FMainDS.PcConference.Rows[0]).OutreachPrefix;

            // display start/end dates
            dtpStartDate.Date = ((PPartnerLocationRow)FMainDS.PPartnerLocation.Rows[0]).DateEffective;
            dtpEndDate.Date   = ((PPartnerLocationRow)FMainDS.PPartnerLocation.Rows[0]).DateGoodUntil;

            // enable dtps only if date is null
            if ((dtpStartDate.Date == null) || (dtpStartDate.Date == DateTime.MinValue))
            {
                dtpStartDate.ReadOnly = false;
                dtpStartDate.TabStop  = true;
            }

            if ((dtpEndDate.Date == null) || (dtpEndDate.Date == DateTime.MinValue))
            {
                dtpEndDate.ReadOnly = false;
                dtpEndDate.TabStop  = true;
            }

            // display currency (if currency code in PUnit has changed then use that over the currency code in PcConference)
            if (FMainDS.PUnit.Rows.Count == 0)
            {
                cmbCurrency.SetSelectedString(((PcConferenceRow)FMainDS.PcConference.Rows[0]).CurrencyCode, -1);
            }
            else
            {
                // There is a PUnit row
                if ((((PUnitRow)FMainDS.PUnit.Rows[0]).OutreachCostCurrencyCode != ((PcConferenceRow)FMainDS.PcConference.Rows[0]).CurrencyCode) &&
                    (((PUnitRow)FMainDS.PUnit.Rows[0]).OutreachCostCurrencyCode != String.Empty))
                {
                    // It is probably more up to date
                    cmbCurrency.SetSelectedString(((PUnitRow)FMainDS.PUnit.Rows[0]).OutreachCostCurrencyCode, -1);
                }
                else
                {
                    cmbCurrency.SetSelectedString(((PcConferenceRow)FMainDS.PcConference.Rows[0]).CurrencyCode, -1);
                }
            }

            // set radio buttons and checkbox
            Boolean ChargeCampaign        = true;
            Boolean AddAccommodationCosts = false;

            foreach (PcConferenceOptionRow CurrentRow in FMainDS.PcConferenceOption.Rows)
            {
                if ((CurrentRow.OptionTypeCode == "COST_PER_NIGHT") && (CurrentRow.OptionSet == true))
                {
                    ChargeCampaign   = false;
                    rbtNight.Checked = true;
                }
                else if ((CurrentRow.OptionTypeCode == "COST_PER_DAY") && (CurrentRow.OptionSet == true))
                {
                    ChargeCampaign = false;
                    rbtDay.Checked = true;
                }
                else if ((CurrentRow.OptionTypeCode == "ADD_ACCOMM_COST_FOR_TOTAL") && (CurrentRow.OptionSet == true))
                {
                    AddAccommodationCosts = true;
                }
            }

            if (ChargeCampaign == true)
            {
                rbtCampaign.Checked = true;
                chkAddAccommodationCosts.Enabled = false;
            }
            else if (AddAccommodationCosts == true)
            {
                chkAddAccommodationCosts.Checked             = true;
                txtSpecialRolePreAccommodation.ReadOnly      = false;
                txtVolunteerPreAccommodation.ReadOnly        = false;
                txtParticipantPreAccommodation.ReadOnly      = false;
                txtSpecialRoleAccommodation.ReadOnly         = false;
                txtVolunteerAccommodation.ReadOnly           = false;
                txtSpecialRoleCampaignAccommodation.ReadOnly = false;

                txtSpecialRolePreAccommodation.TabStop      = true;
                txtVolunteerPreAccommodation.TabStop        = true;
                txtParticipantPreAccommodation.TabStop      = true;
                txtSpecialRoleAccommodation.TabStop         = true;
                txtVolunteerAccommodation.TabStop           = true;
                txtSpecialRoleCampaignAccommodation.TabStop = true;
            }

            // display conference discounts
            foreach (PcDiscountRow CurrentRow in FMainDS.PcDiscount.Rows)
            {
                if (CurrentRow.CostTypeCode == "CONFERENCE")
                {
                    if (CurrentRow.Validity == "PRE")
                    {
                        if (CurrentRow.DiscountCriteriaCode == "ROLE")
                        {
                            txtSpecialRolePreAttendance.NumberValueInt = (int)CurrentRow.Discount;
                        }
                        else if (CurrentRow.DiscountCriteriaCode == "VOL")
                        {
                            txtVolunteerPreAttendance.NumberValueInt = (int)CurrentRow.Discount;
                        }
                        else if (CurrentRow.DiscountCriteriaCode == "OTHER")
                        {
                            txtParticipantPreAttendance.NumberValueInt = (int)CurrentRow.Discount;
                        }
                    }
                    else if (CurrentRow.Validity == "CONF")
                    {
                        if (CurrentRow.DiscountCriteriaCode == "ROLE")
                        {
                            txtSpecialRoleAttendance.NumberValueInt = (int)CurrentRow.Discount;
                        }
                        else if (CurrentRow.DiscountCriteriaCode == "VOL")
                        {
                            txtVolunteerAttendance.NumberValueInt = (int)CurrentRow.Discount;
                        }
                    }
                    else if ((CurrentRow.Validity == "POST") && (CurrentRow.DiscountCriteriaCode == "ROLE"))
                    {
                        txtSpecialRoleCampaignAttendance.NumberValueInt = (int)CurrentRow.Discount;
                    }
                }
                else if (CurrentRow.CostTypeCode == "ACCOMMODATION")
                {
                    if (CurrentRow.Validity == "PRE")
                    {
                        if (CurrentRow.DiscountCriteriaCode == "ROLE")
                        {
                            txtSpecialRolePreAccommodation.NumberValueInt = (int)CurrentRow.Discount;
                        }
                        else if (CurrentRow.DiscountCriteriaCode == "VOL")
                        {
                            txtVolunteerPreAccommodation.NumberValueInt = (int)CurrentRow.Discount;
                        }
                        else if (CurrentRow.DiscountCriteriaCode == "OTHER")
                        {
                            txtParticipantPreAccommodation.NumberValueInt = (int)CurrentRow.Discount;
                        }
                    }
                    else if (CurrentRow.Validity == "CONF")
                    {
                        if (CurrentRow.DiscountCriteriaCode == "ROLE")
                        {
                            txtSpecialRoleAccommodation.NumberValueInt = (int)CurrentRow.Discount;
                        }
                        else if (CurrentRow.DiscountCriteriaCode == "VOL")
                        {
                            txtVolunteerAccommodation.NumberValueInt = (int)CurrentRow.Discount;
                        }
                    }
                    else if ((CurrentRow.Validity == "POST") && (CurrentRow.DiscountCriteriaCode == "ROLE"))
                    {
                        txtSpecialRoleCampaignAccommodation.NumberValueInt = (int)CurrentRow.Discount;
                    }
                }
            }

            // display grid containing venue details
            grdVenues.Columns.Clear();
            grdVenues.AddPartnerKeyColumn(Catalog.GetString("Venue Key"), FMainDS.PcConferenceVenue.ColumnVenueKey);
            grdVenues.AddTextColumn(Catalog.GetString("Venue Name"), FMainDS.PcConferenceVenue.ColumnVenueName);

            DataView MyDataView = FMainDS.PcConferenceVenue.DefaultView;

            MyDataView.Sort      = "p_venue_name_c ASC";
            MyDataView.AllowNew  = false;
            grdVenues.DataSource = new DevAge.ComponentModel.BoundDataView(MyDataView);

            FPetraUtilsObject.ApplySecurity(TSecurityChecks.SecurityPermissionsSetupScreensEditingAndSaving);
        }