private string obtenerTarifas(string sIdNodo)
    {
        try
        {
            StringBuilder sb = new StringBuilder();
            SqlDataReader dr = PERFILSUPER.SelectByT303_idnodo(null, int.Parse(sIdNodo));

            sb.Append("<table id='tblDatos' class='texto MANO' style='width:510px; text-align:left;' mantenimiento='1'>");
            sb.Append("<colgroup><col style='width:15px;' /><col style='width:25px;' /><col style='width:270px;' /><col style='width:100px;' /><col style='width:100px;' /></colgroup>");
            sb.Append("<tbody id='tbodyDatos'>");

            while (dr.Read())
            {
                sb.Append("<tr id='" + dr["t347_idperfilsuper"].ToString() + "' bd='' orden='" + dr["t347_orden"].ToString() + "' onclick='mm(event)' style='height:20px'>");
                sb.Append("<td style='text-align:center;'><img src='../../../../images/imgFN.gif'></td>");
                sb.Append("<td><img src='../../../../images/imgMoveRow.gif' style='margin-left:2px; margin-right:2px; vertical-align:middle; border:0px; cursor:row-resize;' ondragstart='return false;' title='Pinchar y arrastrar para ordenar' ></td>");
                sb.Append("<td><input type='text' class='txtL' style='width:260px' value=\"" + dr["t347_denominacion"].ToString() + "\" maxlength='30' onKeyUp='fm(event)'></td>");
                sb.Append("<td style='text-align:right; margin-right:5px;'><input type='text' class='txtNumL' style='width:90px;' value=\"" + decimal.Parse(dr["t347_imptarifahor"].ToString()).ToString("N") + "\" onKeyUp='fm(event)' onfocus='fn(this)'></td>");
                sb.Append("<td style='text-align:right; margin-right:5px;'><input type='text' class='txtNumL' style='width:90px;' value=\"" + decimal.Parse(dr["t347_imptarifajor"].ToString()).ToString("N") + "\" onKeyUp='fm(event)' onfocus='fn(this)'></td>");
                sb.Append("</tr>");
            }
            dr.Close();
            dr.Dispose();
            sb.Append("</tbody>");
            sb.Append("</table>");

            return("OK@#@" + sb.ToString());
        }
        catch (Exception ex)
        {
            return("Error@#@" + Errores.mostrarError("Error al obtener las tarifas", ex));
        }
    }
    private string obtenerTarifas(string sIdCliente, string sTipo)
    {
        try
        {
            bool?bEstado;

            //Si sTipo=T no restrinjo por estado de la PST, sino saco solo las activas
            if (sTipo == "T")
            {
                bEstado = null;
            }
            else
            {
                bEstado = true;
            }

            StringBuilder sb = new StringBuilder();
            SqlDataReader dr = PERFILSUPER.SelectByT302_idcliente(null, int.Parse(sIdCliente), bEstado);

            sb.Append("<table id='tblDatos' class='texto MANO' style='width:570px; text-align:left;' mantenimiento='1'>");
            sb.Append("<colgroup><col style='width:15px;' /><col style='width:25px;' /><col style='width:270px;' /><col style='width:100px;' /><col style='width:100px;' /><col style='width:60px;' /></colgroup>");
            sb.Append("<tbody id='tbodyDatos'>");

            while (dr.Read())
            {
                sb.Append("<tr id='" + dr["t347_idperfilsuper"].ToString() + "' bd='' orden='" + dr["t347_orden"].ToString() + "' onclick='mm(event)' style='height:20px'>");
                sb.Append("<td><img src='../../../../images/imgFN.gif'></td>");
                sb.Append("<td><img src='../../../../images/imgMoveRow.gif' style='margin-left:2px; margin-right:2px; vertical-align:middle; border:0px; cursor:row-resize;' ondragstart='return false;' title='Pinchar y arrastrar para ordenar' ></td>");
                sb.Append("<td><input type='text' class='txtL' style='width:260px' value=\"" + dr["t347_denominacion"].ToString() + "\" maxlength='30' onKeyUp='fm(event)'></td>");
                sb.Append("<td style='text-align:right; margin-right:5px;'><input type='text' class='txtNumL' style='width:90px;' value=\"" + decimal.Parse(dr["t347_imptarifahor"].ToString()).ToString("N") + "\" onKeyUp='fm(event)' onfocus='fn(this)'></td>");
                sb.Append("<td style='text-align:right; margin-right:5px;'><input type='text' class='txtNumL' style='width:90px;' value=\"" + decimal.Parse(dr["t347_imptarifajor"].ToString()).ToString("N") + "\" onKeyUp='fm(event)' onfocus='fn(this)'></td>");
                sb.Append("<td><input type='checkbox' style='width:20px; margin-left:23px;' ");
                sb.Append("class='checkTabla' onclick='aG();fm(event);' ");
                if ((bool)dr["t347_estado"])
                {
                    sb.Append("checked=true");
                }
                sb.Append("></td>");


                sb.Append("</tr>");
            }
            dr.Close();
            dr.Dispose();
            sb.Append("</tbody>");
            sb.Append("</table>");

            return("OK@#@" + sb.ToString());
        }
        catch (Exception ex)
        {
            return("Error@#@" + Errores.mostrarError("Error al obtener las tarifas", ex));
        }
    }
    protected string Grabar(string strDatos)
    {
        string sResul = "", sDesc = "", sElementosInsertados = "";
        int    nAux = 0;

        try
        {
            oConn = Conexion.Abrir();
            tr    = Conexion.AbrirTransaccion(oConn);
        }
        catch (Exception ex)
        {
            sResul = "Error@#@" + Errores.mostrarError("Error al abrir la conexión", ex);
            return(sResul);
        }

        try
        {
            string[] aTarifa = Regex.Split(strDatos, "///");
            //Primero se hacen las deletes para evitar errores por denominaciones duplicadas.
            foreach (string oTarifa in aTarifa)
            {
                if (oTarifa == "")
                {
                    continue;
                }
                string[] aValores = Regex.Split(oTarifa, "##");
                //0. Opcion BD. "I", "U", "D"
                //1. ID Tarifa
                //2. Descripcion
                //3. Hora
                //4. Jornada
                //5. Orden
                //6. IdNodo

                if (aValores[0] != "D")
                {
                    continue;
                }
                sDesc = Utilidades.unescape(aValores[2]);
                PERFILSUPER.Delete(tr, int.Parse(aValores[1]));
            }

            foreach (string oTarifa in aTarifa)
            {
                if (oTarifa == "")
                {
                    continue;
                }
                string[] aValores = Regex.Split(oTarifa, "##");
                //0. Opcion BD. "I", "U", "D"
                //1. ID Tarifa
                //2. Descripcion
                //3. Hora
                //4. Jornada
                //5. Orden
                //6. IdNodo

                sDesc = Utilidades.unescape(aValores[2]);
                switch (aValores[0])
                {
                case "I":
                    nAux = PERFILSUPER.Insert(tr, Utilidades.unescape(aValores[2]), decimal.Parse(aValores[3]), decimal.Parse(aValores[4]),
                                              int.Parse(aValores[6]), null, short.Parse(aValores[5]), true);
                    if (sElementosInsertados == "")
                    {
                        sElementosInsertados = nAux.ToString();
                    }
                    else
                    {
                        sElementosInsertados += "//" + nAux.ToString();
                    }
                    break;

                case "U":
                    PERFILSUPER.Update(tr, int.Parse(aValores[1]), Utilidades.unescape(aValores[2]), decimal.Parse(aValores[3]),
                                       decimal.Parse(aValores[4]), int.Parse(aValores[6]), null, short.Parse(aValores[5]), true);
                    break;
                    //case "D":
                    //    PERFILSUPER.Delete(tr, int.Parse(aValores[1]));
                    //    break;
                }
            }
            Conexion.CommitTransaccion(tr);

            sResul = "OK@#@" + sElementosInsertados;
        }
        catch (Exception ex)
        {
            Conexion.CerrarTransaccion(tr);
            sResul = "Error@#@" + Errores.mostrarError("Error al grabar las tarifas.", ex) + "@#@" + sDesc;
        }
        finally
        {
            Conexion.Cerrar(oConn);
        }

        return(sResul);
    }