public static void Truncar() { int retorno = 0; MySqlConnection conexion = BDConexion.ObtenerConexion(); MySqlCommand comando = new MySqlCommand(string.Format("TRUNCATE detalle"), conexion); retorno = comando.ExecuteNonQuery(); MySqlCommand comando2 = new MySqlCommand(string.Format("TRUNCATE factura"), conexion); retorno = comando2.ExecuteNonQuery(); MySqlCommand comando3 = new MySqlCommand(string.Format("TRUNCATE productos"), conexion); retorno = comando3.ExecuteNonQuery(); MySqlCommand comando4 = new MySqlCommand(string.Format("TRUNCATE cliente"), conexion); retorno = comando4.ExecuteNonQuery(); MySqlCommand comando5 = new MySqlCommand(string.Format("TRUNCATE responsable"), conexion); retorno = comando5.ExecuteNonQuery(); MySqlCommand comando6 = new MySqlCommand(string.Format("INSERT INTO `responsable` (`idResponsable`, `Nombre`, `Alias`, `Password`, `Puesto`, `FechaIngreso`, `HoraIngreso`) VALUES (NULL, 'Administrador', 'admin', MD5('admin'), 'Gerente', CURRENT_DATE(), CURRENT_TIME())"), conexion); retorno = comando6.ExecuteNonQuery(); // INSERT INTO `responsable` (`idResponsable`, `Nombre`, `Alias`, `Password`, `Puesto`, `FechaIngreso`, `HoraIngreso`) VALUES (NULL, 'Administrador', 'admin', MD5('admin'), 'Gerente', CURRENT_DATE(), CURRENT_TIME()) conexion.Close(); }
private void VerBDProductos_Load(object sender, EventArgs e) { MySqlConnection _conexion = BDConexion.ObtenerConexion(); MySqlDataAdapter mdaDatos = new MySqlDataAdapter(string.Format("SELECT `idProducto`, `Nombre`, `Talla`, `Precio`, `Stock` FROM `productos`"), _conexion); // Aqui use un codigo de que previamene cree una vista mdaDatos.Fill(dtDatos); dataGridReporte.DataSource = dtDatos; _conexion.Close(); }
private void Reporte_Load(object sender, EventArgs e) { MySqlConnection _conexion = BDConexion.ObtenerConexion(); // DataTable dtDatos = new DataTable(); MySqlDataAdapter mdaDatos = new MySqlDataAdapter(string.Format("SELECT * FROM `vistaprod`"), _conexion); // Aqui use un codigo de que previamene cree una vista mdaDatos.Fill(dtDatos); dataGridReporte.DataSource = dtDatos; _conexion.Close(); }
public void llenarcorreocliente() { MySqlConnection _conexion = BDConexion.ObtenerConexion(); DataSet ds = new DataSet(); MySqlDataAdapter da = new MySqlDataAdapter("SELECT `email` FROM `cliente`", _conexion); da.Fill(ds, "cliente"); cmbCorreoCliente.DataSource = ds.Tables[0].DefaultView; cmbCorreoCliente.ValueMember = "email"; _conexion.Close(); }
public void llenarcorreo() { MySqlConnection _conexion = BDConexion.ObtenerConexion(); DataSet ds = new DataSet(); MySqlDataAdapter da = new MySqlDataAdapter("SELECT `CORREO` FROM `responsable`", _conexion); da.Fill(ds, "responsable"); cmbCorreo.DataSource = ds.Tables[0].DefaultView; cmbCorreo.ValueMember = "CORREO"; _conexion.Close(); }
public void llenarproductos() { MySqlConnection _conexion = BDConexion.ObtenerConexion(); DataSet ds = new DataSet(); MySqlDataAdapter da = new MySqlDataAdapter("SELECT `idProducto` FROM `productos`", _conexion); da.Fill(ds, "productos"); comboBoxProducto.DataSource = ds.Tables[0].DefaultView; comboBoxProducto.ValueMember = "idProducto"; _conexion.Close(); }
public static int Eliminar(string pidResponsable) { int retorno = 0; MySqlConnection conexion = BDConexion.ObtenerConexion(); MySqlCommand comando = new MySqlCommand(string.Format("DELETE FROM `responsable` WHERE `responsable`.`idResponsable` = {0}", pidResponsable), conexion); retorno = comando.ExecuteNonQuery(); conexion.Close(); return(retorno); }
public static int Actualizar(Cliente pCliente) { int retorno = 0; MySqlConnection conexion = BDConexion.ObtenerConexion(); MySqlCommand comando = new MySqlCommand(string.Format("UPDATE `cliente` SET `Nombre`='{0}',`Apellidos`='{1}',`Direccion`='{2}',`Telefono`='{3}',`email`='{4}' WHERE `cliente`.`idCliente` = {5}", pCliente.Nombre, pCliente.Apellidos, pCliente.Direccion, pCliente.Telefono, pCliente.idCliente), conexion); retorno = comando.ExecuteNonQuery(); conexion.Close(); return(retorno); }
public static int Truncar() { int retorno = 0; MySqlConnection conexion = BDConexion.ObtenerConexion(); MySqlCommand comando = new MySqlCommand(string.Format("TRUNCATE productos"), conexion); retorno = comando.ExecuteNonQuery(); conexion.Close(); return(retorno); }
public static int Actualhora(string pAlias, string pPass) { int retorno = 0; MySqlConnection conexion = BDConexion.ObtenerConexion(); MySqlCommand comando = new MySqlCommand(string.Format("UPDATE `responsable` SET `FechaIngreso`=CURRENT_DATE(), `HoraIngreso`= CURRENT_TIME() WHERE `Alias` = '" + pAlias + "' AND `Password` = MD5('" + pPass + "')"), conexion); retorno = comando.ExecuteNonQuery(); conexion.Close(); return(retorno); }
public static int Eliminar(string pidProductos) { int retorno = 0; MySqlConnection conexion = BDConexion.ObtenerConexion(); // DELETE FROM `productos` WHERE `productos`.`idProducto` = 4 MySqlCommand comando = new MySqlCommand(string.Format("DELETE FROM `productos` WHERE `productos`.`idProducto` = {0}", pidProductos), conexion); retorno = comando.ExecuteNonQuery(); conexion.Close(); return(retorno); }
public static int Actualizar(BaseRegistro pProducto) { int retorno = 0; MySqlConnection conexion = BDConexion.ObtenerConexion(); MySqlCommand comando = new MySqlCommand(string.Format("UPDATE registro SET IdProducto='{0}', Piezas='{1}', CostoUnit='{2}', Nombre='{3}', Talla='{4}' WHERE IdRegistro={5}", pProducto.IdProducto, pProducto.Piezas, pProducto.CostoUnit, pProducto.Nombre, pProducto.Talla, pProducto.IdRemision), conexion); retorno = comando.ExecuteNonQuery(); conexion.Close(); return(retorno); }
/// <summary> /// /// </summary> /// <param name="pAlias"></param> /// <param name="pPass"></param> /// <returns></returns> public static DataTable Buscar(string pAlias, string pPass) { DataTable dt = new DataTable(); MySqlConnection conexion = BDConexion.ObtenerConexion(); string consulta = "SELECT * FROM responsable WHERE Alias=?username AND Password=?password"; // + "' AND `Password` = MD5('" + pPass + "')"; MySqlCommand comando = new MySqlCommand(String.Format(consulta), conexion); comando.Parameters.AddWithValue("?username", pAlias); comando.Parameters.AddWithValue("?password", Cryptography.Encrypt(pPass)); MySqlDataAdapter adap = new MySqlDataAdapter(comando); adap.Fill(dt); return(dt); }
public static int Actualizar(Responsable pResponsable) { int retorno = 0; MySqlConnection conexion = BDConexion.ObtenerConexion(); // UPDATE `responsable` SET `Puesto` = 'Almacenista', `HoraIngreso` = '14:13:22' WHERE `responsable`.`idResponsable` = 2 //UPDATE `responsable` SET `Nombre`='{0}',`Alias`='{1}',`Password`='{2}',`Puesto`='{3}',`FechaIngreso`='{4}',`HoraIngreso`='{5}' WHERE `responsable`.`idResponsable` = {6} MySqlCommand comando = new MySqlCommand(string.Format("UPDATE `responsable` SET `Nombre`='{0}',`Alias`='{1}',`Password`= MD5('{2}'),`Puesto`='{3}', `CORREO`='{4}' WHERE `responsable`.`idResponsable` = {5}", pResponsable.Nombre, pResponsable.Alias, pResponsable.Password, pResponsable.Puesto, pResponsable.Correo, pResponsable.idResponsable), conexion); retorno = comando.ExecuteNonQuery(); conexion.Close(); return(retorno); }
public static DataTable Buscar2(string pIdProd) { DataTable dt = new DataTable(); MySqlConnection conexion = BDConexion.ObtenerConexion(); // SELECT * FROM `detalle` WHERE `Factura_idFactura` = 1 AND `Productos_idProducto` = 5 string consulta = "SELECT * FROM `detalle` WHERE `Productos_idProducto` = " + pIdProd + " "; MySqlCommand comando = new MySqlCommand(String.Format(consulta), conexion); comando.Parameters.AddWithValue("{0}", pIdProd); MySqlDataAdapter adap = new MySqlDataAdapter(comando); adap.Fill(dt); return(dt); }
// SELECT `Factura_idFactura` FROM `detalle` WHERE `Productos_idProducto` = 5 // SELECT * FROM `ventaunapersona` public static DataTable obtenerFact(string num) { MySqlConnection _conexion = BDConexion.ObtenerConexion(); string consulta = "SELECT `idFactura` FROM `factura` WHERE factura.Cliente_idCliente = @idCliente ORDER BY idFactura DESC"; DataTable dt = new DataTable(); MySqlCommand comando = new MySqlCommand(consulta, _conexion); comando.Parameters.AddWithValue("@idCliente", num); MySqlDataAdapter adap = new MySqlDataAdapter(comando); adap.Fill(dt); return(dt); }
public static DataTable obtenerClienteApe(string num) { MySqlConnection _conexion = BDConexion.ObtenerConexion(); string consulta = "SELECT `Apellidos` FROM `cliente` WHERE cliente.idCliente = @idCliente"; DataTable dt = new DataTable(); MySqlCommand comando = new MySqlCommand(consulta, _conexion); comando.Parameters.AddWithValue("@idCliente", num); MySqlDataAdapter adap = new MySqlDataAdapter(comando); adap.Fill(dt); return(dt); }
public static DataTable obtenerProdPrecio(string num) { MySqlConnection _conexion = BDConexion.ObtenerConexion(); string consulta = "SELECT `Precio` FROM `productos` WHERE idProducto = @idProducto"; DataTable dt = new DataTable(); MySqlCommand comando = new MySqlCommand(consulta, _conexion); comando.Parameters.AddWithValue("@idProducto", num); MySqlDataAdapter adap = new MySqlDataAdapter(comando); adap.Fill(dt); return(dt); }
static void Main() { bool isNew = false; Mutex mtx = new Mutex(true, "BD_HA_V2", out isNew); LOGGER.Info("Verificamos que solo exista una aplicación abierta."); if (!isNew) { return; } LOGGER.Info("Aqui estamos llamando a la funcionn de Obtener conexion"); BDConexion.ObtenerConexion(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new SignIn()); }
public static int Actualizar(Producto pProductos) { int retorno = 0; MySqlConnection conexion = BDConexion.ObtenerConexion(); MessageBox.Show(Convert.ToString(pProductos.idResponsable)); MessageBox.Show(Convert.ToString(pProductos.Nombre)); MessageBox.Show(Convert.ToString(pProductos.Talla)); MessageBox.Show(Convert.ToString(pProductos.Precio)); MessageBox.Show(Convert.ToString(pProductos.Stock)); MessageBox.Show(Convert.ToString(pProductos.idProductos)); //UPDATE `productos` SET `Responsable_idResponsable` = '8', `Nombre` = 'cobija', `Talla` = 'Chico', `Precio` = '54', `Stock` = '65' WHERE `productos`.`idProducto` = 4 MySqlCommand comando = new MySqlCommand(string.Format("UPDATE `productos` SET `Responsable_idResponsable` = '{0}', `Nombre` = '{1}', `Talla` = '{2}', `Precio` = '{3}', `Stock` = '{4}' WHERE `productos`.`idProducto` = '{5}'", pProductos.idResponsable, pProductos.Nombre, pProductos.Talla, pProductos.Precio, pProductos.Stock, pProductos.idProductos), conexion); retorno = comando.ExecuteNonQuery(); conexion.Close(); return(retorno); }
public static int ComprobarUsuario(string pAlias, string pPass) { int retorno = 0; MySqlConnection conexion = BDConexion.ObtenerConexion(); string SQL = "SELECT * FROM `responsable` WHERE `Alias` = '" + pAlias + "' AND `Password` = MD5('" + pPass + "')"; MySqlCommand comando = new MySqlCommand(String.Format(SQL), conexion); MySqlDataReader leer = comando.ExecuteReader(); if (leer.Read()) { retorno = 1; conexion.Close(); return(retorno); } else { conexion.Close(); return(retorno); } }
public static BaseRegistro ObtenerProducto(int pIdRemision) { BaseRegistro pProducto = new BaseRegistro(); MySqlConnection conexion = BDConexion.ObtenerConexion(); MySqlCommand _comando = new MySqlCommand(String.Format("SELECT IdRegistro, IdProducto, Piezas, CostoUnit, Nombre, Talla, (Piezas*CostoUnit) AS Importe FROM registro where IdRegistro={0}", pIdRemision), conexion); MySqlDataReader _reader = _comando.ExecuteReader(); while (_reader.Read()) { pProducto.IdRemision = _reader.GetInt32(0); pProducto.IdProducto = _reader.GetString(1); pProducto.Piezas = _reader.GetString(2); pProducto.CostoUnit = _reader.GetString(3); pProducto.Nombre = _reader.GetString(4); pProducto.Talla = _reader.GetString(5); } conexion.Close(); return(pProducto); }
public static Cliente ObtenerCliente(int pidCliente) { Cliente pCliente = new Cliente(); MySqlConnection conexion = BDConexion.ObtenerConexion(); MySqlCommand _comando = new MySqlCommand(String.Format("SELECT `idCliente`, `Nombre`, `Apellidos`, `Direccion`, `Telefono`, `email` FROM `cliente` WHERE `cliente`.`idCliente` = {0}", pidCliente), conexion); MySqlDataReader _reader = _comando.ExecuteReader(); while (_reader.Read()) { pCliente.idCliente = _reader.GetInt32(0); pCliente.Nombre = _reader.GetString(1); pCliente.Apellidos = _reader.GetString(2); pCliente.Direccion = _reader.GetString(3); pCliente.Telefono = _reader.GetString(4); pCliente.Email = _reader.GetString(5); } conexion.Close(); return(pCliente); }
public static Producto ObtenerProductos(int pidProductos) { Producto pProductos = new Producto(); MySqlConnection conexion = BDConexion.ObtenerConexion(); //SELECT `idProducto`, `Nombre`, `Talla`, `Precio`, `Stock`, `Responsable_idResponsable` FROM `productos` WHERE `productos`.`idProducto` = 1 MySqlCommand _comando = new MySqlCommand(String.Format("SELECT `idProducto`, `Responsable_idResponsable`, `Nombre`, `Talla`, `Precio`, `Stock` FROM `productos` WHERE `productos`.`idProducto` = {0}", pidProductos), conexion); MySqlDataReader _reader = _comando.ExecuteReader(); while (_reader.Read()) { pProductos.idProductos = _reader.GetInt32(0); pProductos.idResponsable = _reader.GetString(1); pProductos.Nombre = _reader.GetString(2); pProductos.Talla = _reader.GetString(3); pProductos.Precio = _reader.GetString(4); pProductos.Stock = _reader.GetString(5); } conexion.Close(); return(pProductos); }
public static Responsable ObtenerUsuario(int pidResponsable) { Responsable pResponsable = new Responsable(); MySqlConnection conexion = BDConexion.ObtenerConexion(); //SELECT `idResponsable`, `Nombre`, `Alias`, `Password`, `Puesto`, `FechaIngreso`, `HoraIngreso` FROM `responsable` WHERE `responsable`.`idResponsable` = 1 MySqlCommand _comando = new MySqlCommand(String.Format("SELECT `idResponsable`, `Nombre`, `Alias`, `Password`, `Puesto`, `FechaIngreso`, `HoraIngreso`, `CORREO` FROM `responsable` WHERE `responsable`.`idResponsable` = {0}", pidResponsable), conexion); MySqlDataReader _reader = _comando.ExecuteReader(); while (_reader.Read()) { pResponsable.idResponsable = _reader.GetInt32(0); pResponsable.Nombre = _reader.GetString(1); pResponsable.Alias = _reader.GetString(2); pResponsable.Password = _reader.GetString(3); pResponsable.Puesto = _reader.GetString(4); pResponsable.FechaIngreso = _reader.GetString(5); pResponsable.HoraIngreso = _reader.GetString(6); pResponsable.Correo = _reader.GetString(7); } conexion.Close(); return(pResponsable); }
public static List <Producto> Buscar(string pidProductos) { List <Producto> _lista = new List <Producto>(); MySqlCommand _comando = new MySqlCommand(String.Format( "SELECT `idProducto`, `Responsable_idResponsable`, `Nombre`, `Talla`, `Precio`, `Stock`, `FechaIngreso`, `HoraIngreso` FROM `productos` WHERE `productos`.`idProducto` = {0}", pidProductos), BDConexion.ObtenerConexion()); MySqlDataReader _reader = _comando.ExecuteReader(); while (_reader.Read()) { Producto pProductos = new Producto(); pProductos.idProductos = _reader.GetInt32(0); pProductos.idResponsable = _reader.GetString(1); pProductos.Nombre = _reader.GetString(2); pProductos.Talla = _reader.GetString(3); pProductos.Precio = _reader.GetString(4); pProductos.Stock = _reader.GetString(5); _lista.Add(pProductos); } return(_lista); }
public static int AgregarFactura(Factura pFactura) { int retorno = 0; // INSERT INTO `factura`(`idFactura`, `Cliente_idCliente`, `Responsable_idResponsable`, `Fecha`) VALUES ('{0}','{1}','{2}',CURRENT_DATE()) MySqlCommand comando = new MySqlCommand(string.Format("INSERT INTO `factura`(`idFactura`, `Cliente_idCliente`, `Responsable_idResponsable`, `Fecha`) VALUES ('{0}','{1}','{2}',CURRENT_DATE())", pFactura.idFactura, pFactura.Cliente_idCliente, pFactura.Responsable_idResponsable), BDConexion.ObtenerConexion()); retorno = comando.ExecuteNonQuery(); return(retorno); }
public static List <Cliente> Buscar(string pidCliente) { List <Cliente> _lista = new List <Cliente>(); MySqlCommand _comando = new MySqlCommand(String.Format( "SELECT `idCliente`, `Nombre`, `Apellidos`, `Direccion`, `Telefono`, `email` FROM `cliente` WHERE `cliente`.`idCliente` = {0}", pidCliente), BDConexion.ObtenerConexion()); MySqlDataReader _reader = _comando.ExecuteReader(); while (_reader.Read()) { Cliente pCliente = new Cliente(); pCliente.idCliente = _reader.GetInt32(0); pCliente.Nombre = _reader.GetString(1); pCliente.Apellidos = _reader.GetString(2); pCliente.Direccion = _reader.GetString(3); pCliente.Telefono = _reader.GetString(4); pCliente.Email = _reader.GetString(5); _lista.Add(pCliente); } return(_lista); }
public static int AgregarUsuario(Responsable pResponsable) { int retorno = 0; MySqlCommand comando = new MySqlCommand(string.Format("INSERT INTO `responsable`(`idResponsable`, `Nombre`, `Alias`, `Password`, `Puesto`, `FechaIngreso`, `HoraIngreso`, `CORREO`) VALUES ('{0}','{1}','{2}','{3}','{4}',CURRENT_DATE(), CURRENT_TIME(),'{5}')", pResponsable.idResponsable, pResponsable.Nombre, pResponsable.Alias, Cryptography.Encrypt(pResponsable.Password), pResponsable.Puesto, pResponsable.Correo), BDConexion.ObtenerConexion()); retorno = comando.ExecuteNonQuery(); return(retorno); }
public static List <Responsable> Buscar(string pidResponsable) { List <Responsable> _lista = new List <Responsable>(); MySqlCommand _comando = new MySqlCommand(String.Format( "SELECT `idResponsable`, `Nombre`, `Alias`, `Password`, `Puesto`, `FechaIngreso`, `HoraIngreso`, `CORREO` FROM `responsable` WHERE `responsable`.`idResponsable` = {0}", pidResponsable), BDConexion.ObtenerConexion()); MySqlDataReader _reader = _comando.ExecuteReader(); while (_reader.Read()) { Responsable pResponsable = new Responsable(); pResponsable.idResponsable = _reader.GetInt32(0); pResponsable.Nombre = _reader.GetString(1); pResponsable.Alias = _reader.GetString(2); pResponsable.Password = _reader.GetString(3); pResponsable.Puesto = _reader.GetString(4); pResponsable.FechaIngreso = _reader.GetString(5); pResponsable.HoraIngreso = _reader.GetString(6); pResponsable.Correo = _reader.GetString(7); _lista.Add(pResponsable); } return(_lista); }