Пример #1
0
        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);
            }
        }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }
Пример #4
0
        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);
        }
Пример #5
0
        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);
        }
Пример #6
0
        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);
        }
Пример #7
0
        public static int AgregarDetalle(Detalle pDetalle)
        {
            int retorno = 0;

            // INSERT INTO `detalle`(`idDetalle`, `Factura_idFactura`, `Productos_idProducto`, `Cantidad`, `Precio`) VALUES ([value-1],[value-2],[value-3],[value-4],[value-5])

            MySqlCommand comando = new MySqlCommand(string.Format("INSERT INTO `detalle`(`idDetalle`, `Factura_idFactura`, `Productos_idProducto`, `Cantidad`) VALUES ('{0}','{1}','{2}','{3}')",
                                                                  pDetalle.idDetalle, pDetalle.Factura_idFactura, pDetalle.Productos_idProducto, pDetalle.Cantidad), BDConexion.ObtenerConexion());

            retorno = comando.ExecuteNonQuery();

            return(retorno);
        }
Пример #8
0
        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);
        }
Пример #9
0
        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);
        }
Пример #10
0
        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);
        }
Пример #11
0
        public static List <Producto> Buscar(string pIdRemision)
        {
            List <Producto> _lista = new List <Producto>();

            MySqlCommand _comando = new MySqlCommand(String.Format(
                                                         "SELECT IdRegistro, IdProducto, Piezas, CostoUnit, Nombre, Talla, (Piezas*CostoUnit) AS Importe FROM registro where IdRegistro ='{0}'", pIdRemision), BDConexion.ObtenerConexion());
            MySqlDataReader _reader = _comando.ExecuteReader();

            while (_reader.Read())
            {
                Producto pProducto = new Producto();
                pProducto.idProductos  = _reader.GetInt32(0);
                pProducto.Nombre       = _reader.GetString(1);
                pProducto.FechaIngreso = _reader.GetString(2);
                pProducto.FechaIngreso = _reader.GetString(3);
                pProducto.Nombre       = _reader.GetString(4);
                pProducto.Talla        = _reader.GetString(5);
                _lista.Add(pProducto);
            }

            return(_lista);
        }
Пример #12
0
        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);
        }
Пример #13
0
        public static int AgregarProducto(BaseRegistro pProducto)
        {
            int retorno = 0;

            MySqlCommand comando = new MySqlCommand(string.Format("INSERT INTO registro (IdProducto, Piezas, CostoUnit, Nombre, Talla) VALUES ('{0}','{1}','{2}','{3}','{4}') ",
                                                                  pProducto.IdProducto, pProducto.Piezas, pProducto.CostoUnit, pProducto.Nombre, pProducto.Talla), BDConexion.ObtenerConexion());

            //INSERT INTO `registro` (`IdProducto`, `Piezas`, `CostoUnit`, `Nombre`, `Clasif`) VALUES ('{0}','{1}','{2}','{3}','{4}')

            retorno = comando.ExecuteNonQuery();

            return(retorno);
        }
Пример #14
0
        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);
        }
Пример #15
0
        public static int AgregarCliente(Cliente pCliente)
        {
            int retorno = 0;
            // INSERT INTO `cliente`(`idCliente`, `Nombre`, `Apellidos`, `Direccion`, `Telefono`, `email`) VALUES ([value-1],[value-2],[value-3],[value-4],[value-5],[value-6])
            MySqlCommand comando = new MySqlCommand(string.Format("INSERT INTO `cliente`(`idCliente`, `Nombre`, `Apellidos`, `Direccion`, `Telefono`, `email`) VALUES ('{0}','{1}','{2}','{3}','{4}','{5}')",
                                                                  pCliente.idCliente, pCliente.Nombre, pCliente.Apellidos, pCliente.Direccion, pCliente.Telefono, pCliente.Email), BDConexion.ObtenerConexion());

            retorno = comando.ExecuteNonQuery();

            return(retorno);
        }
Пример #16
0
        public static int AgregarProducto(Producto pProducto)
        {
            int retorno = 0;

            MySqlCommand comando = new MySqlCommand(string.Format("INSERT INTO `productos` (`idProducto`, `Responsable_idResponsable`, `Nombre`, `Talla`, `Precio`, `Stock`, `FechaIngreso`, `HoraIngreso`) VALUES ('{0}','{1}','{2}','{3}','{4}','{5}',CURRENT_DATE(), CURRENT_TIME())",
                                                                  pProducto.idProductos, pProducto.idResponsable, pProducto.Nombre, pProducto.Talla, pProducto.Precio, pProducto.Stock), BDConexion.ObtenerConexion());

            retorno = comando.ExecuteNonQuery();

            return(retorno);
        }
Пример #17
0
        public static List <VistaVenta> Llenar(string pidFactura)
        {
            List <VistaVenta> _lista = new List <VistaVenta>();

            MySqlCommand _comando = new MySqlCommand(String.Format(
                                                         "SELECT factura.idFactura, responsable.Nombre AS Responsable, productos.Nombre, productos.Talla, productos.Precio, cliente.Nombre AS Comprador, CONCAT('$ ',FORMAT(detalle.Cantidad*productos.Precio,2)) AS Importe FROM `factura` INNER JOIN detalle INNER JOIN cliente INNER JOIN responsable INNER JOIN productos ON cliente.idCliente = factura.Cliente_idCliente AND responsable.idResponsable = factura.Responsable_idResponsable AND productos.idProducto = detalle.Productos_idProducto AND detalle.Factura_idFactura = factura.idFactura WHERE factura.idFactura = {0}", pidFactura), BDConexion.ObtenerConexion());
            MySqlDataReader _reader = _comando.ExecuteReader();

            while (_reader.Read())
            {
                VistaVenta pVentas = new VistaVenta();
                pVentas.idFactura   = _reader.GetInt32(0);
                pVentas.Responsable = _reader.GetString(1);
                pVentas.Nombre      = _reader.GetString(2);
                pVentas.Talla       = _reader.GetString(3);
                pVentas.Precio      = _reader.GetString(4);
                pVentas.Comprador   = _reader.GetString(5);
                pVentas.Importe     = _reader.GetString(6);
                _lista.Add(pVentas);
            }
            return(_lista);
        }