Exemple #1
0
 public static void CambiarEstado(int id, EstadoTraspaso e, string descripcion)
 {
     try
     {
         MySqlCommand sql = new MySqlCommand();
         sql.CommandText = "UPDATE traspaso SET estado=?estado, descripcion=?descripcion WHERE id=?id";
         sql.Parameters.AddWithValue("?estado", e);
         sql.Parameters.AddWithValue("?descripcion", descripcion);
         sql.Parameters.AddWithValue("?id", id);
         ConexionBD.EjecutarConsulta(sql);
         if (e == EstadoTraspaso.Recibida)
         {
             Traspaso t = new Traspaso(id);
             t.ObtenerDatos();
             InsertarProductos(t);
         }
     }
     catch (MySqlException ex)
     {
         throw ex;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #2
0
 private static void InsertarProductos(Traspaso t)
 {
     try
     {
         for (int i = 0; i < t.idProductos.Count; i++)
         {
             //Suma los productos a la sucursal de destino
             Inventario.CambiarCantidadInventario(t.idProductos[i], t.cantProductos[i], t.idSucursalDestino);
             //Resta los productos a la sucursal de origen
             Inventario.CambiarCantidadInventario(t.idProductos[i], t.cantProductos[i] * -1, t.idSucursalOrigen);
         }
     }
     catch (MySqlException ex)
     {
         throw ex;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }