private async void saveRecordatorio(object sender, RoutedEventArgs e)
        {
            if (validarDatos() == 1) //si los datos son validados
            {
                Factura factura = new Factura();

                factura = getInfoFactura(); //obtengo la infomacion de los controles y retonrno el objeto factura

                factDao.insertFactura(factura); //inserto en la base de datos el nuevo objeto

                var facturas = App.Current.Resources["facturas"] as Facturas; //obtengo la referencia de la coleccion de datos
                facturas.Data.Add(factura);  //actualizo la coleccion con el objeto que fue insertado en la base de datos

                //redirigo a MainPage con bandera 0 para mensaje de insertado con exito
                rootFrame.Navigate(typeof(MainPage), "0");
            }
            if (validarDatos() == 2) //problemas con la fecha 
            {
                var dialog = new Windows.UI.Popups.MessageDialog("No te podemos notificar " + (txtDia.SelectedIndex + 1) + " días antes, el día límite es el " + txtVence.Text, "Algo sucede!");
                dialog.Commands.Add(new Windows.UI.Popups.UICommand("Entendido") { Id = 1 });
                var result = await dialog.ShowAsync();
            }
            if (validarDatos() == 0)
            {
                var dialog = new Windows.UI.Popups.MessageDialog("Falta información para crear el recordatorio", "Falta Información!");
                dialog.Commands.Add(new Windows.UI.Popups.UICommand("Entendido") { Id = 1 });
                var result = await dialog.ShowAsync();
            }
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            fact = e.Parameter as Factura;

            //asigno los valores del objeto almacenado a los controles correspondientes para editarlos
            txtNombre.Text = fact.Nombre;
            txtVence.Text = fact.Vence.Day.ToString();
            txtDia.SelectedIndex = (Convert.ToInt32(fact.Vence.Day.ToString()) - Convert.ToInt32(fact.Alarma.Day.ToString())) - 1;
            txtHora.Time = fact.Alarma.TimeOfDay;
            txtValor.Text = fact.Valor.ToString();
        }
Esempio n. 3
0
 public void insertFactura(Factura factura)
 {
     string sql = "INSERT INTO factura (nombre, vence, alarma, valor, estado) VALUES(?,?,?,?,?)";
     using (var statement = con.Prepare(sql))
     {
         statement.Bind(1, factura.Nombre);
         statement.Bind(2, string.Format("{0:yyyy-MM-dd hh:mm:ss}", Convert.ToDateTime(factura.Vence)));
         statement.Bind(3, string.Format("{0:yyyy-MM-dd hh:mm:ss}", Convert.ToDateTime(factura.Alarma)));
         statement.Bind(4, factura.Valor);
         statement.Bind(5, factura.Estado);
         statement.Step();
     }
 }
        public Factura getInfoFactura()
        {
            Factura fact = new Factura();

            fact.Nombre = getNombreEmpresa();
            fact.Vence = getFechaVence();
            fact.Alarma = getFechaAlarma();
            fact.Estado = "Pendiente";
            fact.Valor = Convert.ToInt32(txtValor.Text);

            return fact;
        }
Esempio n. 5
0
 public void updateFactura(Factura factura)
 {
     string sql = "UPDATE factura SET nombre=?, vence=?, alarma=?, valor=? ,estado=? WHERE id=?";
     using (var statement = con.Prepare(sql))
     {
         statement.Bind(1, factura.Nombre);
         statement.Bind(2, string.Format("{0:yyyy-MM-dd hh:mm:ss}", Convert.ToDateTime(factura.Vence)));
         statement.Bind(3, string.Format("{0:yyyy-MM-dd hh:mm:ss}", Convert.ToDateTime(factura.Alarma)));
         statement.Bind(4, factura.Valor);
         statement.Bind(5, factura.Estado);
         statement.Bind(6, factura.Id);
         statement.Step();
     }
 }
Esempio n. 6
0
        private Factura getFacturaWithStatement(ISQLiteStatement statement)
        {
            Factura factura = new Factura();
            factura.Id = (long)statement[0];
            factura.Nombre = (string)statement[1];

            factura.Vence = FormatDateTime(statement[2]);

            factura.Alarma = FormatDateTime(statement[3]);

            factura.Valor = (long)statement[4];
            factura.Estado = (string)statement[5];
            return factura;
        }