Exemple #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (txtVenta.Text.Trim() != "")
     {
         if (double.TryParse(txtVenta.Text.Trim(), out double venta))
         {
             double precio, cantidad, resul;
             precio   = double.Parse(txtPrecio.Text.Trim());
             cantidad = double.Parse(txtCantidad.Text.Trim());
             if (cantidad - venta >= 0)
             {
                 resul = venta * precio;
                 if (MessageBox.Show("Total a vender" + resul, "Informacion venta", MessageBoxButtons.OKCancel) == DialogResult.OK)
                 {
                     p1.Cantidad = (int)(cantidad - venta);
                     AccesoBd.EditarProductos(p1);
                     Refrescar();
                 }
             }
             else
             {
                 MessageBox.Show("Cantidad insuficiente");
             }
         }
     }
 }
Exemple #2
0
 private void btnAcepar_Click(object sender, EventArgs e)
 {
     if (Validaciones())
     {
         Productos p1 = new Productos();
         p1.Producto = txtNombre.Text.Trim();
         p1.Cantidad = int.Parse(txtCantidad.Text.Trim());
         p1.Precio   = double.Parse(txtPrecio.Text.Trim());
         if (id == null)
         {
             AccesoBd.AgregarProductos(p1);
         }
         else
         {
             p1.Id = (int)this.id;
             AccesoBd.EditarProductos(p1);
         }
         this.Close();
     }
 }