public static Venta leerPoFecha(string fecha) // buscar { Venta venta = new Venta(); MySqlCommand comando = new MySqlCommand(String.Format("call buscarVentaFecha('{0}')", fecha), ConectorMySQL.Conectar()); try { MySqlDataReader leer = comando.ExecuteReader(); while (leer.Read()) { venta.ID = leer.GetInt32(0); venta.Subtotal = leer.GetDouble(1); venta.IVA = leer.GetDouble(2); venta.Total = leer.GetDouble(3); venta.Fecha = leer.GetDateTime(4); } return(venta); } catch (Exception) { throw; } finally { ConectorMySQL.Desconectar(); } }
public static Venta leerPorIDUna(int id) // buscar { Venta p = new Venta(); MySqlCommand comando = new MySqlCommand(String.Format("call buscarVentaId('{0}')", id), ConectorMySQL.Conectar()); try { MySqlDataReader leer = comando.ExecuteReader(); while (leer.Read()) { p.ID = leer.GetInt32(0); p.Subtotal = leer.GetDouble(1); p.IVA = leer.GetDouble(2); p.Total = leer.GetDouble(3); p.Fecha = leer.GetDateTime(4); } return(p); } catch (Exception) { throw; } finally { ConectorMySQL.Desconectar(); } }
public static int eliminar(int id) { MySqlCommand comando = new MySqlCommand(String.Format("CALL eliminaruser ('{0}')", id), ConectorMySQL.Conectar()); try { int eliminado = comando.ExecuteNonQuery(); return(eliminado); } catch (Exception) { throw; } finally { ConectorMySQL.Desconectar(); } }
public static int eliminarDetalleVenta(int id) { MySqlCommand comando = new MySqlCommand(String.Format("call EliminarDVenta( '{0}')", id), ConectorMySQL.Conectar()); try { int eliminado = comando.ExecuteNonQuery(); return(eliminado); } catch (Exception) { return(id); } finally { ConectorMySQL.Desconectar(); } }
public static int Actualizarusuario(int id, string nombre, string comtraseña) { MySqlCommand comando = new MySqlCommand(String.Format("call ActualizarUser ('{0}','{1}','{2}')", nombre, comtraseña, id), ConectorMySQL.Conectar()); try { int actualizar = comando.ExecuteNonQuery(); return(actualizar); } catch (Exception) { return(id); } finally { ConectorMySQL.Desconectar(); } }
public static void CrearDetalleTemporal(int id_prod, int cantidad, double importe, string descripcion, double precio) { MySqlCommand comando = new MySqlCommand(String.Format("call generar_detalles_tmp('{0}','{1}','{2}','{3}','{4}')", id_prod, cantidad, importe, descripcion, precio), ConectorMySQL.Conectar()); try { comando.ExecuteNonQuery(); } catch (Exception) { throw; } finally { ConectorMySQL.Desconectar(); } }
public static int ActualizarStock(int id, string descripcion, int stock, double precio) { MySqlCommand comando = new MySqlCommand(String.Format(" call ActualizarProduc('{0}','{1}','{2}','{3}')", descripcion, stock, precio, id), ConectorMySQL.Conectar()); try { int actualizar = comando.ExecuteNonQuery(); return(actualizar); } catch (Exception) { return(id); } finally { ConectorMySQL.Desconectar(); } }
public static int ActualizarStock(int id, int stock) { MySqlCommand comando = new MySqlCommand(String.Format("call actualizarStock('{0}','{1}')", stock, id), ConectorMySQL.Conectar()); try { int actualizar = comando.ExecuteNonQuery(); return(actualizar); } catch (Exception) { return(id); } finally { ConectorMySQL.Desconectar(); } }
public static int crear(UsuarioGeneral add) // agregar { int retorno = 0; MySqlCommand comando = new MySqlCommand(String.Format("CALL nuevoUsuario('{0}','{1}')", add.Nombre, add.Contraseña), ConectorMySQL.Conectar()); try { retorno = comando.ExecuteNonQuery(); return(retorno); } catch (Exception) { throw; } finally { ConectorMySQL.Desconectar(); } }
public static int crear(Producto add) // agregar { int retorno = 0; MySqlCommand comando = new MySqlCommand(String.Format("call NuevaCompra('{0}','{1}','{2}')", add.Stock, add.Descripcion, add.Precio), ConectorMySQL.Conectar()); try { retorno = comando.ExecuteNonQuery(); return(retorno); } catch (Exception) { throw; } finally { ConectorMySQL.Desconectar(); } }
public static int crear(Venta add) // agregar { int retorno = 0; MySqlCommand comando = new MySqlCommand(String.Format("call CrearVenta('{0}','{1}','{2}','{3}')", add.Subtotal, add.IVA, add.Total, add.Efecha), ConectorMySQL.Conectar()); try { retorno = comando.ExecuteNonQuery(); return(retorno); } catch (Exception) { throw; } finally { ConectorMySQL.Desconectar(); } }
public static void ActualizarStockDetalle(int id, int stock, double precio) { double importe = 0; importe = stock * precio; MySqlCommand comando = new MySqlCommand(String.Format("call ActuDetallStock('{0}','{1}','{2}')", stock, importe, id), ConectorMySQL.Conectar()); try { comando.ExecuteNonQuery(); } catch (Exception) { throw; } finally { ConectorMySQL.Desconectar(); } }
public static int ActualizarVenta(DetallesVenta detalle, Producto producto, int cantidad) { int retorno = 0; MySqlCommand comando = new MySqlCommand(String.Format(" call ActualizarVenta('{0}','{1}','{2}')", detalle.ID_Venta, producto.Precio, cantidad), ConectorMySQL.Conectar()); try { comando.ExecuteNonQuery(); } catch (Exception) { MessageBox.Show("Error, venta no actualizada"); } finally { ConectorMySQL.Desconectar(); } return(retorno); }
public static bool VentaEnCeros(int id) { bool retorno = false; Venta p = new Venta(); MySqlCommand comando = new MySqlCommand(String.Format(" call VBuscarId('{0}')", id), ConectorMySQL.Conectar()); try { MySqlDataReader leer = comando.ExecuteReader(); while (leer.Read()) { p.ID = leer.GetInt32(0); p.Subtotal = leer.GetDouble(1); p.IVA = leer.GetDouble(2); p.Total = leer.GetDouble(3); p.Fecha = leer.GetDateTime(4); } if (p.Subtotal == 0 && p.IVA == 0 && p.Total == 0) { retorno = true; return(retorno); } } catch (Exception) { throw; } finally { ConectorMySQL.Desconectar(); } return(retorno); }