Exemplo n.º 1
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            string producto  = txtProducto.Text;
            int    precio    = Convert.ToInt16(txtPrecio.Text);
            int    cantidad  = Convert.ToInt16(txtCantida.Text);
            string proveedor = txtProveedor.Text;

            if (id == null)
            {
                Form1 f1 = new Form1();
                using (DanielaEntities1 db = new DanielaEntities1())
                {
                    db.PA_Insertar(producto, Convert.ToInt16(precio), Convert.ToInt16(cantidad), proveedor);
                }
                f1.Show();
                Close();
            }
            else
            {
                Form1 f1 = new Form1();
                using (DanielaEntities1 db = new DanielaEntities1())
                {
                    db.PA_Actualizar(Convert.ToInt16(id), producto, precio, cantidad, proveedor);
                }
                f1.Show();
                Close();
            }
        }
Exemplo n.º 2
0
 public void CargarDatos()
 {
     using (DanielaEntities1 db = new DanielaEntities1())
     {
         int Id2 = Convert.ToInt16(id);
         Producto          = db.tbProductos.Find(Id2);
         txtProducto.Text  = Producto.Producto;
         txtPrecio.Text    = Producto.Precio.ToString();
         txtCantida.Text   = Producto.Cantidad.ToString();
         txtProveedor.Text = Producto.Proveedor;
     }
 }
Exemplo n.º 3
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            string id = GetID();

            if (id != null)
            {
                int id2 = Convert.ToInt16(id);
                using (DanielaEntities1 db = new DanielaEntities1())
                {
                    db.PA_Eliminar(id2);
                    Form1 f1 = new Form1();

                    f1.Show();
                    this.Hide();
                }
            }
        }