Ejemplo n.º 1
0
        private void BtnView_Click(object sender, EventArgs e)
        {
            // get the currently selected row
            DataRow CurrentlySelectedRow = GetCurrentDataRow();

            if (CurrentlySelectedRow != null)
            {
                try
                {
                    this.Cursor = Cursors.WaitCursor;

                    TFrmGiftBatch gb = new TFrmGiftBatch(this);
                    gb.LedgerNumber = FLedgerNumber;

                    // load dataset with data for whole transaction (all details)

                    // Viewmode = true

                    /*gb.ViewModeTDS = TRemote.MFinance.Gift.WebConnectors.LoadAGiftSingle(FLedgerNumber,
                     *  (int)CurrentlySelectedRow["a_batch_number_i"],
                     *  (int)CurrentlySelectedRow["a_gift_transaction_number_i"]);
                     *
                     * if (gb.ViewModeTDS.AGiftBatch[0].BatchStatus == MFinanceConstants.BATCH_POSTED)
                     * {
                     *  // read only if gift belongs to a posted batch
                     *  gb.ViewMode = true;
                     *  gb.ShowDetailsOfOneBatch(FLedgerNumber, (int)CurrentlySelectedRow["a_batch_number_i"],
                     *      gb.ViewModeTDS.AGiftBatch[0].BatchYear, gb.ViewModeTDS.AGiftBatch[0].BatchPeriod);
                     * }
                     * else
                     * {
                     *  gb.ShowDetailsOfOneBatch(FLedgerNumber, (int)CurrentlySelectedRow["a_batch_number_i"],
                     *      gb.ViewModeTDS.AGiftBatch[0].BatchYear, gb.ViewModeTDS.AGiftBatch[0].BatchPeriod);
                     *  gb.DisableBatches();
                     * }*/

                    // Viewmode = false
                    gb.ShowDetailsOfOneBatch(FLedgerNumber, (int)CurrentlySelectedRow["a_batch_number_i"],
                                             (int)CurrentlySelectedRow["a_batch_year_i"], (int)CurrentlySelectedRow["a_batch_period_i"]);

                    gb.SelectTab(TFrmGiftBatch.eGiftTabs.Transactions);

                    gb.FindGiftDetail((int)CurrentlySelectedRow["a_batch_number_i"],
                                      (int)CurrentlySelectedRow["a_gift_transaction_number_i"], (int)CurrentlySelectedRow["a_detail_number_i"]);
                }
                finally
                {
                    this.Cursor = Cursors.Default;
                }
            }
        }
        private void ViewTransaction(object sender, EventArgs e)
        {
            // get the currently selected row
            FPreviouslySelectedDetailRow = GetSelectedDetailRow();

            if ((FPreviouslySelectedDetailRow != null) && (FMainDS != null))
            {
                try
                {
                    this.Cursor = Cursors.WaitCursor;

                    TFrmGiftBatch gb = new TFrmGiftBatch(this);

                    // load dataset with data for whole transaction (all details)
                    gb.ViewModeTDS = TRemote.MFinance.Gift.WebConnectors.LoadAGiftSingle(FLedgerNumber,
                                                                                         (int)FPreviouslySelectedDetailRow["BatchNumber"],
                                                                                         (int)FPreviouslySelectedDetailRow["GiftTransactionNumber"]);

                    if (gb.ViewModeTDS.AGiftBatch[0].BatchStatus == MFinanceConstants.BATCH_POSTED)
                    {
                        // read only if gift belongs to a posted batch
                        gb.ViewMode = true;
                        gb.ShowDetailsOfOneBatch(FLedgerNumber, (int)FPreviouslySelectedDetailRow["BatchNumber"],
                                                 gb.ViewModeTDS.AGiftBatch[0].BatchYear, gb.ViewModeTDS.AGiftBatch[0].BatchPeriod);
                    }
                    else
                    {
                        gb.ShowDetailsOfOneBatch(FLedgerNumber, (int)FPreviouslySelectedDetailRow["BatchNumber"],
                                                 gb.ViewModeTDS.AGiftBatch[0].BatchYear, gb.ViewModeTDS.AGiftBatch[0].BatchPeriod);
                        gb.DisableBatches();
                    }

                    gb.SelectTab(TFrmGiftBatch.eGiftTabs.Transactions);
                    gb.FindGiftDetail((AGiftDetailRow)gb.ViewModeTDS.AGiftDetail.Rows.Find(
                                          new object[] { FLedgerNumber,
                                                         FPreviouslySelectedDetailRow["BatchNumber"],
                                                         FPreviouslySelectedDetailRow["GiftTransactionNumber"],
                                                         FPreviouslySelectedDetailRow["DetailNumber"] }));
                }
                finally
                {
                    this.Cursor = Cursors.Default;
                }
            }
        }
        private void BtnView_Click(object sender, EventArgs e)
        {
            // get the currently selected row
            DataRow CurrentlySelectedRow = GetCurrentDataRow();

            if (CurrentlySelectedRow != null)
            {
                try
                {
                    this.Cursor = Cursors.WaitCursor;

                    TFrmGiftBatch gb = new TFrmGiftBatch(this);
                    gb.LedgerNumber = FLedgerNumber;

                    // load dataset with data for whole transaction (all details)

                    // Viewmode = true

                    /*gb.ViewModeTDS = TRemote.MFinance.Gift.WebConnectors.LoadAGiftSingle(FLedgerNumber,
                     *  (int)CurrentlySelectedRow["a_batch_number_i"],
                     *  (int)CurrentlySelectedRow["a_gift_transaction_number_i"]);
                     *
                     * if (gb.ViewModeTDS.AGiftBatch[0].BatchStatus == MFinanceConstants.BATCH_POSTED)
                     * {
                     *  // read only if gift belongs to a posted batch
                     *  gb.ViewMode = true;
                     *  gb.ShowDetailsOfOneBatch(FLedgerNumber, (int)CurrentlySelectedRow["a_batch_number_i"],
                     *      gb.ViewModeTDS.AGiftBatch[0].BatchYear, gb.ViewModeTDS.AGiftBatch[0].BatchPeriod);
                     * }
                     * else
                     * {
                     *  gb.ShowDetailsOfOneBatch(FLedgerNumber, (int)CurrentlySelectedRow["a_batch_number_i"],
                     *      gb.ViewModeTDS.AGiftBatch[0].BatchYear, gb.ViewModeTDS.AGiftBatch[0].BatchPeriod);
                     *  gb.DisableBatches();
                     * }*/

                    // Viewmode = false
                    gb.ShowDetailsOfOneBatch(FLedgerNumber, (int)CurrentlySelectedRow["a_batch_number_i"],
                        (int)CurrentlySelectedRow["a_batch_year_i"], (int)CurrentlySelectedRow["a_batch_period_i"]);

                    gb.SelectTab(TFrmGiftBatch.eGiftTabs.Transactions);

                    gb.FindGiftDetail((int)CurrentlySelectedRow["a_batch_number_i"],
                        (int)CurrentlySelectedRow["a_gift_transaction_number_i"], (int)CurrentlySelectedRow["a_detail_number_i"]);
                }
                finally
                {
                    this.Cursor = Cursors.Default;
                }
            }
        }
        private void ViewTransaction(object sender, EventArgs e)
        {
            // get the currently selected row
            FPreviouslySelectedDetailRow = GetSelectedDetailRow();

            if ((FPreviouslySelectedDetailRow != null) && (FMainDS != null))
            {
                try
                {
                    this.Cursor = Cursors.WaitCursor;

                    TFrmGiftBatch gb = new TFrmGiftBatch(this);

                    // load dataset with data for whole transaction (all details)
                    gb.ViewModeTDS = TRemote.MFinance.Gift.WebConnectors.LoadAGiftSingle(FLedgerNumber,
                        (int)FPreviouslySelectedDetailRow["BatchNumber"],
                        (int)FPreviouslySelectedDetailRow["GiftTransactionNumber"]);

                    if (gb.ViewModeTDS.AGiftBatch[0].BatchStatus == MFinanceConstants.BATCH_POSTED)
                    {
                        // read only if gift belongs to a posted batch
                        gb.ViewMode = true;
                        gb.ShowDetailsOfOneBatch(FLedgerNumber, (int)FPreviouslySelectedDetailRow["BatchNumber"],
                            gb.ViewModeTDS.AGiftBatch[0].BatchYear, gb.ViewModeTDS.AGiftBatch[0].BatchPeriod);
                    }
                    else
                    {
                        gb.ShowDetailsOfOneBatch(FLedgerNumber, (int)FPreviouslySelectedDetailRow["BatchNumber"],
                            gb.ViewModeTDS.AGiftBatch[0].BatchYear, gb.ViewModeTDS.AGiftBatch[0].BatchPeriod);
                        gb.DisableBatches();
                    }

                    gb.SelectTab(TFrmGiftBatch.eGiftTabs.Transactions);
                    gb.FindGiftDetail((AGiftDetailRow)gb.ViewModeTDS.AGiftDetail.Rows.Find(
                            new object[] { FLedgerNumber,
                                           FPreviouslySelectedDetailRow["BatchNumber"],
                                           FPreviouslySelectedDetailRow["GiftTransactionNumber"],
                                           FPreviouslySelectedDetailRow["DetailNumber"] }));
                }
                finally
                {
                    this.Cursor = Cursors.Default;
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// show the form for the gift reversal/adjustment
        /// </summary>
        /// <param name="AFunctionName">Which function shall be called on the server</param>
        private void ShowRevertAdjustForm(GiftAdjustmentFunctionEnum AFunctionName)
        {
            TFrmGiftBatch ParentGiftBatchForm = (TFrmGiftBatch)ParentForm;
            bool          ReverseWholeBatch   = (AFunctionName == GiftAdjustmentFunctionEnum.ReverseGiftBatch);
            bool          AdjustGift          = (AFunctionName == GiftAdjustmentFunctionEnum.AdjustGift);

            if (!ParentGiftBatchForm.SaveChangesManual())
            {
                return;
            }

            ParentGiftBatchForm.Cursor = Cursors.WaitCursor;

            AGiftBatchRow giftBatch   = ((TFrmGiftBatch)ParentForm).GetBatchControl().GetSelectedDetailRow();
            int           BatchNumber = giftBatch.BatchNumber;

            if (giftBatch == null)
            {
                MessageBox.Show(Catalog.GetString("Please select a Gift Batch to Reverse."));
                ParentGiftBatchForm.Cursor = Cursors.Default;
                return;
            }

            if (!giftBatch.BatchStatus.Equals(MFinanceConstants.BATCH_POSTED))
            {
                MessageBox.Show(Catalog.GetString("This function is only possible when the selected batch is already posted."));
                ParentGiftBatchForm.Cursor = Cursors.Default;
                return;
            }

            if (FPetraUtilsObject.HasChanges)
            {
                MessageBox.Show(Catalog.GetString("Please save first and than try again!"));
                ParentGiftBatchForm.Cursor = Cursors.Default;
                return;
            }

            if (ReverseWholeBatch && (FBatchNumber != BatchNumber))
            {
                ParentGiftBatchForm.SelectTab(TFrmGiftBatch.eGiftTabs.Transactions, true);
                ParentGiftBatchForm.SelectTab(TFrmGiftBatch.eGiftTabs.Batches);
                ParentGiftBatchForm.Cursor = Cursors.WaitCursor;
            }

            if (!ReverseWholeBatch && (FPreviouslySelectedDetailRow == null))
            {
                MessageBox.Show(Catalog.GetString("Please select a Gift to Adjust/Reverse."));
                ParentGiftBatchForm.Cursor = Cursors.Default;
                return;
            }

            TFrmGiftRevertAdjust revertForm = new TFrmGiftRevertAdjust(FPetraUtilsObject.GetForm());

            if (AdjustGift)
            {
                if (FSETUseTaxDeductiblePercentageFlag)
                {
                    revertForm.CheckTaxDeductPctChange = true;
                }

                revertForm.CheckGiftDestinationChange = true;
            }

            try
            {
                ParentForm.ShowInTaskbar = false;
                revertForm.LedgerNumber  = FLedgerNumber;
                revertForm.CurrencyCode  = giftBatch.CurrencyCode;

                // put spaces inbetween words
                revertForm.Text = Regex.Replace(AFunctionName.ToString(), "([a-z])([A-Z])", @"$1 $2");

                revertForm.AddParam("Function", AFunctionName);
                revertForm.AddParam("BatchNumber", giftBatch.BatchNumber);

                if (AdjustGift)
                {
                    int workingTransactionNumber = FPreviouslySelectedDetailRow.GiftTransactionNumber;
                    int workingDetailNumber      = FPreviouslySelectedDetailRow.DetailNumber;
                    revertForm.GiftDetailRow = (AGiftDetailRow)FMainDS.AGiftDetail.Rows.Find(
                        new object[] { giftBatch.LedgerNumber, giftBatch.BatchNumber, workingTransactionNumber, workingDetailNumber });
                }

                if (ReverseWholeBatch)
                {
                    revertForm.GetGiftsForReverseAdjust(); // Added Feb '17 Tim Ingham - previously, reversing a whole batch didn't work.
                }

                if (!revertForm.IsDisposed && (revertForm.ShowDialog() == DialogResult.OK))
                {
                    ParentGiftBatchForm.Cursor = Cursors.WaitCursor;

                    if ((revertForm.AdjustmentBatchNumber > 0) && (revertForm.AdjustmentBatchNumber != giftBatch.BatchNumber))
                    {
                        // select the relevant batch
                        ParentGiftBatchForm.InitialBatchNumber = revertForm.AdjustmentBatchNumber;
                    }

                    ParentGiftBatchForm.RefreshAll();
                }
            }
            finally
            {
                ParentGiftBatchForm.Cursor = Cursors.WaitCursor;
                revertForm.Dispose();
                ParentForm.ShowInTaskbar   = true;
                ParentGiftBatchForm.Cursor = Cursors.Default;
            }

            if (AdjustGift && (ParentGiftBatchForm.ActiveTab() == TFrmGiftBatch.eGiftTabs.Transactions))
            {
                //Select first row for adjusting, i.e. first +ve amount
                foreach (DataRowView drv in FMainDS.AGiftDetail.DefaultView)
                {
                    AGiftDetailRow gdr = (AGiftDetailRow)drv.Row;

                    if (gdr.GiftTransactionAmount > 0)
                    {
                        grdDetails.SelectRowInGrid(grdDetails.Rows.DataSourceRowToIndex(drv) + 1);
                    }
                }
            }
        }