コード例 #1
0
        /// <summary>
        /// Update Budget Period Amounts for each record that was created or modified during an import
        /// </summary>
        private void UpdateABudgetPeriodAmounts(BudgetTDS AMainDS, int ACurrentBudgetYear)
        {
            DataView BudgetDV = new DataView(AMainDS.ABudget);

            BudgetDV.RowFilter = String.Format("Isnull({0},'') <> '' And ({0}='Added' Or {0}='Updated')",
                                               ABudgetTable.GetCommentDBName());

            BudgetDV.Sort = String.Format("{0} ASC",
                                          ABudgetTable.GetYearDBName());

            foreach (DataRowView drv in BudgetDV)
            {
                BudgetTDSABudgetRow budgetRow = (BudgetTDSABudgetRow)drv.Row;

                int budgetSeq = budgetRow.BudgetSequence;

                DataView budgetPeriodsDV = new DataView(AMainDS.ABudgetPeriod);

                budgetPeriodsDV.RowFilter = String.Format("{0}={1}",
                                                          ABudgetPeriodTable.GetBudgetSequenceDBName(),
                                                          budgetRow.BudgetSequence);
                budgetPeriodsDV.Sort = String.Format("{0} ASC",
                                                     ABudgetPeriodTable.GetPeriodNumberDBName());

                foreach (DataRowView drv2 in budgetPeriodsDV)
                {
                    ABudgetPeriodRow budgetPeriodRow = (ABudgetPeriodRow)drv2.Row;

                    int    period             = budgetPeriodRow.PeriodNumber;
                    string periodAmountColumn = string.Empty;

                    if (period <= FNumberOfPeriods)
                    {
                        periodAmountColumn            = "Period" + period.ToString("00") + "Amount";
                        budgetRow[periodAmountColumn] = budgetPeriodRow.BudgetBase;
                    }
                    else
                    {
                        //TODO After data migration, this should not happen so add an error message.
                        // In old Petra, budget periods always go up to 20, but are only populated
                        //   up to number of financial periods
                    }
                }
            }

            //Remove import related comment
            // - done separately to loop above to avoid confusion as DataView filtering is on Comment field
            foreach (DataRowView drv in BudgetDV)
            {
                BudgetTDSABudgetRow budgetRow = (BudgetTDSABudgetRow)drv.Row;
                budgetRow.Comment = string.Empty;
            }
        }
コード例 #2
0
        private void UpdatePeriodAmountsFromControls(BudgetTDSABudgetRow ARow)
        {
            if (ARow == null)
            {
                return;
            }

            //Write to Budget custom fields
            for (int i = 1; i <= FNumberOfPeriods; i++)
            {
                ABudgetPeriodRow budgetPeriodRow = (ABudgetPeriodRow)FMainDS.ABudgetPeriod.Rows.Find(
                    new object[] { ARow.BudgetSequence, i });

                if (budgetPeriodRow != null)
                {
                    string customColumn = "Period" + i.ToString("00") + "Amount";

                    if ((decimal)ARow[customColumn] != budgetPeriodRow.BudgetBase)
                    {
                        ARow[customColumn] = budgetPeriodRow.BudgetBase;
                    }
                }

                budgetPeriodRow = null;
            }
        }
コード例 #3
0
        private bool GetDetailDataFromControlsManual(BudgetTDSABudgetRow ARow)
        {
            if (ARow != null)
            {
                ARow.BeginEdit();

                if (rbtAdHoc.Checked)
                {
                    if (FPetraUtilsObject.HasChanges)
                    {
                        ProcessBudgetTypeAdhoc(null, null);
                        ClearBudgetTypeTextboxesExcept(MFinanceConstants.BUDGET_ADHOC);
                    }

                    ARow.BudgetTypeCode = MFinanceConstants.BUDGET_ADHOC;
                }
                else if (rbtSame.Checked)
                {
                    if (FPetraUtilsObject.HasChanges)
                    {
                        ProcessBudgetTypeSame(null, null);
                        ClearBudgetTypeTextboxesExcept(MFinanceConstants.BUDGET_SAME);
                    }

                    ARow.BudgetTypeCode = MFinanceConstants.BUDGET_SAME;
                }
                else if (rbtSplit.Checked)
                {
                    if (FPetraUtilsObject.HasChanges)
                    {
                        ProcessBudgetTypeSplit(null, null);
                        ClearBudgetTypeTextboxesExcept(MFinanceConstants.BUDGET_SPLIT);
                    }

                    ARow.BudgetTypeCode = MFinanceConstants.BUDGET_SPLIT;
                }
                else if (rbtInflateN.Checked)
                {
                    if (FPetraUtilsObject.HasChanges)
                    {
                        ProcessBudgetTypeInflateN(null, null);
                        ClearBudgetTypeTextboxesExcept(MFinanceConstants.BUDGET_INFLATE_N);
                    }

                    ARow.BudgetTypeCode = MFinanceConstants.BUDGET_INFLATE_N;
                }
                else      //rbtInflateBase.Checked
                {
                    if (FPetraUtilsObject.HasChanges)
                    {
                        ProcessBudgetTypeInflateBase(null, null);
                        ClearBudgetTypeTextboxesExcept(MFinanceConstants.BUDGET_INFLATE_BASE);
                    }

                    ARow.BudgetTypeCode = MFinanceConstants.BUDGET_INFLATE_BASE;
                }

                //Write to Budget custom fields
                UpdatePeriodAmountsFromControls(ARow);

                //ARow.Year & ARow.Revision are never set here, but on record creation

                ARow.EndEdit();
            }

            return true;
        }
コード例 #4
0
        private void NewRowManual(ref BudgetTDSABudgetRow ARow)
        {
            if (!cmbDetailAccountCode.Enabled)
            {
                EnableBudgetEntry(true);
            }

            ARow.BudgetSequence = Convert.ToInt32(TRemote.MCommon.WebConnectors.GetNextSequence(TSequenceNames.seq_budget));
            ARow.LedgerNumber = FLedgerNumber;
            ARow.Revision = CreateBudgetRevisionRow(FLedgerNumber, FSelectedBudgetYear);
            ARow.Year = FSelectedBudgetYear;

            //Add the budget period values
            for (int i = 1; i <= FNumberOfPeriods; i++)
            {
                ABudgetPeriodRow budgetPeriodRow = FMainDS.ABudgetPeriod.NewRowTyped();
                budgetPeriodRow.BudgetSequence = ARow.BudgetSequence;
                budgetPeriodRow.PeriodNumber = i;
                budgetPeriodRow.BudgetBase = 0;
                FMainDS.ABudgetPeriod.Rows.Add(budgetPeriodRow);
                budgetPeriodRow = null;
            }
        }
コード例 #5
0
        private void ShowDetailsManual(BudgetTDSABudgetRow ARow)
        {
            ClearBudgetTypeTextboxesExcept("None");
            UpdateCurrencyCode();

            if ((ARow == null) || ((grdDetails.Rows.Count < 2) && rgrBudgetTypeCode.Enabled))
            {
                FBudgetSequence = -1;
                EnableBudgetEntry(false);
                return;
            }
            else if (rgrBudgetTypeCode.Enabled == false)
            {
                EnableBudgetEntry(true);
            }

            if (ARow.BudgetTypeCode == MFinanceConstants.BUDGET_SPLIT)
            {
                rbtSplit.Checked = true;
                DisplayBudgetTypeSplit();
            }
            else if (ARow.BudgetTypeCode == MFinanceConstants.BUDGET_ADHOC)
            {
                rbtAdHoc.Checked = true;
                DisplayBudgetTypeAdhoc();
            }
            else if (ARow.BudgetTypeCode == MFinanceConstants.BUDGET_SAME)
            {
                rbtSame.Checked = true;
                DisplayBudgetTypeSame();
            }
            else if (ARow.BudgetTypeCode == MFinanceConstants.BUDGET_INFLATE_BASE)
            {
                rbtInflateBase.Checked = true;
                DisplayBudgetTypeInflateBase();
            }
            else          //ARow.BudgetTypeCode = MFinanceConstants.BUDGET_INFLATE_N
            {
                rbtInflateN.Checked = true;
                DisplayBudgetTypeInflateN();
            }

            FBudgetSequence = ARow.BudgetSequence;

            pnlBudgetTypeAdhoc.Visible = rbtAdHoc.Checked;
            pnlBudgetTypeSame.Visible = rbtSame.Checked;
            pnlBudgetTypeSplit.Visible = rbtSplit.Checked;
            pnlBudgetTypeInflateN.Visible = rbtInflateN.Checked;
            pnlBudgetTypeInflateBase.Visible = rbtInflateBase.Checked;
        }