protected async override void OnAppearing()
        {
            base.OnAppearing();
            if (CrossConnectivity.Current.IsConnected)
            {
                try
                {
                    Costo_variable _costoVariable = new Costo_variable()
                    {
                        mes_cv     = _mesQuery,
                        gestion_cv = _yearQuery
                    };
                    var        json    = JsonConvert.SerializeObject(_costoVariable);
                    var        content = new StringContent(json, Encoding.UTF8, "application/json");
                    HttpClient client  = new HttpClient();
                    var        result  = await client.PostAsync("https://dmrbolivia.com/api_distribuidora/egresos/listaCostoVariableQuery.php", content);

                    var jsonR = await result.Content.ReadAsStringAsync();

                    var dataCostoVar = JsonConvert.DeserializeObject <List <Costo_variable> >(jsonR);

                    listCostoVariable.ItemsSource = dataCostoVar;
                }
                catch (Exception err)
                {
                    await DisplayAlert("Error", "Algo salio mal, intentelo de nuevo", "OK");
                }
            }
            else
            {
                await DisplayAlert("Error", "Necesitas estar conectado a internet", "OK");
            }
        }
        private async void btnBorrar_Clicked(object sender, EventArgs e)
        {
            if (CrossConnectivity.Current.IsConnected)
            {
                string BusyReason = "Eliminando...";
                await PopupNavigation.Instance.PushAsync(new BusyPopup(BusyReason));

                try
                {
                    Costo_variable _costoVariable = new Costo_variable()
                    {
                        id_cv = _IdCV
                    };

                    var        json    = JsonConvert.SerializeObject(_costoVariable);
                    var        content = new StringContent(json, Encoding.UTF8, "application/json");
                    HttpClient client  = new HttpClient();
                    var        result  = await client.PostAsync("https://dmrbolivia.com/api_distribuidora/egresos/borrarCostoVariable.php", content);

                    if (result.StatusCode == HttpStatusCode.OK)
                    {
                        await PopupNavigation.Instance.PopAsync();
                        await DisplayAlert("ELIMINADO", "Se elimino correctamente", "OK");

                        await Shell.Current.Navigation.PopAsync();
                    }
                    else
                    {
                        await PopupNavigation.Instance.PopAsync();
                        await DisplayAlert("Error", "Algo salio mal, intentelo de nuevo", "OK");

                        await Shell.Current.Navigation.PopAsync();
                    }
                }
                catch (Exception err)
                {
                    await DisplayAlert("Error", "Algo salio mal, intentelo de nuevo", "OK");
                }
            }
            else
            {
                await DisplayAlert("Error", "Necesitas estar conectado a internet", "OK");
            }
        }
        private async void btnGuardar_Clicked(object sender, EventArgs e)
        {
            if (CrossConnectivity.Current.IsConnected)
            {
                if (!string.IsNullOrWhiteSpace(entryNombre.Text) || (!string.IsNullOrEmpty(entryNombre.Text)))
                {
                    if (!string.IsNullOrWhiteSpace(entrymonto.Text) || (!string.IsNullOrEmpty(entrymonto.Text)))
                    {
                        if (_mesQuery != 0)
                        {
                            if (!string.IsNullOrWhiteSpace(entryDescripcion.Text) || (!string.IsNullOrEmpty(entryDescripcion.Text)))
                            {
                                if (!string.IsNullOrWhiteSpace(entryTipoGasto.Text) || (!string.IsNullOrEmpty(entryTipoGasto.Text)))
                                {
                                    _fechaElegida = pickerFecha.Date.ToString("yyyy-MM-dd");
                                    if (!string.IsNullOrWhiteSpace(_fechaElegida) || (!string.IsNullOrEmpty(_fechaElegida)))
                                    {
                                        string BusyReason = "Agregando...";
                                        await PopupNavigation.Instance.PushAsync(new BusyPopup(BusyReason));

                                        try
                                        {
                                            Costo_variable _costoVariable = new Costo_variable()
                                            {
                                                nombre_cv      = entryNombre.Text,
                                                monto_cv       = Convert.ToDecimal(entrymonto.Text),
                                                fecha_cv       = Convert.ToDateTime(_fechaElegida),
                                                mes_cv         = _mesQuery,
                                                gestion_cv     = _yearActual,
                                                descripcion_cv = entryDescripcion.Text,
                                                tipo_gasto_cv  = entryTipoGasto.Text
                                            };
                                            var        json    = JsonConvert.SerializeObject(_costoVariable);
                                            var        content = new StringContent(json, Encoding.UTF8, "application/json");
                                            HttpClient client  = new HttpClient();
                                            var        result  = await client.PostAsync("https://dmrbolivia.com/api_distribuidora/egresos/agregarCostoVariable.php", content);

                                            if (result.StatusCode == HttpStatusCode.OK)
                                            {
                                                await PopupNavigation.Instance.PopAsync();
                                                await DisplayAlert("GUARDADO", "Se agrego correctamente", "OK");

                                                await Shell.Current.Navigation.PopAsync();
                                            }
                                            else
                                            {
                                                await PopupNavigation.Instance.PopAsync();
                                                await DisplayAlert("ERROR", "Algo salio mal, intentelo de nuevo", "OK");

                                                await Shell.Current.Navigation.PopAsync();
                                            }
                                        }
                                        catch (Exception err)
                                        {
                                            await DisplayAlert("Error", "Algo salio mal, intentelo de nuevo", "OK");
                                        }
                                    }
                                }
                                else
                                {
                                    await DisplayAlert("Campo vacio", "El campo de Tipo de gasto esta vacio", "Ok");
                                }
                            }
                            else
                            {
                                await DisplayAlert("Campo vacio", "El campo de Descripcion esta vacio", "Ok");
                            }
                        }
                        else
                        {
                            await DisplayAlert("Campo vacio", "El campo de Mes esta vacio", "Ok");
                        }
                    }
                    else
                    {
                        await DisplayAlert("Campo vacio", "El campo de Monto esta vacio", "Ok");
                    }
                }
                else
                {
                    await DisplayAlert("Campo vacio", "El campo de Nombre esta vacio", "Ok");
                }
            }
            else
            {
                await DisplayAlert("Error", "Necesitas estar conectado a internet", "OK");
            }
        }
示例#4
0
        private async void GetIngEgre()
        {
            if (CrossConnectivity.Current.IsConnected)
            {
                await PopupNavigation.Instance.PushAsync(new BusyPopup(BusyReason));

                try
                {
                    Costo_fijo _costoFijo = new Costo_fijo()
                    {
                        mes_cf     = _mesQuery,
                        gestion_cf = _yearQuery
                    };
                    var        json    = JsonConvert.SerializeObject(_costoFijo);
                    var        content = new StringContent(json, Encoding.UTF8, "application/json");
                    HttpClient client  = new HttpClient();
                    var        result  = await client.PostAsync("https://dmrbolivia.com/api_distribuidora/egresos/listaCostoFijoQuery.php", content);

                    var jsonR = await result.Content.ReadAsStringAsync();

                    var dataCostoFijo = JsonConvert.DeserializeObject <List <Costo_fijo> >(jsonR);
                    if (dataCostoFijo != null)
                    {
                        foreach (var item in dataCostoFijo)
                        {
                            _totalC_Fijo = _totalC_Fijo + item.monto_cf;
                        }
                    }
                }
                catch (Exception err)
                {
                    await DisplayAlert("Error", "Algo salio mal, intentelo de nuevo", "OK");
                }
                await Task.Delay(150);

                try
                {
                    Costo_variable _costoVariable = new Costo_variable()
                    {
                        mes_cv     = _mesQuery,
                        gestion_cv = _yearQuery
                    };
                    var        json    = JsonConvert.SerializeObject(_costoVariable);
                    var        content = new StringContent(json, Encoding.UTF8, "application/json");
                    HttpClient client  = new HttpClient();
                    var        result  = await client.PostAsync("https://dmrbolivia.com/api_distribuidora/egresos/listaCostoVariableQuery.php", content);

                    var jsonR = await result.Content.ReadAsStringAsync();

                    var dataCostoVar = JsonConvert.DeserializeObject <List <Costo_variable> >(jsonR);
                    if (dataCostoVar != null)
                    {
                        foreach (var item in dataCostoVar)
                        {
                            _totalC_Variable = _totalC_Variable + item.monto_cv;
                        }
                    }
                }
                catch (Exception err)
                {
                    await DisplayAlert("Error", "Algo salio mal, intentelo de nuevo", "OK");
                }
                await Task.Delay(150);

                try
                {
                    TotalCompra _totCompra = new TotalCompra()
                    {
                        fecha_inicio = Convert.ToDateTime(_fecha_inicial),
                        fecha_final  = Convert.ToDateTime(_fecha_final)
                    };
                    var        json    = JsonConvert.SerializeObject(_totCompra);
                    var        content = new StringContent(json, Encoding.UTF8, "application/json");
                    HttpClient client  = new HttpClient();
                    var        result  = await client.PostAsync("https://dmrbolivia.com/api_distribuidora/compras/listaCompraTotalQuery.php", content);

                    var jsonR = await result.Content.ReadAsStringAsync();

                    var dataCompras = JsonConvert.DeserializeObject <List <TotalCompra> >(jsonR);
                    if (dataCompras != null)
                    {
                        foreach (var item in dataCompras)
                        {
                            _totalCompras = _totalCompras + item.total;
                        }
                    }
                }
                catch (Exception err)
                {
                    await DisplayAlert("Error", "Algo salio mal, intentelo de nuevo", "OK");
                }
                await Task.Delay(150);

                try
                {
                    TotalVenta _totVenta = new TotalVenta()
                    {
                        fecha_inicio = Convert.ToDateTime(_fecha_inicial),
                        fecha_final  = Convert.ToDateTime(_fecha_final)
                    };
                    var        json    = JsonConvert.SerializeObject(_totVenta);
                    var        content = new StringContent(json, Encoding.UTF8, "application/json");
                    HttpClient client  = new HttpClient();
                    var        result  = await client.PostAsync("https://dmrbolivia.com/api_distribuidora/ventas/listaVentaTotalQuery.php", content);

                    var jsonR = await result.Content.ReadAsStringAsync();

                    var dataVentas = JsonConvert.DeserializeObject <List <TotalVenta> >(jsonR);
                    if (dataVentas != null)
                    {
                        foreach (var item in dataVentas)
                        {
                            _totalVentas = _totalVentas + item.total;
                        }
                    }
                }
                catch (Exception err)
                {
                    await DisplayAlert("Error", "Algo salio mal, intentelo de nuevo", "OK");
                }
                txtTotalIngresos.Text = _totalVentas.ToString();
                txtTotalEgresos.Text  = (_totalCompras + _totalC_Fijo + _totalC_Variable).ToString();
                try
                {
                    //Grafico ingresos/egresos
                    float _C_Fijo     = (float)_totalC_Fijo;
                    float _C_Variable = (float)_totalC_Variable;
                    float _C_Compras  = (float)_totalCompras;
                    float _C_Ingresos = (float)_totalVentas;
                    txtCostosF.Text  = "Costos fijos: " + _totalC_Fijo.ToString() + " Bs.";
                    txtCostosV.Text  = "Costos variables: " + _totalC_Variable.ToString() + " Bs.";
                    txtCompras.Text  = "Compras: " + _totalCompras.ToString() + " Bs. ";
                    txtIngresos.Text = "Ingresos: " + _totalVentas.ToString() + " Bs.";
                    var entries = new[]
                    {
                        new ChartEntry(_C_Fijo)
                        {
                            Color = SKColor.Parse("#000FFF"),
                        },
                        new ChartEntry(_C_Variable)
                        {
                            Color = SKColor.Parse("#FF0000"),
                        },
                        new ChartEntry(_C_Compras)
                        {
                            Color = SKColor.Parse("#f0d400"),
                        },
                        new ChartEntry(_C_Ingresos)
                        {
                            Color = SKColor.Parse("#059B00"),
                        },
                    };
                    grafico1.Chart = new DonutChart()
                    {
                        Entries = entries, BackgroundColor = SKColor.Parse("#40616B"), GraphPosition = GraphPosition.AutoFill
                    };
                    //grafico costos
                    await Task.Delay(500);

                    try
                    {
                        txtCostosF2.Text = "Costos fijos: " + _totalC_Fijo.ToString() + " Bs.";
                        txtCostosV2.Text = "Costos variables: " + _totalC_Variable.ToString() + " Bs.";
                        var entries2 = new[]
                        {
                            new ChartEntry(_C_Fijo)
                            {
                                Color = SKColor.Parse("#000FFF"),
                            },
                            new ChartEntry(_C_Variable)
                            {
                                Color = SKColor.Parse("#FF0000"),
                            },
                        };
                        grafico2.Chart = new DonutChart()
                        {
                            Entries = entries2, BackgroundColor = SKColor.Parse("#40616B"), GraphPosition = GraphPosition.AutoFill
                        };
                    }
                    catch (Exception err)
                    {
                        await DisplayAlert("Error", err.ToString(), "OK");
                    }
                    //Tabla mes
                    await Task.Delay(300);

                    txtTablaVenta.Text  = _totalVentas.ToString();
                    txtTablaCompra.Text = "- " + _totalCompras.ToString();
                    txtTotalVC.Text     = (_totalVentas - _totalCompras).ToString();
                    txtTablaGF.Text     = _totalC_Fijo.ToString();
                    txtTablaGV.Text     = _totalC_Variable.ToString();
                    txtTotalGastos.Text = (_totalC_Fijo + _totalC_Variable).ToString();
                    txtTablaTotal.Text  = ((_totalVentas - _totalCompras) - (_totalC_Fijo + _totalC_Variable)).ToString();
                }
                catch (Exception err)
                {
                    await DisplayAlert("Error", "Algo salio mal, intentelo de nuevo", "OK");
                }
            }
            else
            {
                await DisplayAlert("Error", "Necesitas estar conectado a internet", "OK");
            }
        }
示例#5
0
        private async void GetAltura()
        {
            if (CrossConnectivity.Current.IsConnected)
            {
                try
                {
                    Costo_fijo _costoFijo = new Costo_fijo()
                    {
                        mes_cf     = _mesQuery,
                        gestion_cf = _yearQuery
                    };
                    var        json    = JsonConvert.SerializeObject(_costoFijo);
                    var        content = new StringContent(json, Encoding.UTF8, "application/json");
                    HttpClient client  = new HttpClient();
                    var        result  = await client.PostAsync("https://dmrbolivia.com/api_distribuidora/egresos/listaCostoFijoQuery.php", content);

                    var jsonR = await result.Content.ReadAsStringAsync();

                    var dataCostoFijo = JsonConvert.DeserializeObject <List <Costo_fijo> >(jsonR);

                    if (dataCostoFijo != null)
                    {
                        foreach (var item in dataCostoFijo)
                        {
                            _listaCostoFijo.Add(item);
                        }
                        _medidaStkFijo = dataCostoFijo.Count;
                        await Task.Delay(200);
                    }
                    txtTotalCF.Text = _totalCF.ToString();
                }
                catch (Exception err)
                {
                    await DisplayAlert("Error", "Algo salio mal, intentelo de nuevo", "Ok");
                }
                try
                {
                    Costo_variable _costoVariable = new Costo_variable()
                    {
                        mes_cv     = _mesQuery,
                        gestion_cv = _yearQuery
                    };
                    var        json    = JsonConvert.SerializeObject(_costoVariable);
                    var        content = new StringContent(json, Encoding.UTF8, "application/json");
                    HttpClient client  = new HttpClient();
                    var        result  = await client.PostAsync("https://dmrbolivia.com/api_distribuidora/egresos/listaCostoVariableQuery.php", content);

                    var jsonR = await result.Content.ReadAsStringAsync();

                    var dataCostoVar = JsonConvert.DeserializeObject <List <Costo_variable> >(jsonR);

                    if (dataCostoVar != null)
                    {
                        foreach (var item in dataCostoVar)
                        {
                            _listaCostoVariable.Add(item);
                        }
                        _medidaStkVariable = dataCostoVar.Count;
                        await Task.Delay(200);
                    }
                }
                catch (Exception err)
                {
                    await DisplayAlert("Error", "Algo salio mal, intentelo de nuevo", "Ok");
                }
                if (_medidaStkFijo > _medidaStkVariable)
                {
                    _medidaStkFijo      = _medidaStkFijo * 60;
                    stkCF.HeightRequest = _medidaStkFijo;
                    stkCV.HeightRequest = _medidaStkVariable;
                }
                else if (_medidaStkVariable > _medidaStkFijo)
                {
                    _medidaStkVariable  = _medidaStkVariable * 60;
                    stkCF.HeightRequest = _medidaStkFijo;
                    stkCV.HeightRequest = _medidaStkVariable;
                }
                await Task.Delay(400);
            }
            else
            {
                await DisplayAlert("Error", "Necesitas estar conectado a internet", "OK");
            }
        }
示例#6
0
        private async void GetCostoVariable()
        {
            if (CrossConnectivity.Current.IsConnected)
            {
                await Task.Delay(400);

                try
                {
                    _listaCostoVariable.Clear();
                    Costo_variable _costoVariable = new Costo_variable()
                    {
                        mes_cv     = _mesQuery,
                        gestion_cv = _yearQuery
                    };
                    var        json    = JsonConvert.SerializeObject(_costoVariable);
                    var        content = new StringContent(json, Encoding.UTF8, "application/json");
                    HttpClient client  = new HttpClient();
                    var        result  = await client.PostAsync("https://dmrbolivia.com/api_distribuidora/egresos/listaCostoVariableQuery.php", content);

                    var jsonR = await result.Content.ReadAsStringAsync();

                    var dataCostoVar = JsonConvert.DeserializeObject <List <Costo_variable> >(jsonR);

                    if (dataCostoVar != null)
                    {
                        foreach (var item in dataCostoVar)
                        {
                            StackLayout _stk1CV = new StackLayout();
                            stkCV.Children.Add(_stk1CV);

                            Label _labelNombreCV = new Label();
                            _labelNombreCV.Text      = "Nombre: " + item.nombre_cv;
                            _labelNombreCV.TextColor = Color.Black;
                            _labelNombreCV.FontSize  = 14;
                            _labelNombreCV.HorizontalTextAlignment = TextAlignment.Start;
                            _stk1CV.Children.Add(_labelNombreCV);

                            Label _labelMontoCV = new Label();
                            _labelMontoCV.Text      = "Monto: " + item.monto_cv;
                            _labelMontoCV.TextColor = Color.Black;
                            _labelMontoCV.FontSize  = 14;
                            _labelMontoCV.HorizontalTextAlignment = TextAlignment.Start;
                            _stk1CV.Children.Add(_labelMontoCV);

                            BoxView _bx1CV = new BoxView();
                            _bx1CV.HeightRequest     = 1;
                            _bx1CV.Color             = Color.FromHex("#465B70");
                            _bx1CV.HorizontalOptions = LayoutOptions.FillAndExpand;
                            _stk1CV.Children.Add(_bx1CV);

                            _totalCV = _totalCV + item.monto_cv;
                        }
                    }
                    txtTotalCV.Text = _totalCV.ToString();
                }
                catch (Exception err)
                {
                    await DisplayAlert("Error", "Algo salio mal, intentelo de nuevo", "Ok");
                }
            }
            else
            {
                await DisplayAlert("Error", "Necesitas estar conectado a internet", "OK");
            }
        }