예제 #1
0
        // Code to execute when the application is launching (eg, from Start)
        // This code will not execute when the application is reactivated
        private void Application_Launching(object sender, LaunchingEventArgs e)
        {
            BoyacaDataContext contexto = new BoyacaDataContext("isostore:/boyaca.mdb");
            if (!contexto.DatabaseExists())
            {
                contexto.CreateDatabase();
            }

        }
예제 #2
0
        private void btnGuardar_Click(object sender, RoutedEventArgs e)
        {
            //Insertar
            BoyacaDataContext contexto = new BoyacaDataContext("isostore:/boyaca.mdb");

            Items nuevo = new Items();
            nuevo.Nombre = txtDescripcion.Text;
            nuevo.Precio = Convert.ToInt32(this.txtPrecio.Text);

            contexto.Items.InsertOnSubmit(nuevo);
            contexto.SubmitChanges();

            //Consultar todos

            List<Items> todos = (from i in contexto.Items
                                select i).ToList();

            //Consultar uno y actualizar
            Items uno = (from i in contexto.Items
                         where i.Id == 1
                         select i).SingleOrDefault();

            uno.Nombre = this.txtDescripcion.Text;
            uno.Precio = Convert.ToInt32(this.txtPrecio.Text);

            contexto.SubmitChanges();

            //Borrar
            Items otro = (from i in contexto.Items
                         where i.Id == 1
                         select i).SingleOrDefault();

            contexto.Items.DeleteOnSubmit(otro);
            contexto.SubmitChanges();





        }