public async void LoadData()
        {
            FinancesResponse financesResponse = await new Finances().getList(Filter, OrderBy, OrderType, Since, Until, MovementType, CompanyBranch, Page);

            txtIngresos.Text = financesResponse.TotalIngresosStr;
            txtGastos.Text   = financesResponse.TotalGastosStr;
            txtSaldo.Text    = financesResponse.SaldoStr;
            TotalPages       = financesResponse.TotalPages;

            if (financesResponse.financeMovements.Count > 0)
            {
                grdNoRegisters.Visibility = Visibility.Collapsed;
            }
            else
            {
                grdNoRegisters.Visibility = Visibility.Visible;
            }

            lstFinances.ItemsSource = financesResponse.financeMovements;
            grdLoader.Visibility    = Visibility.Collapsed;

            if (Page == 1)
            {
                btnFirst.IsEnabled    = false;
                btnPrevious.IsEnabled = false;
            }
            if (Page > 1)
            {
                btnFirst.IsEnabled    = true;
                btnPrevious.IsEnabled = true;
            }
            if (Page < TotalPages)
            {
                btnNext.IsEnabled = true;
                btnLast.IsEnabled = true;
            }
            if (Page == TotalPages)
            {
                btnNext.IsEnabled = false;
                btnLast.IsEnabled = false;
            }

            txtRegister.Text = financesResponse.PageString;

            lstFinances.ItemsSource = financesResponse.financeMovements;
        }
Пример #2
0
        public async Task <FinancesResponse> getList(string filtro = "", string ordenar_por = "", string orden = "", string desde = "", string hasta = "", string movement_type = "", string sucursal = "0", int Page = 1)
        {
            FinancesResponse financesResponse = new FinancesResponse();

            try
            {
                List <CloureParam> cparams = new List <CloureParam>();
                cparams.Add(new CloureParam("module", "finances"));
                cparams.Add(new CloureParam("topic", "listar"));
                if (filtro.Length > 0)
                {
                    cparams.Add(new CloureParam("filtro", filtro));
                }
                if (ordenar_por.Length > 0)
                {
                    cparams.Add(new CloureParam("ordenar_por", ordenar_por));
                }
                if (orden.Length > 0)
                {
                    cparams.Add(new CloureParam("orden", orden));
                }
                if (desde.Length > 0)
                {
                    cparams.Add(new CloureParam("desde", desde));
                }
                if (hasta.Length > 0)
                {
                    cparams.Add(new CloureParam("hasta", hasta));
                }
                if (movement_type.Length > 0)
                {
                    cparams.Add(new CloureParam("tipo_movimiento", movement_type));
                }
                if (sucursal.Length > 0)
                {
                    cparams.Add(new CloureParam("sucursal", sucursal));
                }
                cparams.Add(new CloureParam("pagina", Page.ToString()));
                string res = await CloureManager.ExecuteAsync(cparams);

                JsonObject api_result = JsonObject.Parse(res);
                string     error      = api_result.GetNamedString("Error");
                if (error == "")
                {
                    JsonObject api_response = api_result.GetNamedObject("Response");
                    JsonArray  registers    = api_response.GetNamedArray("Registros");

                    foreach (JsonValue jsonValue in registers)
                    {
                        JsonObject      register        = jsonValue.GetObject();
                        FinanceMovement financeMovement = new FinanceMovement();
                        financeMovement.FechaStr   = register.GetNamedString("FechaStr");
                        financeMovement.Detalles   = register.GetNamedString("Detalles");
                        financeMovement.ImporteStr = register.GetNamedString("ImporteStr");

                        financesResponse.financeMovements.Add(financeMovement);
                    }
                    financesResponse.TotalPages = (int)api_response.GetNamedNumber("TotalPaginas");

                    //financesResponse.TotalIngresos = api_response.GetNamedNumber("TotalIngresos");
                    //financesResponse.TotalGastos = api_response.GetNamedNumber("TotalEgresos");
                    //financesResponse.Saldo = api_response.GetNamedNumber("Saldo");

                    financesResponse.TotalIngresosStr = api_response.GetNamedString("TotalIngresosStr");
                    financesResponse.TotalGastosStr   = api_response.GetNamedString("TotalEgresosStr");
                    financesResponse.SaldoStr         = api_response.GetNamedString("SaldoStr");
                    financesResponse.PageString       = api_response.GetNamedString("PageString");
                }
                else
                {
                    throw new Exception(error);
                }
            }
            catch (Exception ex)
            {
                var dialog = new MessageDialog(ex.Message);
                await dialog.ShowAsync();
            }

            return(financesResponse);
        }