private void btnActualizar_Click(object sender, EventArgs e)
        {
            string Dep   = cmbDepartamentos.SelectedItem.ToString();
            int    DepID = AdmDep.GetID(Dep);
            string Nom   = txtNombre.Text;

            if (!(Utileria.IsEmpty(Nom)))
            {
                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;
                }
                string strComando = "UPDATE DEPARTAMENTO SET Nombre=@Nombre WHERE ID=@ID";

                SqlCommand Update = new SqlCommand(strComando, Connection);

                Update.Parameters.AddWithValue("@Nombre", Nom);
                Update.Parameters.AddWithValue("@ID", DepID);

                try
                {
                    Update.ExecuteNonQuery();
                }
                catch (SqlException Ex)
                {
                    foreach (SqlError item in Ex.Errors)
                    {
                        MessageBox.Show(item.Message);
                    }

                    Connection.Close();
                    return;
                }
                Connection.Close();
            }
            if (cmbEncargado.SelectedIndex >= 0)
            {
                string Enc   = cmbEncargado.SelectedItem.ToString();
                int    EncID = AdmEmp.GetIDByName(Enc);
                AdmDep.UpdateEnc(EncID, DepID);
            }
            MessageBox.Show("DEPARTAMENTO ACTUALIZADO EXITOSAMENTE", "AVISO", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            DialogResult Result = MessageBox.Show("¿DESEA AGREGAR ESTE ELEMENTO?", "PREGUNTA", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

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

            if (Utileria.IsEmpty(txtNombre.Text))
            {
                MessageBox.Show("NO SE ACEPTAN CAMPOS VACIOS EN EL NOMBRE", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (Utileria.IsEmpty(txtDescripcion.Text))
            {
                MessageBox.Show("NO SE ACEPTAN CAMPOS VACIOS EN LA DESCRIPCIÓN", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (Utileria.IsEmpty(txtNumSerie.Text))
            {
                MessageBox.Show("NO SE ACEPTAN CAMPOS VACIOS EN EL NÚMERO DE SERIE", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            int           Edificio   = 0;
            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 EDIFICIO WHERE Nombre LIKE '" + cmbEdificio.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())
                {
                    Edificio = Convert.ToInt32(Lector.GetValue(0).ToString());
                }
            }
            Connection.Close();

            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;
            }

            string strComando = "INSERT INTO LOCALIZACION(Nombre,NumPlanta,ID_Edificio,Ubicacion)";

            strComando += " VALUES(@Nombre,@NumPlanta,@ID_Edificio,@Ubicacion)";
            SqlCommand Insert = new SqlCommand(strComando, Connection2);

            Insert.Parameters.AddWithValue("@Nombre", txtUbicacion.Text.Trim());
            Insert.Parameters.AddWithValue("@NumPlanta", nudPlanta.Text);
            Insert.Parameters.AddWithValue("@ID_Edificio", Edificio);
            Insert.Parameters.AddWithValue("@Ubicacion", txtDescUbicacion.Text.Trim());

            try
            {
                Insert.ExecuteNonQuery();
            }
            catch (SqlException Ex)
            {
                foreach (SqlError item in Ex.Errors)
                {
                    MessageBox.Show(item.Message);
                }

                Connection2.Close();
                return;
            }
            Connection2.Close();

            int           Loc         = 0;
            SqlConnection Connection3 = UsoBD.ConectaBD(Utileria.GetConnectionString());

            if (Connection3 == 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        strComando2 = "SELECT ID FROM LOCALIZACION WHERE Ubicacion LIKE '" + txtDescUbicacion.Text.Trim() + "'";

            Lector2 = UsoBD.Consulta(strComando2, Connection3);

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

                Connection3.Close();
                return;
            }
            if (Lector2.HasRows)
            {
                while (Lector2.Read())
                {
                    Loc = Convert.ToInt32(Lector2.GetValue(0).ToString());
                }
            }
            Connection3.Close();

            int Enc = AdmEmp.GetIDByName(cmbEncargado.SelectedItem.ToString());
            int Pov = AdmPro.GetID(cmbProveedor.SelectedItem.ToString());

            AdmCI.AddCI(txtNombre.Text, txtDescripcion.Text, txtNumSerie.Text, maskDate.Text, Loc, Enc, Pov);
        }
        private void btnAgregar_Click(object sender, EventArgs e)
        {
            DialogResult Result = MessageBox.Show("¿DESEA AGREGAR ESTE EMPLEADO?", "PREGUNTA", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

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

            if (Utileria.IsEmpty(txtNombre.Text))
            {
                MessageBox.Show("NO SE ACEPTAN CAMPOS VACIOS EN EL NOMBRE", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (Utileria.IsEmpty(txtEmail.Text))
            {
                MessageBox.Show("NO SE ACEPTAN CAMPOS VACIOS EN EL EMAIL", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (Utileria.IsEmpty(txtDireccion.Text))
            {
                MessageBox.Show("NO SE ACEPTAN CAMPOS VACIOS EN LA DIRECCION", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (Utileria.ValidaTextoNum(txtCelular.Text))
            {
                MessageBox.Show("EN ESTE CAMPO SOLO SE ACEPTAN NUMEROS", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            int Rol = AdmEmp.GetIDByNameRol(cmbRol.SelectedItem.ToString());

            if (AdmEmp.AddEmp(txtNombre.Text, txtEmail.Text, txtCelular.Text, txtDireccion.Text, Rol))
            {
                MessageBox.Show("EMPLEADO AGREGADO EXITOSAMENRE", "INFORMACION", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            int DepID = AdmDepto.GetID(cmbDepto.SelectedItem.ToString());
            int EmpID = AdmEmp.GetIDByName(txtNombre.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;
            }

            string strComando = "INSERT INTO EMPLEADO_DEPTO(ID_Empleado,ID_Depto)";

            strComando += " VALUES(@ID_Empleado, @ID_Depto)";

            SqlCommand Insert = new SqlCommand(strComando, Connection);

            Insert.Parameters.AddWithValue("@ID_Empleado", EmpID);
            Insert.Parameters.AddWithValue("@ID_Depto", DepID);

            try
            {
                Insert.ExecuteNonQuery();
            }
            catch (SqlException Ex)
            {
                foreach (SqlError item in Ex.Errors)
                {
                    MessageBox.Show(item.Message);
                }

                Connection.Close();
            }

            Connection.Close();
        }
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            if (lvEmpleados.SelectedItems.Count == 0)
            {
                MessageBox.Show("NO HA SELECCIONADO NINGUN EMPLEADO", "SIN SELECCIONAR", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            DialogResult R = MessageBox.Show("¿DESEA ELIMINAR EL EMPLEADO SELECCIONADO?", "CONFIRMAR", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (R == DialogResult.Yes)
            {
                string NA, EM;
                for (int i = 0; i < lvEmpleados.Items.Count; i++)
                {
                    if (lvEmpleados.SelectedItems.Contains(lvEmpleados.Items[i]))
                    {
                        NA = lvEmpleados.Items[i].SubItems[0].Text;
                        EM = lvEmpleados.Items[i].SubItems[1].Text;
                        int EmpID = AdmEmp.GetIDByName(NA);
                        if (true)
                        {
                            SqlConnection Connection3  = UsoBD.ConectaBD(Utileria.GetConnectionString());
                            SqlDataReader Lector3      = null;
                            string        strComandoC3 = "SELECT ID FROM DEPARTAMENTO WHERE ID_EmpEncar=" + EmpID;

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

                                Connection3.Close();
                                return;
                            }
                            if (Lector3.HasRows)
                            {
                                while (Lector3.Read())
                                {
                                    AdmEmp.UpdateEstatus(EmpID);
                                    MessageBox.Show("LA BAJA DEL EMPLEADO SE HA REALIZADO CORRECTAMENTE", "ELIMINACION REALIZADA", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    lvEmpleados.Items[i].Remove();
                                    Connection3.Close();
                                    return;
                                }
                            }
                            Connection3.Close();

                            SqlConnection Connection4  = UsoBD.ConectaBD(Utileria.GetConnectionString());
                            SqlDataReader Lector4      = null;
                            string        strComandoC4 = "SELECT  I.ID FROM INCIDENCIA I WHERE I.ID_Tecnico=" + EmpID;

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

                                Connection4.Close();
                                return;
                            }
                            if (Lector4.HasRows)
                            {
                                while (Lector4.Read())
                                {
                                    AdmEmp.UpdateEstatus(EmpID);
                                    MessageBox.Show("LA BAJA DEL EMPLEADO SE HA REALIZADO CORRECTAMENTE", "ELIMINACION REALIZADA", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    lvEmpleados.Items[i].Remove();
                                    Connection4.Close();
                                    return;
                                }
                            }
                            Connection4.Close();


                            SqlConnection Connection5  = UsoBD.ConectaBD(Utileria.GetConnectionString());
                            SqlDataReader Lector5      = null;
                            string        strComandoC5 = "SELECT ID FROM INCIDENCIA WHERE ID_Usuario=" + EmpID;

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

                                Connection5.Close();
                                return;
                            }
                            if (Lector5.HasRows)
                            {
                                while (Lector5.Read())
                                {
                                    AdmEmp.UpdateEstatus(EmpID);
                                    MessageBox.Show("LA BAJA DEL EMPLEADO SE HA REALIZADO CORRECTAMENTE", "ELIMINACION REALIZADA", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    lvEmpleados.Items[i].Remove();
                                    Connection4.Close();
                                    return;
                                }
                            }
                            Connection4.Close();
                        }
                        SqlConnection Connection2  = UsoBD.ConectaBD(Utileria.GetConnectionString());
                        SqlDataReader Lector2      = null;
                        string        strComandoC2 = "DELETE FROM EMPLEADO_DEPTO WHERE ID_Empleado=" + EmpID;

                        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;
                        }
                        Connection2.Close();

                        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 = "DELETE FROM EMPLEADO WHERE Nombre LIKE '" + NA + "' AND Email LIKE '" + EM + "'";

                        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;
                        }
                        Connection.Close();

                        lvEmpleados.Items[i].Remove();
                        MessageBox.Show("LA ELIMINACION DEL EMPLEADO SE HA REALIZADO CORRECTAMENTE", "ELIMINACION REALIZADA", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                }
            }
        }
        private void btnActualizar_Click(object sender, EventArgs e)
        {
            DialogResult Result = MessageBox.Show("¿DESEA GUARDAR LOS CAMBIOS?", "PREGUNTA", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

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

            string Nombre   = cmbNombre.SelectedItem.ToString();
            string NumSerie = AdmCI.GetNumSerie(Nombre);
            int    ID       = AdmCI.GetID(NumSerie);

            if (!(Utileria.IsEmpty(txtDescripcion.Text)))
            {
                AdmCI.UpdateDesc(ID, txtDescripcion.Text);
            }
            if (!(Utileria.IsEmpty(maskDate.Text)))
            {
                AdmCI.UpdateDate(ID, maskDate.Text);
            }
            if (!(Utileria.IsEmpty(txtUbicacion.Text)))
            {
                int LocID = AdmCI.GetIDLoc(NumSerie.Trim());

                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;
                }
                string strComando = "UPDATE LOCALIZACION SET Nombre=@Nombre WHERE ID=@ID";

                SqlCommand Update = new SqlCommand(strComando, Connection);

                Update.Parameters.AddWithValue("@Nombre", txtUbicacion.Text);
                Update.Parameters.AddWithValue("@ID", LocID);

                try
                {
                    Update.ExecuteNonQuery();
                }
                catch (SqlException Ex)
                {
                    foreach (SqlError item in Ex.Errors)
                    {
                        MessageBox.Show(item.Message);
                    }

                    Connection.Close();
                    return;
                }
                Connection.Close();
                //MessageBox.Show("CAMPO 'NOMBRE DE LA UBICACIÓN' ACTUALIZADO EXITOSAMENTE", "AVISO", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            if (!(Utileria.IsEmpty(txtDescUbicacion.Text)))
            {
                int LocID = AdmCI.GetIDLoc(NumSerie.Trim());

                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;
                }
                string strComando = "UPDATE LOCALIZACION SET Ubicacion=@Ubicacion WHERE ID=@ID";

                SqlCommand Update = new SqlCommand(strComando, Connection);

                Update.Parameters.AddWithValue("@Ubicacion", txtDescUbicacion.Text);
                Update.Parameters.AddWithValue("@ID", LocID);

                try
                {
                    Update.ExecuteNonQuery();
                }
                catch (SqlException Ex)
                {
                    foreach (SqlError item in Ex.Errors)
                    {
                        MessageBox.Show(item.Message);
                    }

                    Connection.Close();
                    return;
                }
                Connection.Close();
                //MessageBox.Show("CAMPO 'DESCRIPCION DE LA UBICACIÓN' ACTUALIZADO EXITOSAMENTE", "AVISO", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            if (cmbProveedor.SelectedIndex >= 0)
            {
                string Prov  = cmbProveedor.SelectedItem.ToString();
                int    IDPro = AdmProv.GetID(Prov);
                int    IDCI  = AdmCI.GetID(NumSerie);


                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;
                }
                string strComando2 = "UPDATE CI SET ID_Proveedor=@ID_Proveedor WHERE ID=@ID";

                SqlCommand Update = new SqlCommand(strComando2, Connection2);

                Update.Parameters.AddWithValue("@ID_Proveedor", IDPro);
                Update.Parameters.AddWithValue("@ID", IDCI);

                try
                {
                    Update.ExecuteNonQuery();
                }
                catch (SqlException Ex)
                {
                    foreach (SqlError item in Ex.Errors)
                    {
                        MessageBox.Show(item.Message);
                    }

                    Connection2.Close();
                    return;
                }
                Connection2.Close();
            }
            if (cmbEncargado.SelectedIndex >= 0)
            {
                string Enc  = cmbEncargado.SelectedItem.ToString();
                int    IDEm = AdmEmp.GetIDByName(Enc);
                int    IDCI = AdmCI.GetID(NumSerie);


                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;
                }
                string strComando2 = "UPDATE CI SET ID_Encargado=@ID_Encargado WHERE ID=@ID";

                SqlCommand Update = new SqlCommand(strComando2, Connection2);

                Update.Parameters.AddWithValue("@ID_Encargado", IDEm);
                Update.Parameters.AddWithValue("@ID", IDCI);

                try
                {
                    Update.ExecuteNonQuery();
                }
                catch (SqlException Ex)
                {
                    foreach (SqlError item in Ex.Errors)
                    {
                        MessageBox.Show(item.Message);
                    }

                    Connection2.Close();
                    return;
                }
                Connection2.Close();
            }
            if (cmbEdificio.SelectedIndex >= 0)
            {
                string Ed    = cmbEdificio.SelectedItem.ToString();
                int    IDLoc = AdmCI.GetIDLoc(NumSerie);
                int    IDEd  = 0;

                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 EDIFICIO WHERE Nombre LIKE '" + Ed + "'";

                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())
                    {
                        IDEd = Convert.ToInt32(Lector.GetValue(0).ToString());
                    }
                }
                Connection.Close();

                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;
                }
                string strComando2 = "UPDATE LOCALIZACION SET ID_Edificio=@ID_Edificio WHERE ID=@ID";

                SqlCommand Update = new SqlCommand(strComando2, Connection2);

                Update.Parameters.AddWithValue("@ID_Edificio", IDEd);
                Update.Parameters.AddWithValue("@ID", IDLoc);

                try
                {
                    Update.ExecuteNonQuery();
                }
                catch (SqlException Ex)
                {
                    foreach (SqlError item in Ex.Errors)
                    {
                        MessageBox.Show(item.Message);
                    }

                    Connection2.Close();
                    return;
                }
                Connection2.Close();
            }
            if (nudPlanta.Value >= 1)
            {
                int num   = Convert.ToInt32(nudPlanta.Value);
                int IDLoc = AdmCI.GetIDLoc(NumSerie);

                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;
                }
                string strComando2 = "UPDATE LOCALIZACION SET NumPlanta=@NumPlanta WHERE ID=@ID";

                SqlCommand Update = new SqlCommand(strComando2, Connection2);

                Update.Parameters.AddWithValue("@NumPlanta", num);
                Update.Parameters.AddWithValue("@ID", IDLoc);

                try
                {
                    Update.ExecuteNonQuery();
                }
                catch (SqlException Ex)
                {
                    foreach (SqlError item in Ex.Errors)
                    {
                        MessageBox.Show(item.Message);
                    }

                    Connection2.Close();
                    return;
                }
                Connection2.Close();
            }
            MessageBox.Show("ELEMENTO DE CONFIGURACION ACTUALIZADO EXITOSAMENTE", "AVISO", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }