Exemplo n.º 1
0
        public void actualizarPedido(Pedido p, BindingList <DetallePedido> detalles)
        {
            Conexion con = new Conexion();

            if (con.IsConnected())
            {
                MySqlCommand comando = new MySqlCommand();
                comando.CommandType = System.Data.CommandType.StoredProcedure;
                comando.CommandText = "ACTUALIZAR_PEDIDO_PRODUCTO";
                comando.Connection  = con.Connection;
                comando.Parameters.Add("_ID_PEDIDO", MySqlDbType.Int32).Value       = p.IdPedido;
                comando.Parameters.Add("_ID_EMPLEADO", MySqlDbType.Int32).Value     = p.IdUsuario;
                comando.Parameters.Add("_FECHA_ENTREGA", MySqlDbType.Date).Value    = p.FechaEntrega;
                comando.Parameters.Add("_IMPORTE_TOTAL", MySqlDbType.Decimal).Value = p.ImporteTotal;
                comando.Parameters.Add("_A_CUENTA_PED", MySqlDbType.Decimal).Value  = p.Cuenta;
                comando.Parameters.Add("_SALDO_PED", MySqlDbType.Decimal).Value     = p.Saldo;
                comando.Parameters.Add("_IGV", MySqlDbType.Decimal).Value           = p.Igv;

                comando.ExecuteNonQuery();

                MySqlCommand comando2 = new MySqlCommand();
                comando2.CommandType = System.Data.CommandType.StoredProcedure;
                comando2.CommandText = "ELIMINAR_DETALLE_PEDIDO_PRODUCTO";
                comando2.Connection  = con.Connection;
                comando2.Parameters.Add("_NUM_ORDEN", MySqlDbType.Int32).Value = p.IdPedido;
                comando2.ExecuteNonQuery();

                foreach (DetallePedido d in detalles)
                {
                    d.IdPedido = p.IdPedido;
                    this.registrarDetallePedido(d);
                }
                con.Close();
            }
        }
Exemplo n.º 2
0
        public void avanzarPedido(Pedido p)
        {
            Conexion conexion = new Conexion();

            if (conexion.IsConnected())
            {
                MySqlCommand comando = new MySqlCommand();
                comando.CommandText = String.Format("UPDATE PEDIDO_PRODUCTO SET ESTADO = 'EN PRODUCCION' WHERE ID_PEDIDO_P = \"{0}\"", p.IdPedido);
                comando.Connection  = conexion.Connection;
                comando.ExecuteNonQuery();

                comando.CommandType = System.Data.CommandType.StoredProcedure;
                comando.CommandText = "REGISTRAR_ORDEN_PRODUCCION";
                comando.Parameters.Add("_ID_PEDIDO", MySqlDbType.Int32).Value               = p.IdPedido;
                comando.Parameters.Add("_ID_EMPLEADO", MySqlDbType.Int32).Value             = p.IdUsuario;
                comando.Parameters.Add("_ID_ORDEN_PRODUCCION", MySqlDbType.Int32).Direction = System.Data.ParameterDirection.Output;
                comando.ExecuteNonQuery();
                string idOrdenProduccion = comando.Parameters["_ID_ORDEN_PRODUCCION"].Value.ToString();

                MySqlCommand comando2 = new MySqlCommand();
                BindingList <DetallePedido> detalles = listarDetallesPedido(p.IdPedido);
                foreach (DetallePedido d in detalles)
                {
                    comando2.CommandText = String.Format("INSERT INTO DETALLE_ORDEN_PRODUCCION(`ID_ORDEN_PROD`,`ID_PRODUCTO`,`ACTIVO`) VALUES (\"{0}\",\"{1}\",1);", idOrdenProduccion, d.IdProducto);
                    comando2.Connection  = conexion.Connection;
                    comando2.ExecuteNonQuery();
                }

                conexion.Close();
            }
        }
Exemplo n.º 3
0
        public int registrarClienteJuridico(Juridica c)
        {
            Conexion con = new Conexion();

            if (con.IsConnected())
            {
                MySqlCommand comando = new MySqlCommand();
                comando.CommandType = System.Data.CommandType.StoredProcedure;
                comando.CommandText = "REGISTRAR_CLIENTE_JURIDICO";
                comando.Connection  = con.Connection;
                comando.Parameters.Add("_RAZON", MySqlDbType.VarChar).Value          = c.RazonSocial;
                comando.Parameters.Add("_RUC", MySqlDbType.VarChar).Value            = c.Ruc;
                comando.Parameters.Add("_NOMBRE", MySqlDbType.VarChar).Value         = c.Nombre;
                comando.Parameters.Add("_TELEFONO", MySqlDbType.VarChar).Value       = c.Telefono;
                comando.Parameters.Add("_EMAIL", MySqlDbType.VarChar).Value          = c.Email;
                comando.Parameters.Add("_DIRECCION", MySqlDbType.VarChar).Value      = c.Direccion;
                comando.Parameters.Add("_FECHA_ANIVERSARIO", MySqlDbType.Date).Value = c.FechaAniversario;
                comando.Parameters.Add("_ID_PERSONA", MySqlDbType.Int32).Direction   = System.Data.ParameterDirection.Output;

                int check = comando.ExecuteNonQuery();
                con.Close();
                if (check == 1)
                {
                    return(Int32.Parse(comando.Parameters["_ID_PERSONA"].Value.ToString()));
                }
                else
                {
                    return(0);
                }
            }
            return(-1);
        }
Exemplo n.º 4
0
        public BindingList <Juridica> listarPersonasJuridicas()
        {
            BindingList <Juridica> lista = new BindingList <Juridica>();

            Conexion con = new Conexion();

            if (con.IsConnected())
            {
                MySqlCommand comando = new MySqlCommand();
                comando.CommandType = System.Data.CommandType.StoredProcedure;
                comando.CommandText = "LISTAR_PERSONAS_JURIDICAS";
                comando.Connection  = con.Connection;
                MySqlDataReader reader = comando.ExecuteReader();
                while (reader.Read())
                {
                    Juridica n = new Juridica();
                    n.Direccion        = reader.GetString("DIRECCION");
                    n.Email            = reader.GetString("EMAIL");
                    n.FechaAniversario = (DateTime)reader.GetMySqlDateTime("FECHA_ANIVERSARIO");
                    n.IdPersona        = reader.GetInt32("ID_PERSONA").ToString();
                    n.Nombre           = reader.GetString("NOMBRE");
                    n.RazonSocial      = reader.GetString("RAZON_SOCIAL");
                    n.Ruc      = reader.GetString("RUC");
                    n.Telefono = reader.GetString("TELEFONO");
                    lista.Add(n);
                }
                con.Close();
            }
            return(lista);
        }
Exemplo n.º 5
0
        public int registrarClienteNatural(Natural c)
        {
            Conexion con = new Conexion();

            if (con.IsConnected())
            {
                MySqlCommand comando = new MySqlCommand();
                comando.CommandType = System.Data.CommandType.StoredProcedure;
                comando.CommandText = "REGISTRAR_CLIENTE_NATURAL";
                comando.Connection  = con.Connection;
                comando.Parameters.Add("_NOMBRE", MySqlDbType.VarChar).Value     = c.Nombre;
                comando.Parameters.Add("_DNI", MySqlDbType.VarChar).Value        = c.Dni;
                comando.Parameters.Add("_AP_PATERNO", MySqlDbType.VarChar).Value = c.ApPat;
                comando.Parameters.Add("_AP_MATERNO", MySqlDbType.VarChar).Value = c.ApMat;
                comando.Parameters.Add("_SEXO", MySqlDbType.VarChar).Value       = c.Sexo;
                comando.Parameters.Add("_FECHA_NAC", MySqlDbType.Date).Value     = c.FechaNac;
                comando.Parameters.Add("_TELEFONO", MySqlDbType.VarChar).Value   = c.Telefono;
                comando.Parameters.Add("_EMAIL", MySqlDbType.VarChar).Value      = c.Email;
                comando.Parameters.Add("_DIRECCION", MySqlDbType.VarChar).Value  = c.Direccion;

                comando.Parameters.Add("_ID_PERSONA", MySqlDbType.Int32).Direction = System.Data.ParameterDirection.Output;

                int check = comando.ExecuteNonQuery();
                con.Close();
                if (check == 1)
                {
                    return(Int32.Parse(comando.Parameters["_ID_PERSONA"].Value.ToString()));
                }
                else
                {
                    return(0);
                }
            }
            return(-1);
        }
Exemplo n.º 6
0
        public BindingList <Natural> listarClienteNatural()
        {
            BindingList <Natural> lista = new BindingList <Natural>();

            Conexion con = new Conexion();

            if (con.IsConnected())
            {
                MySqlCommand comando = new MySqlCommand();
                comando.CommandType = System.Data.CommandType.StoredProcedure;
                comando.CommandText = "LISTAR_CLIENTE_NATURAL";
                comando.Connection  = con.Connection;
                MySqlDataReader reader = comando.ExecuteReader();
                while (reader.Read())
                {
                    Natural n = new Natural();
                    n.ApMat     = reader.GetString("AP_MATERNO");
                    n.ApPat     = reader.GetString("AP_PATERNO");
                    n.Direccion = reader.GetString("DIRECCION");
                    n.Dni       = reader.GetString("DNI");
                    n.Email     = reader.GetString("EMAIL");
                    n.FechaNac  = (DateTime)reader.GetMySqlDateTime("FECHA_NACIMIENTO");
                    n.IdPersona = reader.GetInt32("ID_PERSONA").ToString();
                    n.Nombre    = reader.GetString("NOMBRE");
                    n.Sexo      = reader.GetChar("SEXO");
                    n.Telefono  = reader.GetString("TELEFONO");
                    lista.Add(n);
                }
                con.Close();
            }
            return(lista);
        }
Exemplo n.º 7
0
        public BindingList <OrdenProduccion> listarOrdenesProduccion(int idOrden)
        {
            BindingList <OrdenProduccion> lista = new BindingList <OrdenProduccion>();
            Conexion con = new Conexion();

            if (con.IsConnected())
            {
                MySqlCommand comando = new MySqlCommand();
                comando.CommandType = System.Data.CommandType.StoredProcedure;
                comando.CommandText = "LISTAR_DETALLES_ORDEN_PRODUCCION";
                comando.Parameters.Add("_ID_PEDIDO", MySqlDbType.Int32).Value = idOrden;
                comando.Connection = con.Connection;
                MySqlDataReader reader = comando.ExecuteReader();
                while (reader.Read())
                {
                    OrdenProduccion orden = new OrdenProduccion();

                    orden.IdProducto = reader.GetInt32("ID_PRODUCTO");
                    orden.NombreProd = reader.GetString("NOMBRE");
                    orden.Cantidad   = reader.GetInt32("CANT_PRODUCTO");
                    lista.Add(orden);
                }
                con.Close();
            }
            return(lista);
        }
Exemplo n.º 8
0
        public BindingList <Insumo> listarInsumos(string idProveedor)
        {
            BindingList <Insumo> lista = new BindingList <Insumo>();

            Conexion con = new Conexion();

            if (con.IsConnected())
            {
                MySqlCommand comando = new MySqlCommand();
                comando.CommandType = System.Data.CommandType.StoredProcedure;
                comando.CommandText = "LISTAR_INSUMOS_X_PROVEEDOR";
                comando.Connection  = con.Connection;
                comando.Parameters.Add("_ID_PROVEEDOR", MySqlDbType.Int32).Value = idProveedor;
                MySqlDataReader reader = comando.ExecuteReader();
                while (reader.Read())
                {
                    Insumo n = new Insumo();
                    n.Id = reader.GetInt32("ID_INSUMO").ToString();
                    n    = buscarInsumo(n.Id);
                    lista.Add(n);
                }
                con.Close();
            }

            return(lista);
        }
Exemplo n.º 9
0
        public int registrarUsuario(Usuario u)
        {
            Conexion con = new Conexion();

            if (con.IsConnected())
            {
                MySqlCommand comando = new MySqlCommand();
                comando.CommandType = System.Data.CommandType.StoredProcedure;
                comando.CommandText = "REGISTRAR_USUARIO";
                comando.Connection  = con.Connection;
                comando.Parameters.Add("_NOMBRE", MySqlDbType.VarChar).Value      = u.Nombre;
                comando.Parameters.Add("_DNI", MySqlDbType.VarChar).Value         = u.Dni;
                comando.Parameters.Add("_AP_PATERNO", MySqlDbType.VarChar).Value  = u.ApPat;
                comando.Parameters.Add("_AP_MATERNO", MySqlDbType.VarChar).Value  = u.ApMat;
                comando.Parameters.Add("_TELEFONO", MySqlDbType.VarChar).Value    = u.Telefono;
                comando.Parameters.Add("_EMAIL", MySqlDbType.VarChar).Value       = u.Email;
                comando.Parameters.Add("_DIRECCION", MySqlDbType.VarChar).Value   = u.Direccion;
                comando.Parameters.Add("_SEXO", MySqlDbType.VarChar).Value        = u.Sexo;
                comando.Parameters.Add("_FECHA_NAC", MySqlDbType.Date).Value      = u.FechaNac;
                comando.Parameters.Add("_ESTADOP", MySqlDbType.Int32).Value       = 1;
                comando.Parameters.Add("_TIPO_USUARIO", MySqlDbType.Int32).Value  = u.TipoUsuario;
                comando.Parameters.Add("_CONTRASENHA", MySqlDbType.VarChar).Value = u.Password;
                comando.Parameters.Add("_ESTADOU", MySqlDbType.Int32).Value       = u.EstadoU;
                comando.Parameters.Add("_ID_OUT", MySqlDbType.Int32).Direction    = System.Data.ParameterDirection.Output;

                int check = comando.ExecuteNonQuery();
                con.Close();
                if (check == 1)
                {
                    return(Int32.Parse(comando.Parameters["_ID_OUT"].Value.ToString()));
                }
                return(0);
            }
            return(-1);
        }
Exemplo n.º 10
0
        public int registrarOrdenCompra(OrdenCompra p, BindingList <DetalleOrdenCompra> detalles)
        {
            Conexion con = new Conexion();

            if (con.IsConnected())
            {
                /*
                 * MySqlCommand comando = new MySqlCommand();
                 * comando.CommandType = System.Data.CommandType.StoredProcedure;
                 * comando.CommandText = "REGISTRAR_ORDEN_COMPRA";
                 * comando.Connection = con.Connection;
                 * comando.Parameters.Add("_ID_EMPLEADO", MySqlDbType.Int32).Value = p.IdUsuario;
                 * comando.Parameters.Add("_ID_CLIENTE", MySqlDbType.Int32).Value = p.IdCliente;
                 * comando.Parameters.Add("_FECHA_ENTREGA", MySqlDbType.Date).Value = p.FechaEntrega;
                 * comando.Parameters.Add("_IMPORTE_TOTAL", MySqlDbType.Decimal).Value = p.ImporteTotal;
                 * comando.Parameters.Add("_A_CUENTA_PED", MySqlDbType.Decimal).Value = p.Cuenta;
                 * comando.Parameters.Add("_SALDO_PED", MySqlDbType.Decimal).Value = p.Saldo;
                 * comando.Parameters.Add("_IGV", MySqlDbType.Decimal).Value = p.Igv;
                 *
                 * comando.Parameters.Add("_ID_PEDIDO", MySqlDbType.Int32).Direction = System.Data.ParameterDirection.Output;
                 * int check = comando.ExecuteNonQuery();
                 * p.IdPedido = comando.Parameters["_ID_PEDIDO"].Value.ToString();
                 * foreach (DetalleOrdenCompra d in detalles)
                 * {
                 *  d.IdPedido = p.IdPedido;
                 *  this.registrarDetalleOrdenCompra(d);
                 * }
                 * con.Close();
                 * if (check == 1) return Int32.Parse(comando.Parameters["_ID_PEDIDO"].Value.ToString());
                 * else return 0;
                 */
            }
            return(-1);
        }
Exemplo n.º 11
0
        public int modificarUsuario(Usuario u)
        {
            Conexion con = new Conexion();

            if (con.IsConnected())
            {
                MySqlCommand comando = new MySqlCommand();
                comando.CommandType = System.Data.CommandType.StoredProcedure;
                comando.CommandText = "MODIFICAR_USUARIO";
                comando.Connection  = con.Connection;
                comando.Parameters.Add("_ID_PERSONA", MySqlDbType.Int32).Value    = Int32.Parse(u.IdPersona);
                comando.Parameters.Add("_NOMBRE", MySqlDbType.VarChar).Value      = u.Nombre;
                comando.Parameters.Add("_DNI", MySqlDbType.VarChar).Value         = u.Dni;
                comando.Parameters.Add("_AP_PATERNO", MySqlDbType.VarChar).Value  = u.ApPat;
                comando.Parameters.Add("_AP_MATERNO", MySqlDbType.VarChar).Value  = u.ApMat;
                comando.Parameters.Add("_TELEFONO", MySqlDbType.VarChar).Value    = u.Telefono;
                comando.Parameters.Add("_EMAIL", MySqlDbType.VarChar).Value       = u.Email;
                comando.Parameters.Add("_DIRECCION", MySqlDbType.VarChar).Value   = u.Direccion;
                comando.Parameters.Add("_SEXO", MySqlDbType.VarChar).Value        = u.Sexo;
                comando.Parameters.Add("_FECHA_NAC", MySqlDbType.Date).Value      = u.FechaNac;
                comando.Parameters.Add("_ESTADOP", MySqlDbType.Int32).Value       = 1;
                comando.Parameters.Add("_TIPO_USUARIO", MySqlDbType.Int32).Value  = u.TipoUsuario;
                comando.Parameters.Add("_CONTRASENHA", MySqlDbType.VarChar).Value = u.Password;
                comando.Parameters.Add("_ESTADOU", MySqlDbType.Int32).Value       = 1;

                int result = comando.ExecuteNonQuery();
                con.Close();
                return(result);
            }
            return(-1);
        }
Exemplo n.º 12
0
        public BindingList <Proveedor> listarProveedores()
        {
            BindingList <Proveedor> lista = new BindingList <Proveedor>();

            Conexion con = new Conexion();

            if (con.IsConnected())
            {
                MySqlCommand comando = new MySqlCommand();
                comando.CommandType = System.Data.CommandType.StoredProcedure;
                comando.CommandText = "LISTAR_PROVEEDORES";
                comando.Connection  = con.Connection;
                MySqlDataReader reader = comando.ExecuteReader();
                while (reader.Read())
                {
                    Proveedor n = new Proveedor();
                    n.Email                = reader.GetString("_EMAIL");
                    n.FechaAniversario     = reader.GetDateTime("_FECHA_ANIVERSARIO");
                    n.IdPersona            = reader.GetInt32("_ID_PERSONA").ToString();
                    n.IdProveedor          = reader.GetInt32("_ID_PROVEEDOR").ToString();
                    n.Nombre               = reader.GetString("_NOMBRE");
                    n.RazonSocial          = reader.GetString("_RAZON_SOCIAL");
                    n.Representante.Nombre = reader.GetString("_NOMBRE_REP");
                    n.Ruc      = reader.GetString("_RUC");
                    n.Telefono = reader.GetString("_TELEFONO");

                    lista.Add(n);
                }
                con.Close();
            }

            return(lista);
        }
Exemplo n.º 13
0
        public int ObtenerNivelUsuario(string id)
        {
            Conexion conexion = new Conexion();

            if (conexion.IsConnected())
            {
                MySqlCommand comando = new MySqlCommand();
                comando.CommandText = String.Format("SELECT TIPO_USUARIO FROM USUARIO WHERE ID_USUARIO = '{0}' AND ACTIVO=1", id);
                comando.Connection  = conexion.Connection;
                try
                {
                    MySqlDataReader reader = comando.ExecuteReader();
                    int             nivel  = 0;
                    if (reader.Read())
                    {
                        nivel = reader.GetInt32("TIPO_USUARIO");
                    }
                    conexion.Close();
                    return(nivel);
                }
                catch (Exception)
                {
                    conexion.Close();
                    return(0);
                }
            }
            else
            {
                return(-1);
            }
        }
Exemplo n.º 14
0
        public int ValidarUsuario(string user, string password)
        {
            Conexion conexion = new Conexion();

            if (conexion.IsConnected())
            {
                MySqlCommand comando = new MySqlCommand();
                comando.CommandText = String.Format("SELECT * FROM USUARIO WHERE ID_USUARIO = \"{0}\" AND CONTRASENHA = \"{1}\" AND ACTIVO=1", user, password);
                comando.Connection  = conexion.Connection;
                try{
                    int mysqlint = int.Parse(comando.ExecuteScalar().ToString());

                    inicioSesion(user);

                    conexion.Close();
                    return(1);
                }
                catch (Exception)
                {
                    conexion.Close();
                    return(0);
                }
            }
            else
            {
                return(-1);
            }
        }
Exemplo n.º 15
0
        public BindingList <DetallePedido> listarDetallesPedido(string id)
        {
            BindingList <DetallePedido> lista = new BindingList <DetallePedido>();
            Conexion con = new Conexion();

            if (con.IsConnected())
            {
                MySqlCommand comando = new MySqlCommand();
                comando.CommandType = System.Data.CommandType.StoredProcedure;
                comando.CommandText = "LISTAR_DETALLES_PEDIDO";
                comando.Parameters.Add("_ID_PEDIDO", MySqlDbType.Int32).Value = id;
                comando.Connection = con.Connection;
                MySqlDataReader reader = comando.ExecuteReader();
                while (reader.Read())
                {
                    DetallePedido n = new DetallePedido();
                    n.IdDetalle   = reader.GetInt32("ID_DETALLE_ORDEN").ToString();
                    n.IdPedido    = id;
                    n.Cantidad    = reader.GetInt32("CANT_PRODUCTO");
                    n.Subtotal    = reader.GetFloat("IMPORTE_TOTAL_PRODUCTO");
                    n.Producto.Id = reader.GetInt32("ID_PRODUCTO").ToString();
                    lista.Add(n);
                }
                con.Close();
            }
            return(lista);
        }
Exemplo n.º 16
0
        public BindingList <Producto> listarProductos()
        {
            Conexion con = new Conexion();

            if (con.IsConnected())
            {
                MySqlCommand comando = new MySqlCommand();
                comando.CommandType = System.Data.CommandType.StoredProcedure;
                comando.CommandText = "LISTAR_PRODUCTOS";
                comando.Connection  = con.Connection;

                MySqlDataReader reader = comando.ExecuteReader();

                BindingList <Producto> lista = new BindingList <Producto>();

                while (reader.Read())
                {
                    Producto u = new Producto();
                    u.Id          = reader.GetString("ID_PRODUCTO");
                    u.Nombre      = reader.GetString("NOMBRE");
                    u.Descripcion = reader.GetString("DESCRIPCION");
                    u.Color       = reader.GetString("COLOR");
                    u.Precio      = reader.GetDouble("PRECIO");
                    u.StockActual = reader.GetInt32("STOCK_ACTUAL");
                    u.Activo1     = reader.GetInt32("ACTIVO");
                    u.Talla       = reader.GetChar("TALLA");

                    lista.Add(u);
                }

                con.Close();
                return(lista);
            }
            return(null);
        }
Exemplo n.º 17
0
        public void eliminarCliente(string id)
        {
            Conexion con = new Conexion();

            if (con.IsConnected())
            {
                MySqlCommand comando = new MySqlCommand();
                comando.CommandText = String.Format("UPDATE PERSONA SET ACTIVO = 0  WHERE ID_PERSONA = \"{0}\"", id);
                comando.Connection  = con.Connection;
                comando.ExecuteNonQuery();
                con.Close();
            }
        }
Exemplo n.º 18
0
        public void eliminarDetallePedido(DetallePedido d)
        {
            Conexion con = new Conexion();

            if (con.IsConnected())
            {
                MySqlCommand comando = new MySqlCommand();
                comando.CommandType = System.Data.CommandType.StoredProcedure;
                comando.CommandText = "ELIMINAR_DETALLE_PEDIDO_PRODUCTO";
                comando.Connection  = con.Connection;
                comando.Parameters.Add("_NUM_ORDEN", MySqlDbType.Int32).Value = d.IdPedido;

                int check = comando.ExecuteNonQuery();
                con.Close();
            }
        }
Exemplo n.º 19
0
        public void registrarDetallePedido(DetallePedido d)
        {
            Conexion con = new Conexion();

            if (con.IsConnected())
            {
                MySqlCommand comando = new MySqlCommand();
                comando.CommandType = System.Data.CommandType.StoredProcedure;
                comando.CommandText = "REGISTRAR_DETALLE_PEDIDO_PRODUCTO";
                comando.Connection  = con.Connection;
                comando.Parameters.Add("_NUM_ORDEN", MySqlDbType.Int32).Value              = d.IdPedido;
                comando.Parameters.Add("_CANTIDAD_PRODUCTO", MySqlDbType.Int32).Value      = d.Cantidad;
                comando.Parameters.Add("_IMPORTE_TOTAL_PRODUCTO", MySqlDbType.Int32).Value = d.Subtotal;
                comando.Parameters.Add("_ID_PRODUCTO", MySqlDbType.Int32).Value            = d.Producto.Id;

                comando.ExecuteNonQuery();
                con.Close();
            }
        }
Exemplo n.º 20
0
        public void eliminarUsuario(string id)
        {
            Conexion conexion = new Conexion();

            if (conexion.IsConnected())
            {
                MySqlCommand comando = new MySqlCommand();
                comando.CommandText = String.Format("UPDATE USUARIO SET ACTIVO = 0  WHERE ID_USUARIO = \"{0}\"", id);
                comando.Connection  = conexion.Connection;
                try
                {
                    comando.ExecuteNonQuery();
                    conexion.Close();
                }
                catch (Exception)
                {
                    conexion.Close();
                }
            }
        }
Exemplo n.º 21
0
        public void cerrarSesion(string user)
        {
            Conexion conexion = new Conexion();

            if (conexion.IsConnected())
            {
                MySqlCommand comando = new MySqlCommand();
                comando.CommandText = String.Format("UPDATE USUARIO SET ENLINEA = 0  WHERE ID_USUARIO = \"{0}\"", user);
                comando.Connection  = conexion.Connection;
                try
                {
                    comando.ExecuteNonQuery();
                    conexion.Close();
                }
                catch (Exception)
                {
                    conexion.Close();
                }
            }
        }
Exemplo n.º 22
0
        public BindingList <Usuario> listarUsuarios()
        {
            Conexion con = new Conexion();

            if (con.IsConnected())
            {
                MySqlCommand comando = new MySqlCommand();
                comando.CommandType = System.Data.CommandType.StoredProcedure;
                comando.CommandText = "LISTAR_USUARIOS";
                comando.Connection  = con.Connection;

                MySqlDataReader reader = comando.ExecuteReader();

                BindingList <Usuario> usuarios = new BindingList <Usuario>();

                while (reader.Read())
                {
                    Usuario u = new Usuario();
                    u.ApMat       = reader.GetString("AP_MATERNO");
                    u.ApPat       = reader.GetString("AP_PATERNO");
                    u.Direccion   = reader.GetString("DIRECCION");
                    u.Dni         = reader.GetString("DNI");
                    u.Email       = reader.GetString("EMAIL");
                    u.EstadoU     = reader.GetInt32("ACTIVO");
                    u.FechaNac    = (DateTime)reader.GetMySqlDateTime("FECHA_NACIMIENTO");
                    u.IdPersona   = reader.GetString("ID_PERSONA");
                    u.IdUsuario   = Int32.Parse(reader.GetString("ID_USUARIO"));
                    u.Nombre      = reader.GetString("NOMBRE");
                    u.Password    = reader.GetString("CONTRASENHA");
                    u.Sexo        = reader.GetChar("SEXO");
                    u.Telefono    = reader.GetString("TELEFONO");
                    u.TipoUsuario = reader.GetInt32("TIPO_USUARIO");

                    usuarios.Add(u);
                }

                con.Close();
                return(usuarios);
            }
            return(null);
        }
Exemplo n.º 23
0
        public int obtenerIdOrden(int id)
        {
            Conexion con = new Conexion();

            if (con.IsConnected())
            {
                MySqlCommand comando = new MySqlCommand();
                comando.CommandText = String.Format("SELECT ID_ORDEN_PROD FROM ORDEN_PRODUCCION WHERE ID_PEDIDO_P = '{0}'", id);
                comando.Connection  = con.Connection;
                MySqlDataReader reader  = comando.ExecuteReader();
                int             idOrden = -1;
                if (reader.Read())
                {
                    OrdenProduccion orden = new OrdenProduccion();
                    idOrden = reader.GetInt32("ID_ORDEN_PROD");
                }
                con.Close();
                return(idOrden);
            }
            return(-1);
        }
Exemplo n.º 24
0
        public int cancelarPedido(string id)
        {
            Conexion conexion = new Conexion();

            if (conexion.IsConnected())
            {
                MySqlCommand comando = new MySqlCommand();
                comando.CommandText = String.Format("UPDATE PEDIDO_PRODUCTO SET ACTIVO = 0, ESTADO = 'CANCELADO'" +
                                                    " WHERE ID_PEDIDO_P = \"{0}\"", id);
                comando.Connection = conexion.Connection;
                int rv = 0;
                try { rv = comando.ExecuteNonQuery(); }
                catch (Exception) { return(-1); }

                comando.CommandText = String.Format("UPDATE DETALLE_PEDIDO_PRODUCTO SET ACTIVO =0 WHERE NUM_ORDEN=\"{0}\"", id);
                int rv2 = 0;
                try { rv2 = comando.ExecuteNonQuery(); }
                catch (Exception) { return(-1); }
                conexion.Close();
            }
            return(-1);
        }
Exemplo n.º 25
0
        public int registrarPedido(Pedido p, BindingList <DetallePedido> detalles)
        {
            Conexion con = new Conexion();

            if (con.IsConnected())
            {
                MySqlCommand comando = new MySqlCommand();
                comando.CommandType = System.Data.CommandType.StoredProcedure;
                comando.CommandText = "REGISTRAR_PEDIDO_PRODUCTO";
                comando.Connection  = con.Connection;
                comando.Parameters.Add("_ID_EMPLEADO", MySqlDbType.Int32).Value     = p.IdUsuario;
                comando.Parameters.Add("_ID_CLIENTE", MySqlDbType.Int32).Value      = p.IdCliente;
                comando.Parameters.Add("_FECHA_ENTREGA", MySqlDbType.Date).Value    = p.FechaEntrega;
                comando.Parameters.Add("_IMPORTE_TOTAL", MySqlDbType.Decimal).Value = p.ImporteTotal;
                comando.Parameters.Add("_A_CUENTA_PED", MySqlDbType.Decimal).Value  = p.Cuenta;
                comando.Parameters.Add("_SALDO_PED", MySqlDbType.Decimal).Value     = p.Saldo;
                comando.Parameters.Add("_IGV", MySqlDbType.Decimal).Value           = p.Igv;

                comando.Parameters.Add("_ID_PEDIDO", MySqlDbType.Int32).Direction = System.Data.ParameterDirection.Output;
                int check = comando.ExecuteNonQuery();
                p.IdPedido = comando.Parameters["_ID_PEDIDO"].Value.ToString();
                foreach (DetallePedido d in detalles)
                {
                    d.IdPedido = p.IdPedido;
                    this.registrarDetallePedido(d);
                }
                con.Close();
                if (check == 1)
                {
                    return(Int32.Parse(comando.Parameters["_ID_PEDIDO"].Value.ToString()));
                }
                else
                {
                    return(0);
                }
            }
            return(-1);
        }
Exemplo n.º 26
0
        public BindingList <Pedido> listarPedidos()
        {
            BindingList <Pedido> lista = new BindingList <Pedido>();
            Conexion             con   = new Conexion();

            if (con.IsConnected())
            {
                MySqlCommand comando = new MySqlCommand();
                comando.CommandType = System.Data.CommandType.StoredProcedure;
                comando.CommandText = "LISTAR_PEDIDOS";
                comando.Connection  = con.Connection;
                MySqlDataReader reader = comando.ExecuteReader();
                while (reader.Read())
                {
                    Pedido n = new Pedido();
                    n.IdPedido     = reader.GetInt32("ID_PEDIDO_P").ToString();
                    n.IdUsuario    = reader.GetInt32("ID_EMPLEADO").ToString();
                    n.IdCliente    = reader.GetInt32("ID_CLIENTE").ToString();
                    n.FechaEntrega = reader.GetDateTime("FECHA_ENTREGA");
                    n.ImporteTotal = (float)reader.GetDecimal("IMPORTE_TOTAL");
                    n.Cuenta       = (float)reader.GetDecimal("A_CUENTA_PED");
                    n.Saldo        = (float)reader.GetDecimal("SALDO_PED");
                    n.Estado       = reader.GetString("ESTADO");
                    if (reader.GetDecimal("IGV") > 0)
                    {
                        n.Igv = true;
                    }
                    else
                    {
                        n.Igv = false;
                    }

                    lista.Add(n);
                }
                con.Close();
            }
            return(lista);
        }
Exemplo n.º 27
0
        public Insumo buscarInsumo(string id)
        {
            Insumo   p        = new Insumo();
            Conexion conexion = new Conexion();

            if (conexion.IsConnected())
            {
                MySqlCommand comando = new MySqlCommand();
                comando.CommandText = String.Format("SELECT * FROM PRODUCTO_GENERICO WHERE ID_PRODUCTO =  \"{0}\"", id);
                comando.Connection  = conexion.Connection;
                MySqlDataReader reader = comando.ExecuteReader();
                while (reader.Read())
                {
                    p.Id          = reader.GetInt32("ID_PRODUCTO").ToString();
                    p.Nombre      = reader.GetString("NOMBRE");
                    p.Precio      = reader.GetInt32("PRECIO");
                    p.Descripcion = reader.GetString("DESCRIPCION");
                    p.Color       = reader.GetString("COLOR");
                }
                conexion.Close();
            }
            return(p);
        }
Exemplo n.º 28
0
        public void actualizarClienteJuridico(Juridica c)
        {
            Conexion con = new Conexion();

            if (con.IsConnected())
            {
                MySqlCommand comando = new MySqlCommand();
                comando.CommandType = System.Data.CommandType.StoredProcedure;
                comando.CommandText = "ACTUALIZAR_CLIENTE_JURIDICO";
                comando.Connection  = con.Connection;
                comando.Parameters.Add("_RAZON", MySqlDbType.VarChar).Value          = c.RazonSocial;
                comando.Parameters.Add("_RUC", MySqlDbType.VarChar).Value            = c.Ruc;
                comando.Parameters.Add("_NOMBRE", MySqlDbType.VarChar).Value         = c.Nombre;
                comando.Parameters.Add("_TELEFONO", MySqlDbType.VarChar).Value       = c.Telefono;
                comando.Parameters.Add("_EMAIL", MySqlDbType.VarChar).Value          = c.Email;
                comando.Parameters.Add("_DIRECCION", MySqlDbType.VarChar).Value      = c.Direccion;
                comando.Parameters.Add("_FECHA_ANIVERSARIO", MySqlDbType.Date).Value = c.FechaAniversario;
                comando.Parameters.Add("_ID_PERSONA", MySqlDbType.Int32).Value       = c.IdPersona;

                int check = comando.ExecuteNonQuery();
                con.Close();
            }
        }
Exemplo n.º 29
0
        public void actualizarClienteNatural(Natural c)
        {
            Conexion con = new Conexion();

            if (con.IsConnected())
            {
                MySqlCommand comando = new MySqlCommand();
                comando.CommandType = System.Data.CommandType.StoredProcedure;
                comando.CommandText = "ACTUALIZAR_CLIENTE_NATURAL";
                comando.Connection  = con.Connection;
                comando.Parameters.Add("_NOMBRE", MySqlDbType.VarChar).Value     = c.Nombre;
                comando.Parameters.Add("_DNI", MySqlDbType.VarChar).Value        = c.Dni;
                comando.Parameters.Add("_AP_PATERNO", MySqlDbType.VarChar).Value = c.ApPat;
                comando.Parameters.Add("_AP_MATERNO", MySqlDbType.VarChar).Value = c.ApMat;
                comando.Parameters.Add("_SEXO", MySqlDbType.VarChar).Value       = c.Sexo;
                comando.Parameters.Add("_FECHA_NAC", MySqlDbType.Date).Value     = c.FechaNac;
                comando.Parameters.Add("_TELEFONO", MySqlDbType.VarChar).Value   = c.Telefono;
                comando.Parameters.Add("_EMAIL", MySqlDbType.VarChar).Value      = c.Email;
                comando.Parameters.Add("_DIRECCION", MySqlDbType.VarChar).Value  = c.Direccion;
                comando.Parameters.Add("_ID_PERSONA", MySqlDbType.Int32).Value   = Convert.ToInt32(c.IdPersona);
                comando.ExecuteNonQuery();
                con.Close();
            }
        }
Exemplo n.º 30
0
        public Persona buscarCliente(string id)
        {
            Conexion conexion = new Conexion();

            if (conexion.IsConnected())
            {
                MySqlCommand comando = new MySqlCommand();
                comando.CommandText = String.Format("SELECT * FROM PERSONA_NATURAL WHERE PERSONA_NATURAL.ID_PERSONA = {0}", id);
                comando.Connection  = conexion.Connection;

                int nfilas1 = 0;
                try
                {
                    nfilas1 = int.Parse(comando.ExecuteScalar().ToString());
                }
                catch (Exception)
                {
                }

                int nfilas2 = 0;

                comando.CommandText = String.Format("SELECT * FROM PERSONA_JURIDICA WHERE ID_PERSONA = {0}", id);
                try
                {
                    nfilas2 = int.Parse(comando.ExecuteScalar().ToString());
                }
                catch (Exception)
                {
                }

                if (nfilas2 > nfilas1)
                {
                    Juridica j = new Juridica();
                    comando.CommandText = String.Format("SELECT * FROM PERSONA_JURIDICA INNER JOIN PERSONA WHERE PERSONA_JURIDICA.ID_PERSONA = {0}", id);
                    MySqlDataReader reader = comando.ExecuteReader();

                    while (reader.Read())
                    {
                        j.Nombre   = reader.GetString("NOMBRE");
                        j.Email    = reader.GetString("EMAIL");
                        j.Telefono = reader.GetString("TELEFONO");
                    }
                    conexion.Close();
                    return(j);
                }
                else if (nfilas2 < nfilas1)
                {
                    Natural n = new Natural();
                    comando.CommandText = String.Format("SELECT * FROM PERSONA_NATURAL INNER JOIN PERSONA WHERE PERSONA_NATURAL.ID_PERSONA = {0}", id);
                    MySqlDataReader reader = comando.ExecuteReader();

                    while (reader.Read())
                    {
                        n.Nombre   = reader.GetString("NOMBRE");
                        n.ApPat    = reader.GetString("AP_PATERNO");
                        n.ApMat    = reader.GetString("AP_MATERNO");
                        n.Email    = reader.GetString("EMAIL");
                        n.Telefono = reader.GetString("TELEFONO");
                    }
                    conexion.Close();
                    return(n);
                }
                else
                {
                    Console.WriteLine("caroxdaniela");
                }
            }
            return(null);
        }