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 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 List <DetallesVenta> leerPordescripcion(string descripcion) // buscar { List <DetallesVenta> listaBuscar = new List <DetallesVenta>(); MySqlCommand comando = new MySqlCommand(String.Format("call DbuscarDescrip('{0}')", descripcion), ConectorMySQL.Conectar()); try { MySqlDataReader leer1 = comando.ExecuteReader(); while (leer1.Read()) { DetallesVenta d = new DetallesVenta(); d.ID_Detalle = leer1.GetInt32(0); d.Cantidad = leer1.GetInt32(1); d.Descripcion = leer1.GetString(2); d.Precio = leer1.GetDouble(3); d.Importe = leer1.GetDouble(4); listaBuscar.Add(d); } return(listaBuscar); } catch (Exception) { throw; } 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 List <UsuarioGeneral> leerPordescripcion(string nombre) // buscar { List <UsuarioGeneral> listaBuscar = new List <UsuarioGeneral>(); MySqlCommand comando = new MySqlCommand(String.Format("call UBuscarNombre('{0}')", nombre), ConectorMySQL.Conectar()); try { MySqlDataReader leer = comando.ExecuteReader(); while (leer.Read()) { UsuarioGeneral p = new UsuarioGeneral(); p.ID = leer.GetInt32(0); p.Nombre = leer.GetString(1); p.Contraseña = leer.GetString(2); p.Tipo = leer.GetString(3); listaBuscar.Add(p); } return(listaBuscar); } catch (Exception) { throw; } finally { ConectorMySQL.Desconectar(); } }
public static Administrador IniciarSesionAdmin(string nombre, string contra) { MySqlCommand comando = new MySqlCommand(String.Format("CALL InicioSesion('{0}', '{1}')", nombre, contra), ConectorMySQL.Conectar()); try { MySqlDataReader leer = comando.ExecuteReader(); Administrador a = new Administrador(); while (leer.Read()) { a.ID = leer.GetInt32(0); a.Nombre = leer.GetString(1); a.Contraseña = leer.GetString(2); a.Tipo = leer.GetString(3); } return(a); } 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 List <Producto> leerTodo() // mostrar { List <Producto> lista = new List <Producto>(); MySqlCommand comando = new MySqlCommand(String.Format("call VerCompras()"), ConectorMySQL.Conectar()); try { MySqlDataReader leer = comando.ExecuteReader(); while (leer.Read()) { Producto p = new Producto(); p.ID = leer.GetInt32(0); p.Stock = leer.GetInt32(1); p.Descripcion = leer.GetString(2); p.Precio = leer.GetDouble(3); lista.Add(p); } return(lista); } 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 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 List <Venta> leerTodo() // mostrar { List <Venta> lista = new List <Venta>(); MySqlCommand comando = new MySqlCommand(String.Format("call VerVenta ()"), ConectorMySQL.Conectar()); try { MySqlDataReader leer = comando.ExecuteReader(); while (leer.Read()) { Venta p = new Venta(); 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); lista.Add(p); } return(lista); } catch (Exception) { throw; } finally { ConectorMySQL.Desconectar(); } }
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); }
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 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 DetallesVenta leerDetalleVentaUna(int id) // buscar { DetallesVenta p = new DetallesVenta(); MySqlCommand comando = new MySqlCommand(String.Format("call DbuscarId('{0}')", id), ConectorMySQL.Conectar()); try { MySqlDataReader leer1 = comando.ExecuteReader(); while (leer1.Read()) { p.ID_Detalle = leer1.GetInt32(0); p.Cantidad = leer1.GetInt32(1); p.Descripcion = leer1.GetString(2); p.Precio = leer1.GetDouble(3); p.Importe = leer1.GetDouble(4); p.ID_Producto = leer1.GetInt32(5); p.ID_Venta = leer1.GetInt32(6); } return(p); } 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 List <DetallesVenta> leerTodo() // mostrar { List <DetallesVenta> lista = new List <DetallesVenta>(); MySqlCommand comando = new MySqlCommand(String.Format("call verDetalleVenta()"), ConectorMySQL.Conectar()); try { MySqlDataReader leer = comando.ExecuteReader(); while (leer.Read()) { DetallesVenta d = new DetallesVenta(); d.ID_Detalle = leer.GetInt32(0); d.Cantidad = leer.GetInt32(1); d.Descripcion = leer.GetString(2); d.Precio = leer.GetDouble(3); d.Importe = leer.GetDouble(4); d.ID_Venta = leer.GetInt32(5); lista.Add(d); } return(lista); } catch (Exception) { throw; } finally { ConectorMySQL.Desconectar(); } }
public static Producto obtenerproducto(int id) { Producto p = new Producto(); MySqlCommand comando = new MySqlCommand(String.Format("call Cbuscarid( '{0}')", id), ConectorMySQL.Conectar()); try { MySqlDataReader read = comando.ExecuteReader(); while (read.Read()) { p.ID = read.GetInt32(0); p.Stock = read.GetInt32(1); p.Descripcion = read.GetString(2); p.Precio = read.GetDouble(3); } return(p); } catch (Exception) { throw; } 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 List <Producto> leerPordescripcion(string descripcion) // buscar { List <Producto> listaBuscar = new List <Producto>(); MySqlCommand comando = new MySqlCommand(String.Format("call CbuscarDescrip('{0}')", descripcion), ConectorMySQL.Conectar()); try { MySqlDataReader leer1 = comando.ExecuteReader(); while (leer1.Read()) { Producto p = new Producto(); p.ID = leer1.GetInt32(0); p.Stock = leer1.GetInt32(1); p.Descripcion = leer1.GetString(2); p.Precio = leer1.GetDouble(3); listaBuscar.Add(p); } return(listaBuscar); } catch (Exception) { throw; } finally { ConectorMySQL.Desconectar(); } }
public static UsuarioGeneral obtenerproducto(int id) { UsuarioGeneral s = new UsuarioGeneral(); MySqlCommand comando = new MySqlCommand(String.Format("call UBuscarId('{0}')", id), ConectorMySQL.Conectar()); try { MySqlDataReader leer = comando.ExecuteReader(); while (leer.Read()) { s.ID = leer.GetInt32(0); s.Nombre = leer.GetString(1); s.Contraseña = leer.GetString(2); s.Tipo = leer.GetString(3); } return(s); } 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 List <UsuarioGeneral> leerTodo() // mostrar { List <UsuarioGeneral> lista = new List <UsuarioGeneral>(); MySqlCommand comando = new MySqlCommand(String.Format("CALL verUsuarios()"), ConectorMySQL.Conectar()); try { MySqlDataReader leer = comando.ExecuteReader(); while (leer.Read()) { UsuarioGeneral p = new UsuarioGeneral(); p.ID = leer.GetInt32(0); p.Nombre = leer.GetString(1); p.Contraseña = leer.GetString(2); p.Tipo = leer.GetString(3); lista.Add(p); } return(lista); } 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 UsuarioGeneral IniciarSesionGeneral(string nombre, string contra) { MySqlCommand comando = new MySqlCommand(String.Format("CALL InicioSesion('{0}','{1}')", nombre, contra), ConectorMySQL.Conectar()); try { MySqlDataReader leer = comando.ExecuteReader(); UsuarioGeneral p = new UsuarioGeneral(); while (leer.Read()) { p.ID = leer.GetInt32(0); p.Nombre = leer.GetString(1); p.Contraseña = leer.GetString(2); p.Tipo = leer.GetString(3); } return(p); } 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(); } }