示例#1
0
        async void LoadGLTrans()
        {
            childDgGLTrans.ClearSorting();
            SetExpandAndCollapse(true);
            List <int> dim1 = null, dim2 = null, dim3 = null, dim4 = null, dim5 = null;

            var NumberOfDimensions = api.CompanyEntity.NumberOfDimensions;

            if (NumberOfDimensions >= 1)
            {
                dim1 = TransactionReport.GetRowIDs(cbdim1);
            }
            if (NumberOfDimensions >= 2)
            {
                dim2 = TransactionReport.GetRowIDs(cbdim2);
            }
            if (NumberOfDimensions >= 3)
            {
                dim3 = TransactionReport.GetRowIDs(cbdim3);
            }
            if (NumberOfDimensions >= 4)
            {
                dim4 = TransactionReport.GetRowIDs(cbdim4);
            }
            if (NumberOfDimensions >= 5)
            {
                dim5 = TransactionReport.GetRowIDs(cbdim5);
            }
            AccountStatement.SetDateTime(txtDateFrm, txtDateTo);
            DateTime fromDate = AccountStatement.DefaultFromDate, toDate = AccountStatement.DefaultToDate;

            var showDimOnPrimo = cmbShowDimOnPrimo.SelectedIndex;

#if !SILVERLIGHT
            pageBreak = cbxPageBreak.IsChecked.Value;
#endif
            setShowDimOnPrimoIndex = showDimOnPrimo;

            string fromAccount = null, toAccount = null;
            var    accountObj = cmbFromAccount.EditValue;
            if (accountObj != null)
            {
                fromAccount = accountObj.ToString();
            }

            accountObj = cmbToAccount.EditValue;
            if (accountObj != null)
            {
                toAccount = accountObj.ToString();
            }

            busyIndicator.IsBusy = true;

            if (Simulated.Visible)
            {
                SimulatedVisible = true;
            }
            string journal = cmbJournal.Text;
            Simulated.Visible = SimulatedVisible && !string.IsNullOrWhiteSpace(journal);

            var dimensionParams = BalanceReport.SetDimensionParameters(dim1, dim2, dim3, dim4, dim5, true, true, true, true, true);
            var listTrans       = (GLTransClientTotal[])await transApi.GetTransactions(new GLTransClientTotal(), journal, fromAccount, toAccount, fromDate, toDate, dimensionParams, showDimOnPrimo);

            if (accountCache == null)
            {
                accountCache = await transApi.CompanyEntity.LoadCache(typeof(Uniconta.DataModel.GLAccount), api);
            }

            if (listTrans != null)
            {
                FillStatement(listTrans);
            }
            else if (transApi.LastError != 0)
            {
                Uniconta.ClientTools.Util.UtilDisplay.ShowErrorCode(transApi.LastError);
            }
            dgGLTrans.Visibility = Visibility.Visible;
            busyIndicator.IsBusy = false;
            SetExpandAndCollapse(IsCollapsed);
        }
        async void LoadGLTrans()
        {
            SetExpandAndCollapse(true);
            statementList.Clear();
            List <int> dim1 = null, dim2 = null, dim3 = null, dim4 = null, dim5 = null;

            var NumberOfDimensions = api.CompanyEntity.NumberOfDimensions;

            if (NumberOfDimensions >= 1)
            {
                dim1 = TransactionReport.GetRowIDs(cbdim1);
            }
            if (NumberOfDimensions >= 2)
            {
                dim2 = TransactionReport.GetRowIDs(cbdim2);
            }
            if (NumberOfDimensions >= 3)
            {
                dim3 = TransactionReport.GetRowIDs(cbdim3);
            }
            if (NumberOfDimensions >= 4)
            {
                dim4 = TransactionReport.GetRowIDs(cbdim4);
            }
            if (NumberOfDimensions >= 5)
            {
                dim5 = TransactionReport.GetRowIDs(cbdim5);
            }
            AccountStatement2.SetDateTime(txtDateFrm, txtDateTo);
            DateTime fromDate = AccountStatement2.DefaultFromDate, toDate = AccountStatement2.DefaultToDate;

            var isAscending = cbxAscending.IsChecked.Value;
            var skipBlank   = cbxSkipBlank.IsChecked.Value;

            var Pref = api.session.Preference;

            Pref.TransactionReport_isAscending = isAscending;
            Pref.TransactionReport_skipBlank   = skipBlank;

            string fromAccount = null, toAccount = null;
            var    accountObj = cmbFromAccount.EditValue;

            if (accountObj != null)
            {
                fromAccount = accountObj.ToString();
            }

            accountObj = cmbToAccount.EditValue;
            if (accountObj != null)
            {
                toAccount = accountObj.ToString();
            }

            string journal = cmbJournal.Text;

            busyIndicator.IsBusy = true;
            var transApi        = new Uniconta.API.GeneralLedger.ReportAPI(api);
            var dimensionParams = BalanceReport.SetDimensionParameters(dim1, dim2, dim3, dim4, dim5, true, true, true, true, true);
            var listTrans       = (GLTransClientTotal[])await transApi.GetTransactions(new GLTransClientTotal(), journal, fromAccount, toAccount, fromDate, toDate, dimensionParams, ReportAPI.SimplePrimo);

            if (listTrans != null)
            {
                string currentItem = null;
                AccountStatementList2     masterDbStatement = null;
                List <GLTransClientTotal> dbTransClientChildList = null;
                long SumAmount = 0, SumAmountCur = 0;
                byte currentCur = 0;

                foreach (var trans in listTrans)
                {
                    if (trans._Account != currentItem)
                    {
                        currentItem = trans._Account;

                        if (masterDbStatement != null)
                        {
                            if (!skipBlank || SumAmount != 0 || SumAmountCur != 0 || dbTransClientChildList.Count > 1)
                            {
                                masterDbStatement._SumAmount    = SumAmount / 100d;
                                masterDbStatement._SumAmountCur = SumAmountCur / 100d;
                                statementList.Add(masterDbStatement);
                            }
                        }

                        masterDbStatement              = new AccountStatementList2((GLAccount)accountCache.Get(currentItem));
                        dbTransClientChildList         = new List <GLTransClientTotal>();
                        masterDbStatement.ChildRecords = dbTransClientChildList;
                        SumAmount  = SumAmountCur = 0;
                        currentCur = (byte)masterDbStatement.Acc._Currency;
                    }

                    SumAmount   += trans._AmountCent;
                    trans._Total = SumAmount;
                    masterDbStatement._SumAmount = SumAmount;

                    if (trans._AmountCurCent != 0 && trans._Currency == currentCur)
                    {
                        SumAmountCur   += trans._AmountCurCent;
                        trans._TotalCur = SumAmountCur;
                    }

                    if (isAscending)
                    {
                        dbTransClientChildList.Add(trans);
                    }
                    else
                    {
                        dbTransClientChildList.Insert(0, trans);
                    }
                }

                if (masterDbStatement != null)
                {
                    if (!skipBlank || SumAmount != 0 || SumAmountCur != 0 || dbTransClientChildList.Count > 1)
                    {
                        masterDbStatement._SumAmount    = SumAmount / 100d;
                        masterDbStatement._SumAmountCur = SumAmountCur / 100d;
                        statementList.Add(masterDbStatement);
                    }
                }

                if (statementList.Count > 0)
                {
                    dgGLTrans.ItemsSource = null;
                    dgGLTrans.ItemsSource = statementList;
                }
                dgGLTrans.Visibility = Visibility.Visible;
            }
            else if (transApi.LastError != 0)
            {
                Uniconta.ClientTools.Util.UtilDisplay.ShowErrorCode(transApi.LastError);
            }
            busyIndicator.IsBusy = false;
            if (_master != null)
            {
                SetExpandAndCollapse(false);
            }
        }
示例#3
0
        private async Task LoadGlTran(bool maintainIndex = false)
        {
            List <int> dim1 = null, dim2 = null, dim3 = null, dim4 = null, dim5 = null;

            var NumberOfDimensions = api.CompanyEntity.NumberOfDimensions;

            if (NumberOfDimensions >= 1)
            {
                dim1 = GetRowIDs(cbdim1);
            }
            if (NumberOfDimensions >= 2)
            {
                dim2 = GetRowIDs(cbdim2);
            }
            if (NumberOfDimensions >= 3)
            {
                dim3 = GetRowIDs(cbdim3);
            }
            if (NumberOfDimensions >= 4)
            {
                dim4 = GetRowIDs(cbdim4);
            }
            if (NumberOfDimensions >= 5)
            {
                dim5 = GetRowIDs(cbdim5);
            }

            var isAscending = cbxAscending.IsChecked.Value;

            api.session.Preference.TransactionReport_isAscending = isAscending;

            var showDimOnPrimo = cmbShowDimOnPrimo.SelectedIndex;

            setShowDimOnPrimoIndex = showDimOnPrimo;

            setDateTime(txtDateFrm, txtDateTo);
            busyIndicator.IsBusy = true;

            string journal         = cmbJournal.Text;
            var    dimensionParams = BalanceReport.SetDimensionParameters(dim1, dim2, dim3, dim4, dim5, true, true, true, true, true);
            var    listtran        = (GLTransClientTotal[])await tranApi.GetTransactions(new GLTransClientTotal(), journal, masterClient._Account, masterClient._Account, DefaultFromDate, DefaultToDate, dimensionParams, showDimOnPrimo);

            if (listtran != null)
            {
                long Total = 0, TotalCur = 0;
                byte currentCur = (byte)masterClient._Currency;

                int l = listtran.Length;
                for (int i = 0; (i < l); i++)
                {
                    var t = listtran[i];
                    Total   += t._AmountCent;
                    t._Total = Total;

                    if (t._AmountCurCent != 0 && t._Currency == currentCur)
                    {
                        TotalCur   += t._AmountCurCent;
                        t._TotalCur = TotalCur;
                    }
                }

                if (!isAscending)
                {
                    Array.Reverse(listtran);
                }

                dgGLTran.SetSource(listtran, maintainIndex);
            }
            else if (tranApi.LastError != 0)
            {
                busyIndicator.IsBusy = false;
                Uniconta.ClientTools.Util.UtilDisplay.ShowErrorCode(tranApi.LastError);
            }
        }