private void frmTiempoRespuestaIncidencia_Load(object sender, EventArgs e)
        {
            SqlConnection Connection2 = UsoBD.ConectaBD(Utileria.GetConnectionString());

            if (Connection2 == null)
            {
                MessageBox.Show("ERROR DE CONEXIÓN CON LA BASE DE DATOS");

                foreach (SqlError E in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(E.Message);
                }

                return;
            }

            SqlDataReader Lector2 = null;
            string        ID = "", DE = "", TI = "", PR = "", FE = "";
            string        strComandoC2 = "SELECT I.ID,I.Descripcion,T.Descripcion,P.Descripcion, I.FechaInicio, I.Tiempo_Respuesta, I.ID_Stat FROM INCIDENCIA I INNER JOIN PRIORIDAD P ON I.ID_Prioridad=P.ID INNER JOIN TIPO_INCIDENCIA T ON I.ID_Tipo=T.ID WHERE I.ID_Tecnico=" + TecID;

            Lector2 = UsoBD.Consulta(strComandoC2, Connection2);

            if (Lector2 == null)
            {
                MessageBox.Show("ERROR AL HACER LA CONSULTA");
                foreach (SqlError E in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(E.Message);
                }

                Connection2.Close();
                return;
            }
            if (Lector2.HasRows)
            {
                while (Lector2.Read())
                {
                    if (Utileria.IsEmpty(Lector2.GetValue(5).ToString()))
                    {
                        if (Lector2.GetValue(6).ToString() != "1" && Lector2.GetValue(5).ToString() != "5")
                        {
                            ID = Lector2.GetValue(0).ToString();
                            DE = Lector2.GetValue(1).ToString();
                            TI = Lector2.GetValue(2).ToString();
                            PR = Lector2.GetValue(3).ToString();
                            FE = Lector2.GetValue(4).ToString();

                            ListViewItem Registro = new ListViewItem(ID);
                            Registro.SubItems.Add(DE);
                            Registro.SubItems.Add(TI);
                            Registro.SubItems.Add(PR);
                            Registro.SubItems.Add(FE);

                            lvIndicencias.Items.Add(Registro);
                        }
                    }
                }
            }
            Connection2.Close();
        }
Ejemplo n.º 2
0
        public bool AgregarDetalle(int ClaveFact, int ClaveArt, int Cant)
        {
            string        strConexion = Rutinas.GetConnectionString();
            SqlConnection Con         = UsoBD.ConectaBD(strConexion);

            if (Con == null)
            {
                MessageBox.Show("NO SE PUDO CONECTAR A LA BASE DE DATOS");

                foreach (SqlError E in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(E.Message);
                }
                return(false);
            }
            SqlDataReader Lector = null;

            string strComandoC = "exec InsertarDetalleFactura " + ClaveFact + "," + ClaveArt + "," + Cant;

            Lector = UsoBD.Consulta(strComandoC, Con);
            if (Lector == null)
            {
                MessageBox.Show("ERROR AL HACER LA CONSULTA");
                foreach (SqlError E in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(E.Message);
                }

                Con.Close();
                return(false);
            }
            Con.Close();
            return(false);
        }
Ejemplo n.º 3
0
        public bool validaUsuario(string nombre)
        {
            bool          encontro = false;
            String        Conexion = Utileria.GetConnectionString();
            SqlConnection Conecta  = UsoBD.ConectaBD(Conexion);

            if (Conecta == null)
            {
                MessageBox.Show("NO SE PUDO CONECTAR A LA BASE DE DATOS", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                foreach (SqlError Error in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(Error.Message);
                }
                Conecta.Close();
            }
            string        Query  = "SELECT USUARIO FROM ADMINISTRADOR WHERE USUARIO = " + "'" + nombre + "'";
            SqlDataReader Lector = null;

            Lector = UsoBD.Consulta(Query, Conecta);
            if (Lector == null)
            {
                MessageBox.Show("ERROR AL REALIZAR LA CONSULTA");
                foreach (SqlError Error in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(Error.Message);
                }
                Conecta.Close();
            }
            if (Lector.HasRows)
            {
                encontro = true;
            }
            Conecta.Close();
            return(encontro);
        }
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            if (lvDetalleFactura.SelectedItems.Count == 0)
            {
                MessageBox.Show("NO HA SELECCIONADO NINGUN DETALLE DE FACTURA", "SIN SELECCIONAR", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            DialogResult R = MessageBox.Show("¿DESEA ELIMINAR EL DETALLE SELECCIONADO?", "CONFIRMAR", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (R == DialogResult.Yes)
            {
                string Fac, Art, Cant, Pre;
                for (int i = 0; i < lvDetalleFactura.Items.Count; i++)
                {
                    if (lvDetalleFactura.SelectedItems.Contains(lvDetalleFactura.Items[i]))
                    {
                        Fac  = lvDetalleFactura.Items[i].SubItems[0].Text;
                        Art  = lvDetalleFactura.Items[i].SubItems[1].Text;
                        Cant = lvDetalleFactura.Items[i].SubItems[3].Text;
                        Pre  = lvDetalleFactura.Items[i].SubItems[4].Text;

                        string        strConexion = Rutinas.GetConnectionString();
                        SqlConnection Con         = UsoBD.ConectaBD(strConexion);

                        if (Con == null)
                        {
                            MessageBox.Show("NO SE PUDO CONECTAR A LA BASE DE DATOS");

                            foreach (SqlError E in UsoBD.ESalida.Errors)
                            {
                                MessageBox.Show(E.Message);
                            }
                            return;
                        }
                        SqlDataReader Lector = null;

                        string strComandoC = "EXEC EliminaDetalleFactura " + Fac + "," + Art + "," + Cant + "," + Pre;

                        Lector = UsoBD.Consulta(strComandoC, Con);
                        if (Lector == null)
                        {
                            MessageBox.Show("ERROR AL HACER LA CONSULTA");
                            foreach (SqlError E in UsoBD.ESalida.Errors)
                            {
                                MessageBox.Show(E.Message);
                            }

                            Con.Close();
                            return;
                        }
                        Con.Close();
                        lvDetalleFactura.Items[i].Remove();
                        MessageBox.Show("LA ELIMINACION DEL DETALLE DE FACTURA SE HA REALIZADO CORRECTAMENTE", "ELIMINACION REALIZADA", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                }
            }
        }
Ejemplo n.º 5
0
        private void cmbDepartamentos_SelectedIndexChanged(object sender, EventArgs e)
        {
            SqlConnection conn = UsoBD.ConectaBD(ConexionBD.strCon);

            if (conn == null)
            {
                MessageBox.Show("Imposible conectar con la BD");
                foreach (SqlError err in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(err.Message);
                }
                return;
            }
            else
            {
                string strCommando = "SELECT emp_id, emp_nom, emp_apar, emp_amar, emp_dom, emp_sueldoD, bon_total, departamento FROM EMPLEADOS" +
                                     " inner join BONOS on EMPLEADOS.emp_id=BONOS.empleado";
                SqlDataReader lector = null;
                try
                {
                    lector = UsoBD.Consulta(strCommando, conn);
                }
                catch (SqlException ex)
                {
                    MessageBox.Show("Error al realizar consulta");
                    foreach (SqlError err in ex.Errors)
                    {
                        MessageBox.Show(err.Message);
                    }
                    conn.Close();
                    return;
                }
                if (lector.HasRows)
                {
                    while (lector.Read())
                    {
                        string dep = lector.GetValue(7).ToString();
                        if (cmbDepartamentos.SelectedItem.ToString() == dep)
                        {
                            DataGridViewRow fila = new DataGridViewRow();
                            fila.CreateCells(dataGridViewNomina);
                            fila.Cells[0].Value = lector.GetValue(0).ToString();
                            fila.Cells[1].Value = lector.GetValue(1).ToString();
                            fila.Cells[2].Value = lector.GetValue(2).ToString();
                            fila.Cells[3].Value = lector.GetValue(3).ToString();
                            fila.Cells[4].Value = lector.GetValue(4).ToString();
                            fila.Cells[5].Value = lector.GetValue(5).ToString();
                            fila.Cells[6].Value = lector.GetValue(6).ToString();


                            dataGridViewNomina.Rows.Add(fila);
                        }
                    }
                }
                conn.Close();
            }
        }
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            DialogResult Result = MessageBox.Show("¿DESEA AGREGAR ESTE ELEMENTO?", "PREGUNTA", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (Result == DialogResult.No)
            {
                return;
            }

            int IDCI = 0;

            if (Utileria.IsEmpty(txtDescripcion.Text))
            {
                MessageBox.Show("NO SE ACEPTAN CAMPOS VACIOS EN LA DESCRIPCION", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            SqlConnection Connection = UsoBD.ConectaBD(Utileria.GetConnectionString());

            if (Connection == null)
            {
                MessageBox.Show("ERROR DE CONEXIÓN CON LA BASE DE DATOS");

                foreach (SqlError E in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(E.Message);
                }
                return;
            }

            SqlDataReader Lector      = null;
            string        strComandoC = "SELECT ID FROM CI WHERE NumSerie LIKE '" + lbl.Text + "'";

            Lector = UsoBD.Consulta(strComandoC, Connection);

            if (Lector == null)
            {
                MessageBox.Show("ERROR AL HACER LA CONSULTA");
                foreach (SqlError E in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(E.Message);
                }

                Connection.Close();
                return;
            }
            if (Lector.HasRows)
            {
                while (Lector.Read())
                {
                    IDCI = Convert.ToInt32(Lector.GetValue(0).ToString());
                }
            }
            Connection.Close();
            AdmIn.AddInCI(txtDescripcion.Text, maskDate.Text, IDCI, Tipo, IDEmp);
        }
        private void cmbArticulos_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cmbArticulos.SelectedIndex == 0)
            {
                lblDescripcion.Text = "";
                lblMarca.Text       = "";
                lblPrecio.Text      = "";
                lblCantidad.Text    = "";
            }
            else
            {
                string strConexion = Rutinas.GetConnectionString();

                SqlConnection Con = UsoBD.ConectaBD(strConexion);
                if (Con == null)
                {
                    MessageBox.Show("NO SE PUDO CONECTAR A LA BASE DE DATOS");

                    foreach (SqlError E in UsoBD.ESalida.Errors)
                    {
                        MessageBox.Show(E.Message);
                    }
                    return;
                }
                SqlDataReader Lector = null;

                string Desc = cmbArticulos.SelectedItem.ToString();

                string strComando = "SELECT Descripcion,Marca,Precio,Cantidad FROM Articulo WHERE Descripcion LIKE'" + Desc + "'";

                Lector = UsoBD.Consulta(strComando, Con);

                if (Lector == null)
                {
                    MessageBox.Show("ERROR AL HACER LA CONSULTA");
                    foreach (SqlError E in UsoBD.ESalida.Errors)
                    {
                        MessageBox.Show(E.Message);
                    }

                    Con.Close();
                    return;
                }
                if (Lector.HasRows)
                {
                    while (Lector.Read())
                    {
                        lblDescripcion.Text = Lector.GetValue(0).ToString();
                        lblMarca.Text       = Lector.GetValue(1).ToString();
                        lblPrecio.Text      = Lector.GetValue(2).ToString();
                        lblCantidad.Text    = Lector.GetValue(3).ToString();
                    }
                }
                Con.Close();
            }
        }
        private void frmBajaEmpleado_Load(object sender, EventArgs e)
        {
            SqlConnection Connection = UsoBD.ConectaBD(Utileria.GetConnectionString());

            if (Connection == null)
            {
                MessageBox.Show("ERROR DE CONEXIÓN CON LA BASE DE DATOS");

                foreach (SqlError E in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(E.Message);
                }

                return;
            }

            SqlDataReader Lector = null;
            string        NA = "", EM = "", CE = "", DI = "", RO = "";
            string        strComandoC = "SELECT E.Nombre,Email,Celular,Direccion,R.Nombre FROM EMPLEADO E INNER JOIN ROL R ON E.ID_Rol=R.ID WHERE Estatus=1";

            Lector = UsoBD.Consulta(strComandoC, Connection);

            if (Lector == null)
            {
                MessageBox.Show("ERROR AL HACER LA CONSULTA");
                foreach (SqlError E in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(E.Message);
                }

                Connection.Close();
                return;
            }
            if (Lector.HasRows)
            {
                while (Lector.Read())
                {
                    NA = Lector.GetValue(0).ToString();
                    EM = Lector.GetValue(1).ToString();
                    CE = Lector.GetValue(2).ToString();
                    DI = Lector.GetValue(3).ToString();
                    RO = Lector.GetValue(3).ToString();

                    ListViewItem Registro = new ListViewItem(NA);
                    Registro.SubItems.Add(EM);
                    Registro.SubItems.Add(CE);
                    Registro.SubItems.Add(DI);
                    Registro.SubItems.Add(RO);

                    lvEmpleados.Items.Add(Registro);
                }
            }
            Connection.Close();
        }
Ejemplo n.º 9
0
        private void cmbClaveFactura_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cmbClaveFactura.SelectedIndex < 0)
            {
                return;
            }
            string        claveFactura = cmbClaveFactura.SelectedItem.ToString();
            string        strConexion  = Rutinas.GetConnectionString();
            SqlConnection Con          = UsoBD.ConectaBD(strConexion);

            if (Con == null)
            {
                MessageBox.Show("NO SE PUDO CONECTAR A LA BASE DE DATOS");

                foreach (SqlError E in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(E.Message);
                }
                return;
            }

            SqlDataReader Lector = null;

            string strComando = "select p.clave,p.Nombre,f.monto,format(f.fecha,'dd/MM/yyyy') from Factura f inner join Proveedor p on f.provedor=p.Clave where f.clave =" + claveFactura;

            Lector = UsoBD.Consulta(strComando, Con);

            if (Lector == null)
            {
                MessageBox.Show("ERROR AL HACER LA CONSULTA");
                foreach (SqlError E in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(E.Message);
                }

                Con.Close();
                return;
            }
            if (Lector.HasRows)
            {
                while (Lector.Read())
                {
                    txtClaveProveedor.Text = Lector.GetValue(0).ToString();
                    txtProveedor.Text      = Lector.GetValue(1).ToString();
                    txtImporte.Text        = Lector.GetValue(2).ToString();
                    txtFecha.Text          = Lector.GetValue(3).ToString();
                }
            }
            Con.Close();
            int factura = int.Parse(claveFactura);

            txtCantDetalles.Text = String.Format("" + mD.DetallesPorFactura(factura));
        }
Ejemplo n.º 10
0
        private void frmConsultaDias_Load(object sender, EventArgs e)
        {
            SqlConnection conn = UsoBD.ConectaBD(ConexionBD.strCon);

            if (conn == null)
            {
                MessageBox.Show("Imposible conectar con la BD");
                foreach (SqlError err in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(err.Message);
                }
                return;
            }
            else
            {
                string strCommando = "SELECT emp_id, emp_nom, emp_apar, emp_amar, departamento, dias_Cantidad FROM EMPLEADOS " +
                                     "inner join EMPLEADO_DIAS on EMPLEADOS.emp_id=EMPLEADO_DIAS.emp_id " +
                                     "inner join DIAS on DIAS.dias_id=EMPLEADO_DIAS.dias_id";
                SqlDataReader lector = null;
                try
                {
                    lector = UsoBD.Consulta(strCommando, conn);
                }
                catch (SqlException ex)
                {
                    MessageBox.Show("Error al realizar consulta");
                    foreach (SqlError err in ex.Errors)
                    {
                        MessageBox.Show(err.Message);
                    }
                    conn.Close();
                    return;
                }
                if (lector.HasRows)
                {
                    while (lector.Read())
                    {
                        DataGridViewRow fila = new DataGridViewRow();
                        fila.CreateCells(dataGridViewNomina);
                        fila.Cells[0].Value = lector.GetValue(0).ToString();
                        fila.Cells[1].Value = lector.GetValue(1).ToString();
                        fila.Cells[2].Value = lector.GetValue(2).ToString();
                        fila.Cells[3].Value = lector.GetValue(3).ToString();
                        fila.Cells[4].Value = lector.GetValue(4).ToString();
                        fila.Cells[5].Value = lector.GetValue(5).ToString();


                        dataGridViewNomina.Rows.Add(fila);
                    }
                }
                conn.Close();
            }
        }
        private void btnAprobar_Click(object sender, EventArgs e)
        {
            if (lvIndicencias.SelectedItems.Count == 0)
            {
                MessageBox.Show("NO HA SELECCIONADO NINGUNA INCIDENCIA", "SIN SELECCIONAR", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            else
            {
                int PrioID = 0, Stat = 3;

                SqlConnection Connection  = UsoBD.ConectaBD(Utileria.GetConnectionString());

                if (Connection == null)
                {
                    MessageBox.Show("ERROR DE CONEXIÓN CON LA BASE DE DATOS");

                    foreach (SqlError E in UsoBD.ESalida.Errors)
                    {
                        MessageBox.Show(E.Message);
                    }

                    return;
                }
                SqlDataReader Lector      = null;
                string        strComandoC = "SELECT ID FROM PRIORIDAD WHERE Descripcion LIKE '" + cmbPrioridad.SelectedItem.ToString() + "'";

                Lector = UsoBD.Consulta(strComandoC, Connection);
                if (Lector == null)
                {
                    MessageBox.Show("ERROR AL HACER LA CONSULTA");
                    foreach (SqlError E in UsoBD.ESalida.Errors)
                    {
                        MessageBox.Show(E.Message);
                    }

                    Connection.Close();
                    return;
                }
                if (Lector.HasRows)
                {
                    while (Lector.Read())
                    {
                        PrioID = Convert.ToInt32(Lector.GetValue(0).ToString());
                    }
                }
                Connection.Close();

                AdmIn.UpdatePrioridad(InID, PrioID);
                AdmIn.UpdateStatus(InID, Stat);
                MessageBox.Show("INCIDENCIA APROBADA EXITOSAMENTE", "AVISO", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        private void frmConsultarConlcuidasTecnico_Load(object sender, EventArgs e)
        {
            string        Conexion = Utileria.GetConnectionString();
            SqlConnection Conecta  = UsoBD.ConectaBD(Conexion);

            if (Conecta == null)
            {
                MessageBox.Show("NO SE PUDO CONECTAR A LA BASE DE DATOS", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                foreach (SqlError Error in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(Error.Message);
                }
                Conecta.Close();
                return;
            }
            string        Query  = "SELECT * FROM VW_IncidenciasConcluidas WHERE  SOLUCIONADO_POR= " + "'" + usuario + "'";
            SqlDataReader Lector = null;

            Lector = UsoBD.Consulta(Query, Conecta);
            if (Lector == null)
            {
                MessageBox.Show("ERROR AL REALIZAR CONSULTA");
                foreach (SqlError Error in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(Error.Message);
                }
                Conecta.Close();
                return;
            }
            if (Lector.HasRows)
            {
                dgvIncidencias.Rows.Clear();
                while (Lector.Read())
                {
                    string ID           = Lector.GetValue(0).ToString();
                    string Dispositivo  = Lector.GetValue(1).ToString();
                    string Marca        = Lector.GetValue(2).ToString();
                    string Modelo       = Lector.GetValue(3).ToString();
                    string Ubicado      = Lector.GetValue(4).ToString();
                    string Incidencia   = Lector.GetValue(5).ToString();
                    string Reporto      = Lector.GetValue(6).ToString();
                    string FechaRep     = Lector.GetValue(7).ToString();
                    string FechaSol     = Lector.GetValue(8).ToString();
                    string Estatus      = Lector.GetValue(9).ToString();
                    string Soluciono    = Lector.GetValue(10).ToString();
                    string tipoSolucion = Lector.GetValue(11).ToString();

                    dgvIncidencias.Rows.Add(ID, Dispositivo, Marca, Modelo, Ubicado, Incidencia, Reporto, FechaRep, FechaSol, Estatus, Soluciono, tipoSolucion);
                }
            }
            Conecta.Close();
        }
        private void frmVerProblemasConocidos_Load(object sender, EventArgs e)
        {
            SqlConnection Connection2 = UsoBD.ConectaBD(Utileria.GetConnectionString());

            if (Connection2 == null)
            {
                MessageBox.Show("ERROR DE CONEXIÓN CON LA BASE DE DATOS");

                foreach (SqlError E in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(E.Message);
                }

                return;
            }

            SqlDataReader Lector2 = null;
            string        ID = "", DE = "", SO = "", TM = "";
            string        strComandoC2 = "SELECT * FROM PROBLEMAS_CONOCIDOS";

            Lector2 = UsoBD.Consulta(strComandoC2, Connection2);

            if (Lector2 == null)
            {
                MessageBox.Show("ERROR AL HACER LA CONSULTA");
                foreach (SqlError E in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(E.Message);
                }

                Connection2.Close();
                return;
            }
            if (Lector2.HasRows)
            {
                while (Lector2.Read())
                {
                    ID = Lector2.GetValue(0).ToString();
                    DE = Lector2.GetValue(1).ToString();
                    SO = Lector2.GetValue(2).ToString();
                    TM = Lector2.GetValue(3).ToString();

                    ListViewItem Registro = new ListViewItem(ID);
                    Registro.SubItems.Add(DE);
                    Registro.SubItems.Add(SO);
                    Registro.SubItems.Add(TM);

                    lvInci.Items.Add(Registro);
                }
            }
            Connection2.Close();
        }
        private void cmbIncidencias_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cmbIncidencias.SelectedIndex == -1)
            {
                return;
            }

            string ID = cmbIncidencias.SelectedItem.ToString();

            string        Conexion = Utileria.GetConnectionString();
            SqlConnection Conecta  = UsoBD.ConectaBD(Conexion);

            if (Conecta == null)
            {
                MessageBox.Show("NO SE PUDO CONECTAR A LA BASE DE DATOS", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                foreach (SqlError Error in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(Error.Message);
                }
                Conecta.Close();
                return;
            }
            string        Query  = "SELECT * FROM VW_Incidencias WHERE ID = " + "'" + ID + "'";
            SqlDataReader Lector = null;

            Lector = UsoBD.Consulta(Query, Conecta);
            if (Lector == null)
            {
                MessageBox.Show("ERROR AL REALIZAR CONSULTA");
                foreach (SqlError Error in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(Error.Message);
                }
                Conecta.Close();
                return;
            }
            if (Lector.HasRows)
            {
                while (Lector.Read())
                {
                    txtDispositivo.Text = Lector.GetValue(1).ToString();
                    txtMarca.Text       = Lector.GetValue(2).ToString();
                    txtModelo.Text      = Lector.GetValue(3).ToString();
                    txtUbicado.Text     = Lector.GetValue(4).ToString();
                    txtIncidencia.Text  = Lector.GetValue(5).ToString();
                    txtReporto.Text     = Lector.GetValue(6).ToString();
                    txtFecha.Text       = Lector.GetValue(7).ToString();
                    txtEstatus.Text     = Lector.GetValue(8).ToString();
                }
            }
            Conecta.Close();
        }
        private void cmbArticulo_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cmbArticulo.SelectedIndex < 0)
            {
                return;
            }
            string descripcion = cmbArticulo.SelectedItem.ToString();

            string        strConexion = Rutinas.GetConnectionString();
            SqlConnection Con         = UsoBD.ConectaBD(strConexion);

            if (Con == null)
            {
                MessageBox.Show("NO SE PUDO CONECTAR A LA BASE DE DATOS");

                foreach (SqlError E in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(E.Message);
                }
                return;
            }

            SqlDataReader Lector = null;

            string strComando = "SELECT * from articulo where descripcion = '" + descripcion + "'";

            Lector = UsoBD.Consulta(strComando, Con);

            if (Lector == null)
            {
                MessageBox.Show("ERROR AL HACER LA CONSULTA");
                foreach (SqlError E in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(E.Message);
                }

                Con.Close();
                return;
            }
            if (Lector.HasRows)
            {
                while (Lector.Read())
                {
                    txtClaveArt.Text   = Lector.GetValue(0).ToString();
                    txtPrecio.Text     = Lector.GetValue(3).ToString();
                    txtExistencia.Text = Lector.GetValue(4).ToString();
                    Con.Close();
                    return;
                }
            }
            Con.Close();
        }
Ejemplo n.º 16
0
        private void frmAutorizaCambios_Load(object sender, EventArgs e)
        {
            SqlConnection Connection2 = UsoBD.ConectaBD(Utileria.GetConnectionString());

            if (Connection2 == null)
            {
                MessageBox.Show("ERROR DE CONEXIÓN CON LA BASE DE DATOS");

                foreach (SqlError E in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(E.Message);
                }

                return;
            }

            SqlDataReader Lector2 = null;
            string        FE = "", IN = "", DE = "", ID = "";
            string        strComandoC2 = "SELECT C.ID,I.Descripcion,C.Descripcion,C.FechaSol FROM CAMBIOS C INNER JOIN INCIDENCIA I ON C.IDInc=I.ID WHERE C.Estatus=1 ORDER BY C.FechaSol ";

            Lector2 = UsoBD.Consulta(strComandoC2, Connection2);

            if (Lector2 == null)
            {
                MessageBox.Show("ERROR AL HACER LA CONSULTA");
                foreach (SqlError E in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(E.Message);
                }

                Connection2.Close();
                return;
            }
            if (Lector2.HasRows)
            {
                while (Lector2.Read())
                {
                    ID = Lector2.GetValue(0).ToString();
                    IN = Lector2.GetValue(1).ToString();
                    DE = Lector2.GetValue(2).ToString();
                    FE = Lector2.GetValue(3).ToString();

                    ListViewItem Registro = new ListViewItem(ID);
                    Registro.SubItems.Add(IN);
                    Registro.SubItems.Add(DE);
                    Registro.SubItems.Add(FE);

                    lvCam.Items.Add(Registro);
                }
            }
            Connection2.Close();
        }
        private void btnSelectTec_Click(object sender, EventArgs e)
        {
            int ID = 0;

            for (int i = 0; i < lvInci.Items.Count; i++)
            {
                if (lvInci.SelectedItems.Contains(lvInci.Items[i]))
                {
                    ID = Convert.ToInt32(lvInci.Items[i].SubItems[0].Text);

                    SqlConnection Connection = UsoBD.ConectaBD(Utileria.GetConnectionString());

                    if (Connection == null)
                    {
                        MessageBox.Show("ERROR DE CONEXIÓN CON LA BASE DE DATOS");

                        foreach (SqlError E in UsoBD.ESalida.Errors)
                        {
                            MessageBox.Show(E.Message);
                        }

                        return;
                    }
                    SqlDataReader Lector      = null;
                    string        strComandoC = "SELECT Descripcion,Solucion,Tiempo FROM PROBLEMAS_CONOCIDOS WHERE ID=" + ID;

                    Lector = UsoBD.Consulta(strComandoC, Connection);
                    if (Lector == null)
                    {
                        MessageBox.Show("ERROR AL HACER LA CONSULTA");
                        foreach (SqlError E in UsoBD.ESalida.Errors)
                        {
                            MessageBox.Show(E.Message);
                        }

                        Connection.Close();
                        return;
                    }
                    if (Lector.HasRows)
                    {
                        while (Lector.Read())
                        {
                            txtDesc.Text = Lector.GetValue(0).ToString();
                            txtSol.Text  = Lector.GetValue(1).ToString();
                            txtTime.Text = Lector.GetValue(2).ToString();
                        }
                    }
                    Connection.Close();
                }
            }
        }
        private void cmbNombre_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cmbProveedores.SelectedIndex < 0)
            {
                return;
            }
            string        Conexion = Rutinas.GetConnectionString();
            SqlConnection Conecta  = UsoBD.ConectaBD(Conexion);

            if (Conecta == null)
            {
                MessageBox.Show("NO SE PUDO CONECTAR A LA BASE DE DATOS", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                foreach (SqlError Error in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(Error.Message);
                }
                Conecta.Close();
                return;
            }
            string        Nom    = cmbProveedores.SelectedItem.ToString();
            string        Query  = "select Clave,RFC,Domicilio,Saldo from Proveedor where Nombre = " + "'" + Nom + "'";
            SqlDataReader Lector = null;

            Lector = UsoBD.Consulta(Query, Conecta);
            if (Lector == null)
            {
                MessageBox.Show("ERROR AL REALIZAR CONSULTA");
                foreach (SqlError Error in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(Error.Message);
                }
                Conecta.Close();
                return;
            }
            if (Lector.HasRows)
            {
                while (Lector.Read())
                {
                    string Clave     = Lector.GetValue(0).ToString();
                    string RFC       = Lector.GetValue(1).ToString();
                    string Domicilio = Lector.GetValue(2).ToString();
                    string Saldo     = Lector.GetValue(3).ToString();

                    txtClave.Text     = Clave;
                    txtRFC.Text       = RFC;
                    txtDomicilio.Text = Domicilio;
                    txtSueldo.Text    = Saldo;
                }
            }
            Conecta.Close();
        }
        private void cmbDispositivos_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cmbDispositivos.SelectedIndex == -1)
            {
                return;
            }

            string        Conexion = Utileria.GetConnectionString();
            SqlConnection Conecta  = UsoBD.ConectaBD(Conexion);

            if (Conecta == null)
            {
                MessageBox.Show("NO SE PUDO CONECTAR A LA BASE DE DATOS", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                foreach (SqlError Error in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(Error.Message);
                }
                Conecta.Close();
                return;
            }
            string Numero_serie = cmbDispositivos.SelectedItem.ToString();
            string Query        = "SELECT M.NOMBRE,D.MODELO,D.DESCRIPCION,A.DESCRIPCION FROM DISPOSITIVO D";

            Query += " INNER JOIN MARCA M ON D.MARCA = M.ID";
            Query += " INNER JOIN AULA A ON A.ID = D.AULA";
            Query += " WHERE NUMERO_SERIE = '" + Numero_serie + "'";
            SqlDataReader Lector = null;

            Lector = UsoBD.Consulta(Query, Conecta);
            if (Lector == null)
            {
                MessageBox.Show("ERROR AL REALIZAR CONSULTA");
                foreach (SqlError Error in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(Error.Message);
                }
                Conecta.Close();
                return;
            }
            if (Lector.HasRows)
            {
                while (Lector.Read())
                {
                    txtMarca.Text  = Lector.GetValue(0).ToString();
                    txtModelo.Text = Lector.GetValue(1).ToString();
                    txtDescr.Text  = Lector.GetValue(2).ToString();
                    txtAula.Text   = Lector.GetValue(3).ToString();
                }
            }
            Conecta.Close();
        }
        private void frmActualizacionCI_Load(object sender, EventArgs e)
        {
            SqlConnection Connection = UsoBD.ConectaBD(Utileria.GetConnectionString());

            if (Connection == null)
            {
                MessageBox.Show("ERROR DE CONEXIÓN CON LA BASE DE DATOS");

                foreach (SqlError E in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(E.Message);
                }

                return;
            }

            SqlDataReader Lector = null;

            string strComando = "SELECT CI.IDCI,CI.Nombre,CI.Descripcion,CI.NumSerie,CI.FechaAdquisicion,E.Nombre,EM.Nombre,P.Nombre,CI.Estatus FROM CAMBIOS_CI CI INNER JOIN LOCALIZACION L ON CI.ID_Localizacion = L.ID INNER JOIN EDIFICIO E ON L.ID_Edificio = E.ID INNER JOIN EMPLEADO EM ON CI.ID_Encargado = EM.ID INNER JOIN PROVEEDOR P ON CI.ID_Proveedor = P.ID";

            Lector = UsoBD.Consulta(strComando, Connection);

            if (Lector == null)
            {
                MessageBox.Show("ERROR AL HACER LA CONSULTA");
                foreach (SqlError E in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(E.Message);
                }

                Connection.Close();
                return;
            }
            if (Lector.HasRows)
            {
                while (Lector.Read())
                {
                    string Estatus = "Activo";

                    if (Lector.GetValue(8).ToString() == "False")
                    {
                        Estatus = "Inactivo";
                    }

                    this.dgwCI.Rows.Add(Lector.GetValue(0).ToString(), Lector.GetValue(1).ToString(), Lector.GetValue(2).ToString(), Lector.GetValue(3).ToString(), Lector.GetValue(4).ToString(), Lector.GetValue(5).ToString(), Lector.GetValue(6).ToString(), Lector.GetValue(7).ToString(), Estatus);
                }
            }
            Connection.Close();
        }
        public int Count()
        {
            int           Count    = 0;
            string        Conexion = Rutinas.GetConnectionString();
            SqlConnection Conecta  = UsoBD.ConectaBD(Conexion);

            if (Conecta == null)
            {
                MessageBox.Show("NO SE PUDO CONECTAR A LA BASE DE DATOS", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                foreach (SqlError Error in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(Error.Message);
                }
                Conecta.Close();
                return(Count);
            }
            string        Query  = "select count(*) from Proveedor";
            SqlDataReader Lector = null;

            Lector = UsoBD.Consulta(Query, Conecta);
            if (Lector == null)
            {
                MessageBox.Show("ERROR AL REALIZAR CONSULTA");
                foreach (SqlError Error in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(Error.Message);
                }
                Conecta.Close();
                return(Count);
            }
            if (!Lector.HasRows)
            {
                Conecta.Close();
                return(Count);
            }
            while (Lector.Read())
            {
                try
                {
                    Count = Convert.ToInt32(Lector.GetValue(0));
                }
                catch (Exception Ex)
                {
                    MessageBox.Show("ERRORR AL CONVERTIR", "ERROR FORMATO", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(Count);
                }
            }
            return(Count);
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            string        Conexion = Utileria.GetConnectionString();
            SqlConnection Conecta  = UsoBD.ConectaBD(Conexion);

            if (Conecta == null)
            {
                MessageBox.Show("NO SE PUDO CONECTAR A LA BASE DE DATOS", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                foreach (SqlError Error in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(Error.Message);
                }
                Conecta.Close();
                return;
            }
            string        Query  = "SELECT ID_INCIDENCIA,ADMINISTRADOR,NUMERO_SERIE,MARCA,MODELO,AULA,FECHA,ESTATUS,TECNICO,DETALLE FROM VW_IncidenciasAsignadas";
            SqlDataReader Lector = null;

            Lector = UsoBD.Consulta(Query, Conecta);
            if (Lector == null)
            {
                MessageBox.Show("ERROR AL REALIZAR CONSULTA");
                foreach (SqlError Error in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(Error.Message);
                }
                Conecta.Close();
                return;
            }
            if (Lector.HasRows)
            {
                dgvIncidencias.Rows.Clear();
                while (Lector.Read())
                {
                    string ID          = Lector.GetValue(0).ToString();
                    string Admin       = Lector.GetValue(1).ToString();
                    string Dispositivo = Lector.GetValue(2).ToString();
                    string Marca       = Lector.GetValue(3).ToString();
                    string Modelo      = Lector.GetValue(4).ToString();
                    string Ubicado     = Lector.GetValue(5).ToString();
                    string Fecha       = Lector.GetValue(6).ToString();
                    string Estatus     = Lector.GetValue(7).ToString();
                    string Tecnico     = Lector.GetValue(8).ToString();
                    string Incidencia  = Lector.GetValue(9).ToString();
                    dgvIncidencias.Rows.Add(ID, Admin, Dispositivo, Marca, Modelo, Ubicado, Fecha, Estatus, Tecnico, Incidencia);
                }
            }
            Conecta.Close();
        }
        private void frmBajaDepartamento_Load(object sender, EventArgs e)
        {
            SqlConnection Connection = UsoBD.ConectaBD(Utileria.GetConnectionString());

            if (Connection == null)
            {
                MessageBox.Show("ERROR DE CONEXIÓN CON LA BASE DE DATOS");

                foreach (SqlError E in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(E.Message);
                }

                return;
            }

            SqlDataReader Lector = null;
            string        NA = "", EN = "";
            string        strComandoC = "SELECT D.Nombre,E.Nombre FROM DEPARTAMENTO D INNER JOIN EMPLEADO E ON D.ID_EmpEncar=E.ID AND D.Estatus=1";

            Lector = UsoBD.Consulta(strComandoC, Connection);

            if (Lector == null)
            {
                MessageBox.Show("ERROR AL HACER LA CONSULTA");
                foreach (SqlError E in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(E.Message);
                }

                Connection.Close();
                return;
            }
            if (Lector.HasRows)
            {
                while (Lector.Read())
                {
                    NA = Lector.GetValue(0).ToString();
                    EN = Lector.GetValue(1).ToString();

                    ListViewItem Registro = new ListViewItem(NA);
                    Registro.SubItems.Add(EN);

                    lvDepartamentos.Items.Add(Registro);
                }
            }
            Connection.Close();
        }
        private void frmConsultaIncidenciasJefe_Load(object sender, EventArgs e)
        {
            string        Conexion = Utileria.GetConnectionString();
            SqlConnection Conecta  = UsoBD.ConectaBD(Conexion);

            if (Conecta == null)
            {
                MessageBox.Show("NO SE PUDO CONECTAR A LA BASE DE DATOS", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                foreach (SqlError Error in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(Error.Message);
                }
                Conecta.Close();
                return;
            }
            string        Query  = "SELECT ID,DISPOSITIVO,MARCA,MODELO,UBICADO,INCIDENCIA,FECHA,ESTATUS FROM VW_Incidencias WHERE REPORTADO_POR = " + "'" + Usuario + "'";
            SqlDataReader Lector = null;

            Lector = UsoBD.Consulta(Query, Conecta);
            if (Lector == null)
            {
                MessageBox.Show("ERROR AL REALIZAR CONSULTA");
                foreach (SqlError Error in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(Error.Message);
                }
                Conecta.Close();
                return;
            }
            if (Lector.HasRows)
            {
                dgvIncidencias.Rows.Clear();
                while (Lector.Read())
                {
                    string ID          = Lector.GetValue(0).ToString();
                    string Dispositivo = Lector.GetValue(1).ToString();
                    string Marca       = Lector.GetValue(2).ToString();
                    string Modelo      = Lector.GetValue(3).ToString();
                    string Ubicado     = Lector.GetValue(4).ToString();
                    string Incidencia  = Lector.GetValue(5).ToString();
                    string Fecha       = Lector.GetValue(6).ToString();
                    string Estatus     = Lector.GetValue(7).ToString();

                    dgvIncidencias.Rows.Add(ID, Dispositivo, Marca, Modelo, Ubicado, Incidencia, Fecha, Estatus);
                }
            }
            Conecta.Close();
        }
        public int BuscarPosNombre(String nombre)
        {
            int           P        = -1;
            string        Conexion = Rutinas.GetConnectionString();
            SqlConnection Conecta  = UsoBD.ConectaBD(Conexion);

            if (Conecta == null)
            {
                MessageBox.Show("NO SE PUDO CONECTAR A LA BASE DE DATOS", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                foreach (SqlError Error in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(Error.Message);
                }
                Conecta.Close();
                return(P);
            }
            string        Query  = "select Clave from Proveedor where Nombre= " + "'" + nombre + "'";
            SqlDataReader Lector = null;

            Lector = UsoBD.Consulta(Query, Conecta);
            if (Lector == null)
            {
                MessageBox.Show("ERROR AL REALIZAR CONSULTA");
                foreach (SqlError Error in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(Error.Message);
                }
                Conecta.Close();
                return(P);
            }
            if (Lector.HasRows)
            {
                while (Lector.Read())
                {
                    try
                    {
                        P = int.Parse(Lector.GetValue(0).ToString());
                    }
                    catch (Exception Ex)
                    {
                        MessageBox.Show("ERRORR CONVIRTIENDO LA CLAVE", "ERROR FORMATO", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(P);
                    }
                }
            }
            return(P);
        }
        private void btnSelectTec_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < lvTecnicos.Items.Count; i++)
            {
                if (lvTecnicos.SelectedItems.Contains(lvTecnicos.Items[i]))
                {
                    txtTecnico.Text = lvTecnicos.Items[i].SubItems[0].Text;

                    SqlConnection Connection = UsoBD.ConectaBD(Utileria.GetConnectionString());

                    if (Connection == null)
                    {
                        MessageBox.Show("ERROR DE CONEXIÓN CON LA BASE DE DATOS");

                        foreach (SqlError E in UsoBD.ESalida.Errors)
                        {
                            MessageBox.Show(E.Message);
                        }

                        return;
                    }
                    SqlDataReader Lector      = null;
                    string        strComandoC = "SELECT ID FROM EMPLEADO WHERE Nombre LIKE '" + txtTecnico.Text.Trim() + "'";

                    Lector = UsoBD.Consulta(strComandoC, Connection);
                    if (Lector == null)
                    {
                        MessageBox.Show("ERROR AL HACER LA CONSULTA");
                        foreach (SqlError E in UsoBD.ESalida.Errors)
                        {
                            MessageBox.Show(E.Message);
                        }

                        Connection.Close();
                        return;
                    }
                    if (Lector.HasRows)
                    {
                        while (Lector.Read())
                        {
                            TecID = Convert.ToInt32(Lector.GetValue(0).ToString());
                        }
                    }
                    Connection.Close();
                }
            }
        }
        public bool BuscaRep(string Desc, string Marca)
        {
            string strConexion = Rutinas.GetConnectionString();

            SqlConnection Con = UsoBD.ConectaBD(strConexion);

            if (Con == null)
            {
                MessageBox.Show("NO SE PUDO CONECTAR A LA BASE DE DATOS");

                foreach (SqlError E in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(E.Message);
                }
                return(false);
            }
            SqlDataReader Lector = null;

            string strComandoC = "SELECT COUNT(Clave) FROM Articulo WHERE Descripcion LIKE'" + Desc + "' AND Marca LIKE'" + Marca + "'";

            Lector = UsoBD.Consulta(strComandoC, Con);

            if (Lector == null)
            {
                MessageBox.Show("ERROR AL HACER LA CONSULTA");
                foreach (SqlError E in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(E.Message);
                }

                Con.Close();
                return(false);
            }
            if (Lector.HasRows)
            {
                while (Lector.Read())
                {
                    if (Convert.ToInt32(Lector.GetValue(0).ToString()) > 0)
                    {
                        Con.Close();
                        return(true);
                    }
                }
            }
            Con.Close();
            return(false);
        }
Ejemplo n.º 28
0
        private void frmConsultaEncargados_Load(object sender, EventArgs e)
        {
            SqlConnection conn = UsoBD.ConectaBD(ConexionBD.strCon);

            if (conn == null)
            {
                MessageBox.Show("Imposible conectar con la BD");
                foreach (SqlError err in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(err.Message);
                }
                return;
            }
            else
            {
                string        strCommando = "SELECT dep_id, dep_nombre FROM DEPARTAMENTOS";
                SqlDataReader lector      = null;
                try
                {
                    lector = UsoBD.Consulta(strCommando, conn);
                }
                catch (SqlException ex)
                {
                    MessageBox.Show("Error al realizar consulta");
                    foreach (SqlError err in ex.Errors)
                    {
                        MessageBox.Show(err.Message);
                    }
                    conn.Close();
                    return;
                }
                if (lector.HasRows)
                {
                    while (lector.Read())
                    {
                        DataGridViewRow fila = new DataGridViewRow();
                        fila.CreateCells(dataGridViewNomina);
                        fila.Cells[0].Value = lector.GetValue(0).ToString();
                        fila.Cells[1].Value = lector.GetValue(1).ToString();
                        fila.Cells[2].Value = lector.GetValue(2).ToString();

                        dataGridViewNomina.Rows.Add(fila);
                    }
                }
                conn.Close();
            }
        }
Ejemplo n.º 29
0
        public void cargarDataGridViewFacturas()
        {
            dtgvFacturas.Rows.Clear();
            string        nombre      = cmbProveedores.SelectedItem.ToString();
            string        strConexion = Rutinas.GetConnectionString();
            SqlConnection Con         = UsoBD.ConectaBD(strConexion);

            if (Con == null)
            {
                MessageBox.Show("NO SE PUDO CONECTAR A LA BASE DE DATOS");

                foreach (SqlError E in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(E.Message);
                }
                return;
            }

            SqlDataReader Lector = null;

            string strComando = "select f.clave,p.clave,p.Nombre,f.monto,format(f.fecha,'dd/MM/yyyy') from Factura f inner join Proveedor p on f.provedor=p.Clave where p.Nombre ='" + nombre + "'";

            Lector = UsoBD.Consulta(strComando, Con);

            if (Lector == null)
            {
                MessageBox.Show("ERROR AL HACER LA CONSULTA");
                foreach (SqlError E in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(E.Message);
                }

                Con.Close();
                return;
            }
            int clave = 0;

            if (Lector.HasRows)
            {
                while (Lector.Read())
                {
                    clave = int.Parse(Lector.GetValue(1).ToString());
                    dtgvFacturas.Rows.Add(Lector.GetValue(0).ToString(), Lector.GetValue(1).ToString(), Lector.GetValue(2).ToString(), Lector.GetValue(3).ToString(), Lector.GetValue(4).ToString());
                }
            }
            Con.Close();
        }
        private void frmConsultaDispositivoCambios_Load(object sender, EventArgs e)
        {
            string        Conexion = Utileria.GetConnectionString();
            SqlConnection Conecta  = UsoBD.ConectaBD(Conexion);

            if (Conecta == null)
            {
                MessageBox.Show("NO SE PUDO CONECTAR A LA BASE DE DATOS", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                foreach (SqlError Error in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(Error.Message);
                }
                Conecta.Close();
                return;
            }
            string        Query  = "SELECT * FROM VW_CambiosComponentes";
            SqlDataReader Lector = null;

            Lector = UsoBD.Consulta(Query, Conecta);
            if (Lector == null)
            {
                MessageBox.Show("ERROR AL REALIZAR CONSULTA");
                foreach (SqlError Error in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(Error.Message);
                }
                Conecta.Close();
                return;
            }
            if (Lector.HasRows)
            {
                dgvIncidencias.Rows.Clear();
                while (Lector.Read())
                {
                    String aprobado = Lector.GetValue(6).ToString();
                    if (aprobado == "true")
                    {
                        aprobado = "SI";
                    }
                    else
                    {
                        aprobado = "NO";
                    }
                    dgvIncidencias.Rows.Add(Lector.GetValue(1).ToString(), Lector.GetValue(2).ToString(), Lector.GetValue(3).ToString(), Lector.GetValue(4).ToString(), Lector.GetValue(5).ToString(), aprobado);
                }
            }
        }