private string Grabar(string strDatosBasicos, string strFiguras)
    {
        string sResul = "";
        int    nID    = -1;

        string[] aDatosBasicos = null;
        IB.SUPER.ADM.SIC.Models.AreaPreventa oArea  = new IB.SUPER.ADM.SIC.Models.AreaPreventa();
        IB.SUPER.ADM.SIC.Models.AreaPreventa oAreaD = new IB.SUPER.ADM.SIC.Models.AreaPreventa();
        IB.SUPER.ADM.SIC.BLL.AreaPreventa    oElem  = new IB.SUPER.ADM.SIC.BLL.AreaPreventa();

        IB.SUPER.ADM.SIC.Models.FiguraAreaPreventa oFigura  = new IB.SUPER.ADM.SIC.Models.FiguraAreaPreventa();
        IB.SUPER.ADM.SIC.BLL.FiguraAreaPreventa    oElemFig = new IB.SUPER.ADM.SIC.BLL.FiguraAreaPreventa();
        try
        {
            #region Datos Generales

            if (strDatosBasicos != "")//No se ha modificado nada de la pestaña general
            {
                aDatosBasicos = Regex.Split(strDatosBasicos, "##");
                ///aDatosBasicos[0] = ID
                ///aDatosBasicos[1] = Denominacion
                ///aDatosBasicos[2] = IDResponsable
                ///aDatosBasicos[3] = Activo
                ///aDatosBasicos[4] = IdPadre
                ///aDatosBasicos[5] = IdPT
                oArea.ta199_idunidadpreventa    = short.Parse(aDatosBasicos[4]);
                oArea.ta200_denominacion        = aDatosBasicos[1];
                oArea.ta200_estadoactiva        = (aDatosBasicos[3] == "1") ? true : false;
                oArea.t001_idficepi_responsable = int.Parse(aDatosBasicos[2]);
                if (aDatosBasicos[5] != "")
                {
                    oArea.t331_idpt = int.Parse(aDatosBasicos[5]);
                }

                oAreaD = oElem.SelectPorDenominacion(oArea.ta200_denominacion);

                if (aDatosBasicos[0] == "") //insert
                {
                    if (oAreaD != null)
                    {
                        return("AVISO2@#@Ya existe un área con la misma denominación");               //throw new Exception("Ya existe un área con la misma denominación");
                    }
                    nID = oElem.Insert(oArea);
                }
                else //update
                {
                    nID = int.Parse(aDatosBasicos[0]);
                    if (oAreaD != null && oAreaD.ta200_idareapreventa != nID)
                    {
                        return("AVISO2@#@Ya existe un área con la misma denominación");
                    }
                    oArea.ta200_idareapreventa = nID;
                    oElem.Update(oArea);
                }
            }

            #endregion

            #region Datos Figuras
            if (strFiguras != "")//No se ha modificado nada de la pestaña de Figuras
            {
                string[] aUsuarios = Regex.Split(strFiguras, "///");
                foreach (string oUsuario in aUsuarios)
                {
                    if (oUsuario == "")
                    {
                        continue;
                    }
                    string[] aFig = Regex.Split(oUsuario, "##");
                    ///aFig[0] = bd
                    ///aFig[1] = idUsuario
                    ///aFig[2] = Figuras

                    if (aFig[0] == "D")
                    {
                        //PreventaAreaFiguras.DeleteUsuario(tr, nID, int.Parse(aFig[1]));
                        oElemFig.Delete(nID, int.Parse(aFig[1]));
                    }
                    else
                    {
                        string[] aFiguras = Regex.Split(aFig[2], ",");
                        foreach (string oFig in aFiguras)
                        {
                            if (oFig == "")
                            {
                                continue;
                            }
                            string[] aFig2 = Regex.Split(oFig, "@");
                            ///aFig2[0] = bd
                            ///aFig2[1] = Figura
                            oFigura.ta200_idareapreventa = nID;
                            oFigura.t001_idficepi        = int.Parse(aFig[1]);
                            oFigura.ta202_figura         = aFig2[1];
                            if (aFig2[0] == "D")
                            {
                                //PreventaAreaFiguras.Delete(tr, nID, int.Parse(aFig[1]), aFig2[1]);
                                oElemFig.DeleteFigura(nID, int.Parse(aFig[1]), aFig2[1]);
                            }
                            else
                            {
                                //PreventaAreaFiguras.Insert(tr, nID, int.Parse(aFig[1]), aFig2[1]);
                                oElemFig.Insert(oFigura);
                            }
                        }
                    }
                }
            }
            #endregion

            sResul = "OK@#@" + nID.ToString("#,###");
        }
        catch (Exception ex)
        {
            sResul = "Error@#@" + Errores.mostrarError("Error al grabar los datos.", ex, false);
        }
        finally
        {
            oElem.Dispose();
            oElemFig.Dispose();
        }
        return(sResul);
    }
    private string obtenerFigurasItem(string sPestana, string sNivel, string sIDItem)
    {
        StringBuilder sb       = new StringBuilder();
        StringBuilder sbuilder = new StringBuilder();

        sbuilder.Append(" aFigIni = new Array();");
        int i = 0;

        IB.SUPER.ADM.SIC.BLL.FiguraAreaPreventa oFigura = new IB.SUPER.ADM.SIC.BLL.FiguraAreaPreventa();
        try
        {
            //SqlDataReader dr = null;
            //switch (int.Parse(sNivel))
            //{
            //    case 2: //Area de Preventa
            //        dr = PreventaAreaFiguras.CatalogoFiguras(int.Parse(sIDItem));
            //        break;
            //    default:
            //        dr = null;
            //        break;
            //}

            List <IB.SUPER.ADM.SIC.Models.FiguraAreaPreventa> oLista = oFigura.Catalogo(int.Parse(sIDItem));

            sb.Append("<table id='tblFiguras2' class='texto MM' style='width: 420px;' mantenimiento='1'>");
            sb.Append("<colgroup><col style='width: 20px' /><col style='width: 20px' /><col style='width: 280px;' /><col style='width: 100px;' /></colgroup>");
            sb.Append("<tbody id='tbodyFiguras2'>");
            int  nUsuario  = 0;
            bool bHayFilas = false;
            foreach (IB.SUPER.ADM.SIC.Models.FiguraAreaPreventa oElem in oLista)
            {
                bHayFilas = true;
                sbuilder.Append("aFigIni[" + i.ToString() + "] = {idUser:\"" + oElem.t001_idficepi + "\"," +
                                "sFig:\"" + oElem.ta202_figura + "\"};");
                i++;
                if (oElem.t001_idficepi != nUsuario)
                {
                    if (nUsuario != 0)
                    {
                        sb.Append("</ul></div></td>");
                        sb.Append("</tr>");
                    }
                    sb.Append("<tr id='" + oElem.t001_idficepi + "' bd='' style='height:22px;' onclick='mm(event)' onmousedown='DD(event);' ");

                    sb.Append("><td><img src='../../../../images/imgFN.gif'></td>");
                    sb.Append("<td align='center'>");

                    if (oElem.sexo == "V")
                    {
                        switch (oElem.tipoProf)
                        {
                        case "I":
                            sb.Append("<img src='../../../../images/imgUsuPV.gif'>");
                            break;

                        case "F":
                            sb.Append("<img src='../../../../images/imgUsuFV.gif'>");
                            break;

                        default:
                            sb.Append("<img src='../../../../images/imgUsuEV.gif'>");
                            break;
                        }
                    }
                    else
                    {
                        switch (oElem.tipoProf)
                        {
                        case "I":
                            sb.Append("<img src='../../../../images/imgUsuPV.gif'>");
                            break;

                        case "F":
                            sb.Append("<img src='../../../../images/imgUsuFV.gif'>");
                            break;

                        default:
                            sb.Append("<img src='../../../../images/imgUsuEV.gif'>");
                            break;
                        }
                    }
                    sb.Append("</td><td><span class='NBR W275' ");
                    //sb.Append(" title=\"cssbody=[dvbdy] cssheader=[dvhdr] header=[<img src='../../../../images/info.gif' style='vertical-align:middle'>  Información] body=[<label style='width:70px;'>Profesional:</label>" + dr["Profesional"].ToString().Replace((char)34, (char)39) + "<br><label style='width:70px;'>Usuario:</label>" + int.Parse(dr["t314_idusuario"].ToString()).ToString("#,###") + "<br><label style='width:70px;'>" + Estructura.getDefCorta(Estructura.sTipoElem.NODO) + ":</label>" + dr["t303_denominacion"].ToString().Replace((char)34, (char)39) + "] hideselects=[off]\"");
                    sb.Append(" title=\"cssbody=[dvbdy] cssheader=[dvhdr] header=[<img src='../../../../images/info.gif' style='vertical-align:middle'>  Información] body=[<label style='width:70px;'>Profesional:</label>" + oElem.profesional.Replace((char)34, (char)39) + "] hideselects=[off]\"");

                    sb.Append(">" + oElem.profesional + "</span></td>");

                    //Figuras
                    sb.Append("<td><div><ul id='box-" + oElem.t001_idficepi + "'>");

                    switch (oElem.ta202_figura)
                    {
                    case "D": sb.Append("<li id='D' value='" + oElem.orden.ToString() + "'><img src='../../../../Images/imgDelegado.gif' title='Delegado' /></li>"); break;

                    case "C": sb.Append("<li id='C' value='" + oElem.orden.ToString() + "'><img src='../../../../Images/imgColaborador.gif' title='Colaborador' /></li>"); break;

                    case "I": sb.Append("<li id='I' value='" + oElem.orden.ToString() + "'><img src='../../../../Images/imgInvitado.gif' title='Invitado' /></li>"); break;
                    }

                    nUsuario = oElem.t001_idficepi;
                }
                else
                {
                    switch (oElem.ta202_figura)
                    {
                    case "D": sb.Append("<li id='D' value='" + oElem.orden.ToString() + "'><img src='../../../../Images/imgDelegado.gif' title='Delegado' /></li>"); break;

                    case "C": sb.Append("<li id='C' value='" + oElem.orden.ToString() + "'><img src='../../../../Images/imgColaborador.gif' title='Colaborador' /></li>"); break;

                    case "I": sb.Append("<li id='I' value='" + oElem.orden.ToString() + "'><img src='../../../../Images/imgInvitado.gif' title='Invitado' /></li>"); break;
                    }
                }
            }

            if (bHayFilas)
            {
                sb.Append("</ul></div></td>");
                sb.Append("</tr>");
            }
            sb.Append("</tbody>");
            sb.Append("</table>");

            return("OK@#@" + sPestana + "@#@" + sb.ToString() + "///" + sbuilder.ToString());
        }
        catch (Exception ex)
        {
            return("Error@#@" + Errores.mostrarError("Error al obtener la relación de figuras.", ex));
        }
        finally
        {
            oFigura.Dispose();
        }
    }