Beispiel #1
0
        private void AgregarVenta()
        {
            string folder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData);
            string rutaDb = System.IO.Path.Combine(folder, "MiNegocio1.db");
            // DisplayAlert("Ruta de la base de datos", rutaDb, "ok");
            // Crea la base de datos si no existe, y crea una conexión
            var db = new SQLiteConnection(rutaDb);

            // Crea la tabla si no existe

            db.CreateTable <modelos.Venta>();

            string pagado;

            if (recordar.IsToggled)
            {
                pagado = "Si";
            }
            else
            {
                pagado = "No";
            }

            var registro = new modelos.Venta
            {
                Fecha    = fecha,
                Cliente  = c.Id,
                Producto = p.Id,
                Pagado   = pagado,
            };

            db.Insert(registro);
            DisplayAlert("Agregar", "El registro fue agregado con exito!", "ok");
        }
Beispiel #2
0
        private async void ActualizarRegistro(object sender, EventArgs e)
        {
            string folder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData);
            string rutaDb = System.IO.Path.Combine(folder, "MiNegocio1.db");
            var    db     = new SQLiteConnection(rutaDb);

            string pago;

            if (recordar.IsToggled)
            {
                pago = "si";
            }
            else
            {
                pago = "no";
            }

            var registro = new modelos.Venta
            {
                Id       = id,
                Fecha    = Fecha.Text,
                Cliente  = c.Id,
                Producto = p.Id,
                Pagado   = pago,
            };

            db.Table <modelos.Venta>();
            db.Update(registro);
            await DisplayAlert("", "Venta actualizado", "Aceptar");

            await Navigation.PopAsync();
        }