void Consultargastos()
        {
            lstgasto.Clear();

            DatabaseReference outcomes = referenceBD.GetChild("Gastos");

            nuint handleReference = outcomes.ObserveEvent(DataEventType.Value, (snapshot) =>
            {
                var data = snapshot.GetValue <NSDictionary>();

                var gasto = new Gasto
                {
                    Monto       = float.Parse(data["Monto"].ToString()),
                    Descripcion = data["Descripcion"].ToString(),
                    Fecha       = DateTime.Parse(data["Fecha"].ToString())
                };

                lstgasto.Add(gasto);
                OutcomeTable.ReloadData();
            });
        }
Exemplo n.º 2
0
        public void NuevoGasto()
        {
            if (txtMonto.Text == "" || txtDescripcion.Text == "")
            {
                UIAlertView alert = new UIAlertView()
                {
                    Title   = "Error!",
                    Message = "Ingresa datos por favor!"
                };
                alert.AddButton("OK");
                alert.Show();
            }
            else
            {
                var outcome = new Gasto
                {
                    Monto       = int.Parse(txtMonto.Text),
                    Descripcion = txtDescripcion.Text,
                    Fecha       = DateTime.Now
                };

                object[] keys   = { "Monto", "Descripcion", "Fecha" };
                object[] values = { outcome.Monto, outcome.Descripcion, outcome.Fecha };

                DatabaseReference Gasto = referenceBD.GetChild("Gastos");
                var data = NSDictionary.FromObjectsAndKeys(values, keys, keys.Length);

                Gasto.SetValue(data);
                txtMonto.Text       = "";
                txtDescripcion.Text = "";
                UIAlertView alert = new UIAlertView()
                {
                    Title   = "Exito!",
                    Message = "Ingreso registrado exitosamente!"
                };
                alert.AddButton("OK");
                alert.Show();
            }
        }