protected void CeldaEnlaceLineaCaliente_OnClick(object sender, EventArgs e)
    {
        Button ibut = (Button)TEnlacesLC.FindControl(((Button)sender).ID);

        if (ibut.CssClass == "BtnPanelRadioLibre")
        {
            BtLiberar.Enabled  = false;
            BModificar.Enabled = false;

            //El botón Asignar sólo debe estar habilitado si el botón seleccionado del panel está libre y
            //se ha seleccionado algún destino de la lista
            if (LBoxDestinos.SelectedIndex >= 0)
            {
                BtAsignar.Enabled      = PermisoSegunPerfil;
                ViewState["IdDestino"] = LBoxDestinos.SelectedItem.Text;
                ViewState["IdPrefijo"] = LBoxDestinos.SelectedValue.Replace(LBoxDestinos.SelectedItem.Text, "");
            }
            else
            {
                BtAsignar.Enabled = false;
            }
        }
        else
        {
            BtLiberar.Enabled  = PermisoSegunPerfil;
            BModificar.Enabled = true;
            BtAsignar.Enabled  = false;
        }


//        if (BtAsignar.Enabled || BtLiberar.Enabled)
        if (ibut.Text != "" || PermisoSegunPerfil)
        {
            ViewState["IdBoton"] = ((Button)sender).ID;
            TEnlacesLC.Enabled   = false;
            LBoxDestinos.Enabled = false;
            BtTelefonia.Enabled  = false;
            BtRadio.Enabled      = false;
            BtSector.Enabled     = false;
            Panel1.Visible       = true;
        }
        else if (!PermisoSegunPerfil)
        {
            PanelNoPermissions.Visible = true;
        }
    }
    private void LimpiarPanel()
    {
        TEnlacesLC.Height = NumPosicionesPag > 9 ? 80 : 40;

        TableRow tRow = (TableRow)TEnlacesLC.FindControl("TableRow1");

        tRow.Visible = tRow != null && NumPosicionesPag > 9;

        for (int i = 1; i <= NumPosicionesPag; i++)
        {
            TableCell tCell = (TableCell)TEnlacesLC.FindControl("TableCell" + i.ToString());
            if (tCell != null)
            {
                tCell.Visible = i <= NumPosicionesPag;

                Button ibut = (Button)TEnlacesLC.FindControl("Button" + i.ToString());
                ibut.CssClass = "BtnPanelRadioLibre";
                ibut.Text     = "";
            }
        }
    }
    private void AsignarDestino(string id)
    {
        Button ibut = (Button)TEnlacesLC.FindControl(id);

        if (ibut.CssClass == "BtnPanelTfAsignado")
        {
            DesasignarDestino(id);
        }
        TBoxLiteral.Text = (string)ViewState["IdDestino"];
        DListPrioridadSIP.SelectedIndex = 0;

        uint prefijo = UInt16.Parse((string)ViewState["IdPrefijo"]);

        if (prefijo == PREFIJO_DESTINO_ATS || prefijo == PREFIJO_DESTINO_ATS_BIS)
        {
            //Si es un destino ATS, se puede asignar un DESTINO LCEN al destino ATS
            DListDestinosLCEN.Visible = true;
            LbDestinoLCEN.Visible     = true;

            bEsDestinoATS_IP = ServicioCD40.DestinoATS_ConCentralIP((string)Session["idsistema"], (string)ViewState["IdDestino"]);

            CargaDestinosLCEN_Libres();
        }
        else
        {
            if (DListDestinosLCEN.Items.Count > 0)
            {
                DListDestinosLCEN.Items.Clear();
            }

            DListDestinosLCEN.Visible = false;
            LbDestinoLCEN.Visible     = false;
        }

        Panel2.Visible = true;
    }
    private void DesasignarDestino(string id)
    {
        try
        {
            Button ibut = (Button)TEnlacesLC.FindControl(id);
            if (ibut != null && ibut.CssClass == "BtnPanelTfAsignado")
            {
                uint prefijo = prefijosPosiciones[Int16.Parse(id.Replace("Button", ""))];

                if (prefijo == PREFIJO_DESTINO_LCI && datosLCint != null)       // LCI
                {
                    for (int i = 0; i < datosLCint.Length; i++)
                    {
                        if ((((ServiciosCD40.DestinosInternosSector)datosLCint[i]).Literal == ibut.Text) &&
                            ((ServiciosCD40.DestinosInternosSector)datosLCint[i]).PosHMI == Int16.Parse(id.Replace("Button", "")))
                        {
                            ServicioCD40.DeleteSQL(datosLCint[i]);

                            ServiciosCD40.DestinosInternosSector s = new ServiciosCD40.DestinosInternosSector();
                            s = (ServiciosCD40.DestinosInternosSector)datosLCint[i];

                            ServicioCD40.EliminaColateralEnUsuarioReciproco(ref s);

                            #region Sincronizar CD30
                            Configuration config = WebConfigurationManager.OpenWebConfiguration("~");
                            KeyValueConfigurationElement sincronizar = config.AppSettings.Settings["SincronizaCD30"];
                            if ((sincronizar != null) && (Int32.Parse(sincronizar.Value) == 1))
                            {
                                SincronizaCD30.SincronizaCD30 sincro = new SincronizaCD30.SincronizaCD30();

                                switch (sincro.BajaColateralTelefonia(((ServiciosCD40.DestinosInternosSector)datosLCint[i]).IdNucleo,
                                                                      ((ServiciosCD40.DestinosInternosSector)datosLCint[i]).IdSector,
                                                                      ((ServiciosCD40.DestinosInternosSector)datosLCint[i]).PosHMI + 56))
                                {
                                case 127:
                                    sincro.BajaColateralTelefonia(s.IdNucleo, s.IdSector, s.PosHMI + 56);
                                    cMsg.alert((string)GetGlobalResourceObject("Espaniol", "Cod127"));
                                    break;

                                case 128:
                                    cMsg.alert((string)GetGlobalResourceObject("Espaniol", "Cod128"));
                                    break;

                                default:
                                    break;
                                }
                            }
                            #endregion
                            break;
                        }
                    }
                }
                else
                if ((prefijo == PREFIJO_DESTINO_LCE || prefijo == PREFIJO_DESTINO_ATS || prefijo == PREFIJO_DESTINO_ATS_BIS) && datosLCext != null)     // LCE=1 o ATS=3
                {
                    for (int i = 0; i < datosLCext.Length; i++)
                    {
                        if ((((ServiciosCD40.DestinosExternosSector)datosLCext[i]).Literal == ibut.Text) &&
                            ((ServiciosCD40.DestinosExternosSector)datosLCext[i]).PosHMI == Int16.Parse(id.Replace("Button", "")))
                        {
                            ServicioCD40.DeleteSQL(datosLCext[i]);
                            #region Sincronizar CD30
                            Configuration config = WebConfigurationManager.OpenWebConfiguration("~");
                            KeyValueConfigurationElement sincronizar = config.AppSettings.Settings["SincronizaCD30"];
                            if ((sincronizar != null) && (Int32.Parse(sincronizar.Value) == 1))
                            {
                                SincronizaCD30.SincronizaCD30 sincro = new SincronizaCD30.SincronizaCD30();

                                switch (sincro.BajaColateralTelefonia(((ServiciosCD40.DestinosExternosSector)datosLCext[i]).IdNucleo,
                                                                      ((ServiciosCD40.DestinosExternosSector)datosLCext[i]).IdSector,
                                                                      ((ServiciosCD40.DestinosExternosSector)datosLCext[i]).PosHMI + 56))
                                {
                                case 127:
                                    cMsg.alert((string)GetGlobalResourceObject("Espaniol", "Cod127"));
                                    break;

                                case 128:
                                    cMsg.alert((string)GetGlobalResourceObject("Espaniol", "Cod128"));
                                    break;

                                default:
                                    break;
                                }
                            }
                            #endregion
                            break;
                        }
                    }
                }
            }
        }
        catch (Exception ex)
        {
            logDebugView.Error("(TFTLC-DesasignarDestino): ", ex);
        }
    }
    private void MostrarLC()
    {
        try
        {
            LimpiarPanel();
            if (datosLCint != null)
            {
                for (int i = 0; i < datosLCint.Length; i++)
                {
                    uint pos = ((ServiciosCD40.DestinosInternosSector)datosLCint[i]).PosHMI;
                    //20201019
                    if (pos >= prefijosPosiciones.Length)
                    {
                        cMsg.alert((string)GetGlobalResourceObject("Espaniol", "PanelLcErrorParamCNF"));
                        continue;
                    }
                    TableCell tCell = (TableCell)TEnlacesLC.FindControl("TableCell" + pos.ToString());
                    if (tCell != null)
                    {
                        tCell.Visible = i <= NumPosicionesPag;

                        Button ibut = (Button)TEnlacesLC.FindControl("Button" + pos.ToString());
                        ibut.CssClass           = "BtnPanelTfAsignado";
                        ibut.Text               = ((ServiciosCD40.DestinosInternosSector)datosLCint[i]).Literal;
                        prefijosPosiciones[pos] = ((ServiciosCD40.DestinosInternosSector)datosLCint[i]).IdPrefijo;
                    }
                }
            }
            if (datosLCext != null)
            {
                string strEtiLCEN = string.Empty;

                if (GetLocalResourceObject("LbDestinoLCENResource1.Text") != null)
                {
                    strEtiLCEN = GetLocalResourceObject("LbDestinoLCENResource1.Text").ToString();
                }
                for (int i = 0; i < datosLCext.Length; i++)
                {
                    uint pos = ((ServiciosCD40.DestinosExternosSector)datosLCext[i]).PosHMI;
                    //20201019
                    if (pos >= prefijosPosiciones.Length)
                    {
                        cMsg.alert((string)GetGlobalResourceObject("Espaniol", "PanelLcErrorParamCNF"));
                        continue;
                    }
                    TableCell tCell = (TableCell)TEnlacesLC.FindControl("TableCell" + pos.ToString());
                    if (tCell != null)
                    {
                        tCell.Visible = i <= NumPosicionesPag;

                        Button ibut = (Button)TEnlacesLC.FindControl("Button" + pos.ToString());
                        ibut.CssClass           = "BtnPanelTfAsignado";
                        ibut.Text               = ((ServiciosCD40.DestinosExternosSector)datosLCext[i]).Literal;
                        prefijosPosiciones[pos] = ((ServiciosCD40.DestinosExternosSector)datosLCext[i]).IdPrefijo;

                        if (prefijosPosiciones[pos] == PREFIJO_DESTINO_ATS || prefijosPosiciones[pos] == PREFIJO_DESTINO_ATS_BIS)
                        {
                            if (!string.IsNullOrEmpty(((ServiciosCD40.DestinosExternosSector)datosLCext[i]).IdDestinoLCEN))
                            {
                                ibut.ToolTip = strEtiLCEN + " " + ((ServiciosCD40.DestinosExternosSector)datosLCext[i]).IdDestinoLCEN;
                            }
                            else
                            {
                                ibut.ToolTip = string.Empty;
                            }
                        }
                    }
                }
            }
        }
        catch (Exception ex)
        {
            logDebugView.Error("(TFTLC-MostrarLC): ", ex);
        }
    }