Example #1
0
        public async void LoadOpeningClosing()
        {
            var dateDocument = _appContextService.CurrentFinancialYear;

            var getAcc = await _openingClosingsService.GetAccDocumentItemsAsync(dateDocument);

            GetAcc  = getAcc.Count;
            Opening = await _openingClosingsService.GetCloseAccAsync(dateDocument);

            var newOpening = await _openingClosingsService.GetOpenAccAsync(dateDocument + 1);

            Closing = await _openingClosingsService.GetCloseProfitLossAccountAsync(dateDocument);

            if (GetAcc > 0 && Closing == true && Opening == false)
            {
                CheckType  = "اختتامیه";
                Enable     = true;
                TypeHeader = 4;
            }

            else if (GetAcc > 0 && Opening == true && newOpening == false)
            {
                CheckType  = "افتتاحیه";
                Enable     = true;
                TypeHeader = 3;
            }

            else if (GetAcc > 0 && Opening == true && newOpening == true)
            {
                CheckType = "سند افتتاحیه و اختتامیه صادر شده است";
                Enable    = false;
            }
            else if (GetAcc > 0 && Closing == false)
            {
                CheckType = "سندهای سود و زیانی بسته نشده است";
                Enable    = false;
            }
            else if (GetAcc == 0)
            {
                CheckType = "هیچ سندی صادر نشده است.";
                Enable    = false;
            }

            _appContextService.PropertyChanged += async(sender, eventArgs) =>
            {
                var appContextService = sender as IAppContextService;
                if (eventArgs.PropertyName == "CurrentFinancialYear")
                {
                    dateDocument = _appContextService.CurrentFinancialYear;
                }

                getAcc     = _openingClosingsService.GetAccDocumentItemsAsync(dateDocument).Result;
                GetAcc     = getAcc.Count;
                Opening    = _openingClosingsService.GetCloseAccAsync(dateDocument).Result;
                newOpening = _openingClosingsService.GetOpenAccAsync(dateDocument + 1).GetAwaiter().GetResult();
                Closing    = _openingClosingsService.GetCloseProfitLossAccountAsync(dateDocument).Result;
                if (GetAcc > 0 && Closing == true && Opening == false)
                {
                    CheckType = "اختتامیه";
                    Enable    = true;
                }

                else if (GetAcc > 0 && Opening == true && newOpening == false)
                {
                    CheckType = "افتتاحیه";
                    Enable    = true;
                }

                else if (GetAcc > 0 && Opening == true && newOpening == true)
                {
                    CheckType = "سند افتتاحیه و اختتامیه صادر شده است";
                    Enable    = false;
                }
                else if (GetAcc > 0 && Closing == false)
                {
                    CheckType = "سندهای سود و زیانی بسته نشده است";
                    Enable    = false;
                }
                else if (GetAcc == 0)
                {
                    CheckType = "هیچ سندی صادر نشده است.";
                    Enable    = false;
                }
            };
        }