예제 #1
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);
        }
        public static bool finalizarIncidenciaTecnico(int ID, DateTime fecha, String Tecnico)
        {
            SqlConnection connection = UsoBD.ConectaBD(Utileria.GetConnectionString());

            if (connection == null)
            {
                foreach (SqlError item in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(item.Message);
                }
            }
            string command = "INSERT INTO INCIDENCIA_CONCLUIDA (ID_INCIDENCIA,FECHA_SOLUCION, SOLUCIONADO_POR)";

            command += " VALUES(@ID, @fecha, @Tecnico)";
            SqlCommand comandoInsersion = new SqlCommand(command, connection);

            comandoInsersion.Parameters.AddWithValue("@ID", ID);
            comandoInsersion.Parameters.AddWithValue("@fecha", fecha);
            comandoInsersion.Parameters.AddWithValue("@Tecnico", Tecnico);
            ActualizarStatusIncidenciaFin(ID);
            try
            {
                comandoInsersion.ExecuteNonQuery();
            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.Message);
                connection.Close();
                return(false);
            }
            connection.Close();
            MessageBox.Show("FINALIZADA EXITOSAMENTE", "Finalización", MessageBoxButtons.OK, MessageBoxIcon.Information);
            return(true);
        }
예제 #3
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (!valida())
            {
                return;
            }
            SqlConnection connection = UsoBD.ConectaBD(Utileria.GetConnectionString());

            if (connection == null)
            {
                foreach (SqlError item in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(item.Message);
                }
            }
            string command = "INSERT INTO COMPONENTE(NUMERO_SERIE_PADRE,NUMERO_SERIE_COMPONENTE)";

            command += "VALUES(@NUMERO_SERIE_PADRE,@NUMERO_SERIE_COMPONENTE)";
            SqlCommand comandoInsersion = new SqlCommand(command, connection);

            comandoInsersion.Parameters.AddWithValue("@NUMERO_SERIE_PADRE", cmbDispositivo1.SelectedItem.ToString());
            comandoInsersion.Parameters.AddWithValue("@NUMERO_SERIE_COMPONENTE", cmbDispositivo2.SelectedItem.ToString());
            try
            {
                comandoInsersion.ExecuteNonQuery();
            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.Message);
                connection.Close();
            }
            connection.Close();
            MessageBox.Show("DISPOSITIVO VINCULADO", "CORRECTO", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        public static bool ActualizarStatusIncidenciaFin(int id)
        {
            SqlConnection connection = UsoBD.ConectaBD(Utileria.GetConnectionString());

            if (connection == null)
            {
                foreach (SqlError item in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(item.Message);
                }
            }
            string     command          = "UPDATE INCIDENCIA SET ESTATUS = 1 WHERE ID= @ID";
            SqlCommand comandoInsersion = new SqlCommand(command, connection);

            comandoInsersion.Parameters.AddWithValue("@ID", id);

            try
            {
                comandoInsersion.ExecuteNonQuery();
            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.Message);
                connection.Close();
                return(false);
            }
            connection.Close();

            return(true);
        }
예제 #5
0
        public static bool AñadirJefe(String usuario, String password, int departamento)
        {
            SqlConnection connection = UsoBD.ConectaBD(Utileria.GetConnectionString());

            if (connection == null)
            {
                foreach (SqlError item in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(item.Message);
                }
            }
            string command = "INSERT INTO JEFE_DEPARTAMENTO(Usuario, Password, Departamento)";

            command += " VALUES(@Usuario, @password, @departamento)";
            SqlCommand comandoInsersion = new SqlCommand(command, connection);

            comandoInsersion.Parameters.AddWithValue("@Usuario", usuario);
            comandoInsersion.Parameters.AddWithValue("@password", password);
            comandoInsersion.Parameters.AddWithValue("@departamento", departamento);

            try
            {
                comandoInsersion.ExecuteNonQuery();
            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.Message);
                connection.Close();
                return(false);
            }
            connection.Close();
            MessageBox.Show("GUARDADO EXITOSAMENTE", "ADMINISTRADOR", MessageBoxButtons.OK, MessageBoxIcon.Information);
            return(true);
        }
예제 #6
0
        public static bool ActualizarDepartamentoJefe(String usuario, int departamentoJefe)
        {
            SqlConnection connection = UsoBD.ConectaBD(Utileria.GetConnectionString());

            if (connection == null)
            {
                foreach (SqlError item in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(item.Message);
                }
            }
            string     command          = "UPDATE JEFE_DEPARTAMENTO SET DEPARTAMENTO = @departamentoJefe WHERE USUARIO= @Usuario";
            SqlCommand comandoInsersion = new SqlCommand(command, connection);

            comandoInsersion.Parameters.AddWithValue("@Usuario", usuario);
            comandoInsersion.Parameters.AddWithValue("@departamentoJefe", departamentoJefe);
            try
            {
                comandoInsersion.ExecuteNonQuery();
            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.Message);
                connection.Close();
                return(false);
            }
            connection.Close();
            MessageBox.Show("ACTUALIZADO EXITOSAMENTE", "JEFE", MessageBoxButtons.OK, MessageBoxIcon.Information);
            return(true);
        }
        public static bool AgregarDeptoTecnico(String Nombre)
        {
            SqlConnection connection = UsoBD.ConectaBD(Utileria.GetConnectionString());

            if (connection == null)
            {
                foreach (SqlError item in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(item.Message);
                }
            }
            string command = "INSERT INTO DEPARTAMENTO_TECNICO(NOMBRE)";

            command += " VALUES(@Nombre)";
            SqlCommand comandoInsersion = new SqlCommand(command, connection);

            comandoInsersion.Parameters.AddWithValue("@Nombre", Nombre);

            try
            {
                comandoInsersion.ExecuteNonQuery();
            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.Message);
                connection.Close();
                return(false);
            }
            connection.Close();
            MessageBox.Show("GUARDADO EXITOSAMENTE", "ADMINISTRADOR", MessageBoxButtons.OK, MessageBoxIcon.Information);
            return(true);
        }
예제 #8
0
        public bool AsignarAula(String aula, String usuario)
        {
            SqlConnection connection = UsoBD.ConectaBD(Utileria.GetConnectionString());

            if (connection == null)
            {
                foreach (SqlError item in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(item.Message);
                }
            }
            string     command          = "UPDATE AULA SET JEFE_DEPARTAMENTO = @Usuario WHERE DESCRIPCION= @aula";
            SqlCommand comandoInsersion = new SqlCommand(command, connection);

            comandoInsersion.Parameters.AddWithValue("@Usuario", usuario);
            comandoInsersion.Parameters.AddWithValue("@aula", aula);
            try
            {
                comandoInsersion.ExecuteNonQuery();
            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.Message);
                connection.Close();
                return(false);
            }
            connection.Close();
            MessageBox.Show("ACTUALIZADO EXITOSAMENTE", "AULA", MessageBoxButtons.OK, MessageBoxIcon.Information);
            return(true);
        }
예제 #9
0
        public static bool AgregarAula(string Descripcion, string JefeDepto)
        {
            SqlConnection connection = UsoBD.ConectaBD(Utileria.GetConnectionString());

            if (connection == null)
            {
                foreach (SqlError item in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(item.Message);
                }
            }
            string command = "INSERT INTO AULA(DESCRIPCION, JEFE_DEPARTAMENTO)";

            command += " VALUES(@Descripcion, @JefeDepto)";
            SqlCommand comandoInsersion = new SqlCommand(command, connection);

            comandoInsersion.Parameters.AddWithValue("@Descripcion", Descripcion);
            comandoInsersion.Parameters.AddWithValue("@JefeDepto", JefeDepto);

            try
            {
                comandoInsersion.ExecuteNonQuery();
            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.Message);
                connection.Close();
                return(false);
            }
            connection.Close();
            MessageBox.Show("GUARDADO EXITOSAMENTE", "ADMINISTRADOR", MessageBoxButtons.OK, MessageBoxIcon.Information);
            return(true);
        }
예제 #10
0
        private void btnAutorizar_Click(object sender, EventArgs e)
        {
            SqlConnection connection = UsoBD.ConectaBD(Utileria.GetConnectionString());

            if (connection == null)
            {
                foreach (SqlError item in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(item.Message);
                }
            }
            string     command          = "UPDATE CAMBIO_COMPONENTE SET APROBADO=1 WHERE ID = @id ";
            SqlCommand comandoInsersion = new SqlCommand(command, connection);

            comandoInsersion.Parameters.AddWithValue("@id", cmbCambio.SelectedItem.ToString());
            try
            {
                comandoInsersion.ExecuteNonQuery();
            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.Message);
                connection.Close();
            }
            connection.Close();
            MessageBox.Show("ACTUALIZADO EXITOSAMENTE", "JEFE", MessageBoxButtons.OK, MessageBoxIcon.Information);
            this.Close();
        }
        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 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 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 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 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();
        }
        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);
                }
            }
        }
예제 #17
0
        private void frmConsultaDispositivos_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_Dispositivos WHERE UBICACION != " + "'ALMACÉN'";
            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)
            {
                dataGridView1.Rows.Clear();
                while (Lector.Read())
                {
                    string numSerie         = Lector.GetValue(0).ToString();
                    string descripcion      = Lector.GetValue(1).ToString();
                    string modelo           = Lector.GetValue(2).ToString();
                    string marca            = Lector.GetValue(3).ToString();
                    string ubicacion        = Lector.GetValue(4).ToString();
                    string ubicacionDetalle = Lector.GetValue(5).ToString();
                    string garantia         = Lector.GetValue(6).ToString();

                    dataGridView1.Rows.Add(numSerie, descripcion, modelo, marca, ubicacion, ubicacionDetalle, garantia);
                }
            }
            Conecta.Close();
        }
        private void cmbIncidencias_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cmbIncidencias.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        Query  = "SELECT DISPOSITIVO, INCIDENCIA FROM VW_Incidencias WHERE ID = " + cmbIncidencias.SelectedItem.ToString();
            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())
                {
                    txtNumeroSerie.Text = Lector.GetValue(0).ToString();
                    txtIncidencia.Text  = Lector.GetValue(1).ToString();
                }
            }
            Conecta.Close();
        }
        public bool validaDep(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 NOMBRE FROM DEPARTAMENTO WHERE NOMBRE = " + "'" + 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)
            {
                if (Lector.Read())

                {
                    if (nombre == Lector.GetValue(0).ToString())
                    {
                        encontro = true;
                    }
                }
            }
            Conecta.Close();
            return(encontro);
        }
예제 #20
0
        private void frmVinculaDispositivos_Load(object sender, EventArgs e)
        {
            cmbDispositivo1.Items.Clear();
            cmbDispositivo2.Items.Clear();
            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 NUMERO_SERIE FROM DISPOSITIVO WHERE NUMERO_SERIE NOT IN(SELECT NUMERO_SERIE_COMPONENTE FROM COMPONENTE)";
            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())
                {
                    cmbDispositivo1.Items.Add(Lector.GetValue(0).ToString());
                    cmbDispositivo2.Items.Add(Lector.GetValue(0).ToString());
                }
            }
            Conecta.Close();
        }
예제 #21
0
        public static Jefe GetJefe(String nombre)
        {
            Jefe          jefe       = null;
            SqlConnection connection = UsoBD.ConectaBD(Utileria.GetConnectionString());

            if (connection == null)
            {
                foreach (SqlError item in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(item.Message);
                }
                return(jefe);
            }

            SqlDataReader lector     = null;
            String        comando    = "SELECT USUARIO, PASSWORD, D.NOMBRE FROM JEFE_DEPARTAMENTO J INNER JOIN DEPARTAMENTO D ON J.DEPARTAMENTO = D.ID  WHERE J.USUARIO = '" + nombre + "'";
            SqlCommand    sqlCommand = new SqlCommand(comando, connection);

            try
            {
                lector = sqlCommand.ExecuteReader();
            }
            catch (SqlException ex)
            {
                foreach (SqlError item in ex.Errors)
                {
                    MessageBox.Show(item.Message.ToString());
                }
                connection.Close();
                return(jefe);
            }
            if (lector.Read())
            {
                String usuario      = lector.GetValue(0).ToString();
                String password     = lector.GetValue(1).ToString();
                String departamento = lector.GetValue(2).ToString();
                jefe = new Jefe(usuario, password, departamento);
            }
            connection.Close();
            return(jefe);
        }
예제 #22
0
        public bool Autenticado(String nombre, String password)
        {
            bool          autenticado = false;
            SqlConnection connection  = UsoBD.ConectaBD(Utileria.GetConnectionString());

            if (connection == null)
            {
                foreach (SqlError item in UsoBD.ESalida.Errors)
                {
                    MessageBox.Show(item.Message);
                }
            }
            String        comando    = "SELECT PASSWORD FROM USUARIO WHERE NOMBRE = " + nombre;
            SqlDataReader lector     = null;
            SqlCommand    sqlCommand = new SqlCommand(comando, connection);

            try
            {
                lector = sqlCommand.ExecuteReader();
            }
            catch (SqlException ex)
            {
                foreach (SqlError item in ex.Errors)
                {
                    MessageBox.Show(item.Message.ToString());
                }
                connection.Close();
                return(false);
            }
            if (lector.Read())
            {
                if (password == lector.GetValue(0).ToString())
                {
                    autenticado = true;
                }
            }
            lector.Close();
            connection.Close();
            return(autenticado);
        }
        //FINALIZAR INCIDENCIA
        public static List <int> ObtenerIncidenciaTec(string usuario)
        {
            List <int>    list       = new List <int>();
            SqlConnection connection = UsoBD.ConectaBD(Utileria.GetConnectionString());

            if (connection == null)
            {
                foreach (SqlError item in UsoBD.ESalida.Errors)
                {
                    connection.Close();
                    MessageBox.Show(item.Message);
                }
            }
            SqlDataReader lector  = null;
            String        comando = "SELECT T.ID_INCIDENCIA FROM INCIDENCIA I ";

            comando += "INNER JOIN INCIDENCIA_TECNICO T ON I.ID = T.ID_INCIDENCIA ";
            comando += "WHERE I.ESTATUS = 2 AND T.TECNICO = " + "'" + usuario + "'";
            SqlCommand sqlCommand = new SqlCommand(comando, connection);

            try
            {
                lector = sqlCommand.ExecuteReader();
            }
            catch (SqlException ex)
            {
                foreach (SqlError item in ex.Errors)
                {
                    MessageBox.Show(item.Message.ToString());
                }
                connection.Close();
                return(list);
            }
            while (lector.Read())
            {
                list.Add(Convert.ToInt32(lector.GetValue(0)));
            }
            connection.Close();
            return(list);
        }
예제 #24
0
        private void frmAutorizarCambio_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 FROM CAMBIO_COMPONENTE WHERE APROBADO = 0";
            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)
            {
                cmbCambio.Items.Clear();
                while (Lector.Read())
                {
                    cmbCambio.Items.Add(Lector.GetValue(0).ToString());
                }
            }
            Conecta.Close();
        }
예제 #25
0
        private void cmbDispositivo2_SelectedIndexChanged(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 DESCRIPCION, MODELO FROM VW_Dispositivos WHERE NUMERO_SERIE = " + cmbDispositivo2.SelectedItem.ToString();
            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())
                {
                    txtDescripcion2.Text = (Lector.GetValue(0).ToString());
                    txtModelo2.Text      = (Lector.GetValue(1).ToString());
                }
            }
            Conecta.Close();
        }
        private void LoadCMBMarca()
        {
            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 NOMBRE FROM MARCA";
            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)
            {
                cmbMarca.Items.Clear();
                while (Lector.Read())
                {
                    cmbMarca.Items.Add(Lector.GetValue(0).ToString());
                }
            }
            Conecta.Close();
        }
예제 #27
0
        private void cmbCambio_SelectedIndexChanged(object sender, EventArgs e)
        {
            String        cambio   = cmbCambio.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 NUMERO_SERIE FROM CAMBIO_COMPONENTE C INNER JOIN DISPOSITIVO D ON C.ID_NUEVOCOMPONENTE = D.NUMERO_SERIE WHERE C.ID =" + cambio;
            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(0).ToString();
                }
            }
            Conecta.Close();
        }
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            dgvIncidencias.Rows.Clear();
            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,DISPOSITIVO,INCIDENCIA,REPORTADO_POR,FECHA_REPORTE,FECHA_SOLUCION,TIPO_SOLUCION FROM VW_IncidenciasConcluidas WHERE SOLUCIONADO_POR = " + "'" + comboBox1.SelectedItem.ToString() + "'";
            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())
                {
                    dgvIncidencias.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());
                }
            }
            Conecta.Close();
        }
        private void frmConsultaIncidenciaIndividual_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 FROM INCIDENCIA";
            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())
                {
                    cmbIncidencias.Items.Add(Lector.GetValue(0).ToString());
                }
            }
            Conecta.Close();
        }
        private void frmConsultaDepartamentos_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 D.ID, D.NOMBRE, J.USUARIO AS JEFE_DEPARTAMENTO FROM DEPARTAMENTO D INNER JOIN JEFE_DEPARTAMENTO J ON D.ID = J.DEPARTAMENTO ORDER BY D.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())
                {
                    dataGridView1.Rows.Add(Lector.GetValue(0).ToString(), Lector.GetValue(1).ToString(), Lector.GetValue(2).ToString());
                }
            }
            Conecta.Close();
        }