Exemple #1
0
    private string ObtenerParametrosConsulta(string sActivos)
    {
        StringBuilder sbuilder = new StringBuilder();

        sbuilder.Append(" aParams = new Array();\n");
        SqlDataReader dr = PARAMETROCONSULTAPERSONAL.Catalogo(null, (sActivos == "1") ? true : false);
        int           i  = 0;

        while (dr.Read())
        {
            sbuilder.Append("\taParams[" + i.ToString() + "] = {bd:\"\", " +
                            "idCons:\"" + dr["t472_idconsulta"].ToString() + "\"," +
                            "idParam:\"" + Utilidades.escape(dr["t474_textoparametro"].ToString()) + "\"," +
                            "nombre:\"" + Utilidades.escape(dr["t474_nombreparametro"].ToString()) + "\"," +
                            "texto:\"" + Utilidades.escape(dr["t474_textoparametro"].ToString()) + "\"," +
                            "comentario:\"" + Utilidades.escape(dr["t474_comentarioparametro"].ToString()) + "\"," +
                            "tipo:\"" + dr["t474_tipoparametro"].ToString() + "\"," +
                            "defecto:\"" + Utilidades.escape(dr["t474_valordefecto"].ToString()) + "\"," +
                            "visible:\"" + dr["t474_visible"].ToString() + "\"," +
                            "orden:" + dr["t474_orden"].ToString() + ",");
            if ((bool)dr["t474_opcional"])
            {
                sbuilder.Append("opcional:\"1\"};\n");
            }
            else
            {
                sbuilder.Append("opcional:\"0\"};\n");
            }
            i++;
        }
        dr.Close();
        dr.Dispose();

        return(sbuilder.ToString());
    }
Exemple #2
0
    private string Grabar(string strConsultas, string strParametros)
    {
        string sResul = "", sNuevosAEs = "", sClaveWS = "";
        int    idConsulta;

        try
        {
            #region abrir conexión y transacción
            try
            {
                oConn = Conexion.Abrir();
                tr    = Conexion.AbrirTransaccionSerializable(oConn);
            }
            catch (Exception ex)
            {
                if (oConn.State == ConnectionState.Open)
                {
                    Conexion.Cerrar(oConn);
                }
                sResul = "Error@#@" + Errores.mostrarError("Error al abrir la conexión", ex);
                return(sResul);
            }
            #endregion

            #region CONSULTAS
            int idNuevaConsulta;

            string[] aAE = Regex.Split(strConsultas, "///");
            foreach (string oAE in aAE)
            {
                if (oAE == "")
                {
                    continue;
                }
                string[] aValores = Regex.Split(oAE, "##");
                //0. Opcion BD. "I", "U", "D"
                //1. ID consulta
                //2. Denominación
                //3. Procedimiento almacenado
                //4. Estado
                //5. Descripción
                //6. Clave Web Service
                switch (aValores[0])
                {
                case "D":
                    CONSULTAPERSONAL.Delete(tr, int.Parse(aValores[1]));
                    break;

                case "I":
                    if (aValores[6] != "")
                    {
                        sClaveWS = Utilidades.unescape(aValores[6]).Trim();
                        //Compruebo que no exista ya esa clave
                        if (CONSULTAPERSONAL.ExisteClave(tr, sClaveWS, -1))
                        {
                            throw (new NullReferenceException("La clave del servicio web está asignada a otra consulta."));
                        }
                    }
                    idNuevaConsulta = CONSULTAPERSONAL.Insert(tr, Utilidades.unescape(aValores[2]), Utilidades.unescape(aValores[3]),
                                                              (aValores[4] == "1") ? true : false, Utilidades.unescape(aValores[5]),
                                                              Utilidades.unescape(aValores[6]));
                    sNuevosAEs += aValores[1] + "##" + idNuevaConsulta.ToString() + "@@";
                    break;

                case "U":
                    if (aValores[6] != "")
                    {
                        sClaveWS = Utilidades.unescape(aValores[6]).Trim();
                        //Compruebo que no exista ya esa clave
                        if (CONSULTAPERSONAL.ExisteClave(tr, sClaveWS, int.Parse(aValores[1])))
                        {
                            throw (new NullReferenceException("La clave del servicio web está asignada a otra consulta."));
                        }
                    }
                    CONSULTAPERSONAL.Update(tr, int.Parse(aValores[1]), Utilidades.unescape(aValores[2]), Utilidades.unescape(aValores[3]),
                                            (aValores[4] == "1") ? true : false, Utilidades.unescape(aValores[5]),
                                            Utilidades.unescape(aValores[6]));
                    break;
                }
            }
            #endregion

            #region PARAMETROS CONSULTA

            string[] aVAE = Regex.Split(strParametros, "///");

            foreach (string oVAE in aVAE)
            {
                if (oVAE == "")
                {
                    break;
                }
                string[] aKeysAE     = Regex.Split(sNuevosAEs, "@@");
                string[] aValoresVAE = Regex.Split(oVAE, "##");
                ///aValoresVAE[0] = opcionBD;
                ///aValoresVAE[1] = idConsulta;
                ///aValoresVAE[2] = idParámetro;
                ///aValoresVAE[3] = tipo;
                ///aValoresVAE[4] = comentario;
                ///aValoresVAE[5] = defecto;
                ///aValoresVAE[6] = visible;
                ///aValoresVAE[7] = orden;
                ///aValoresVAE[8] = texto;
                ///aValoresVAE[9] = nombre;
                ///aValoresVAE[10] = opcional;
                idConsulta = int.Parse(aValoresVAE[1]);
                if (idConsulta < 0)
                {
                    idConsulta = flBuscarKeyAE(aValoresVAE[1], aKeysAE);
                }

                switch (aValoresVAE[0])
                {
                case "I":
                    PARAMETROCONSULTAPERSONAL.Insert(tr, idConsulta,
                                                     Utilidades.unescape(aValoresVAE[8]),
                                                     Utilidades.unescape(aValoresVAE[9]),
                                                     aValoresVAE[3],
                                                     Utilidades.unescape(aValoresVAE[4]),
                                                     Utilidades.unescape(aValoresVAE[5]),
                                                     aValoresVAE[6],
                                                     byte.Parse(aValoresVAE[7]),
                                                     (aValoresVAE[10] == "0")?false:true);
                    break;

                case "U":
                    PARAMETROCONSULTAPERSONAL.Update(tr, idConsulta,
                                                     Utilidades.unescape(aValoresVAE[8]),
                                                     Utilidades.unescape(aValoresVAE[9]),
                                                     aValoresVAE[3],
                                                     Utilidades.unescape(aValoresVAE[4]),
                                                     Utilidades.unescape(aValoresVAE[5]),
                                                     aValoresVAE[6],
                                                     byte.Parse(aValoresVAE[7]),
                                                     (aValoresVAE[10] == "0") ? false : true);
                    break;

                case "D":
                    PARAMETROCONSULTAPERSONAL.Delete(tr, int.Parse(aValoresVAE[1]), Utilidades.unescape(aValoresVAE[2]));
                    break;
                }
            }
            #endregion

            Conexion.CommitTransaccion(tr);

            sResul = "OK@#@" + sNuevosAEs;
        }
        catch (Exception ex)
        {
            Conexion.CerrarTransaccion(tr);
            sResul = "Error@#@" + Errores.mostrarError("Error al grabar las consultas.", ex, false);
        }
        finally
        {
            Conexion.Cerrar(oConn);
        }
        return(sResul);
    }
Exemple #3
0
    protected void ObtenerParametros(int nIdConsulta)
    {
        StringBuilder sb = new StringBuilder();
        string        sChecked = "", sValor = "";

        try
        {
            SqlDataReader dr = PARAMETROCONSULTAPERSONAL.SelectByIdconsulta(null, nIdConsulta);

            sb.Append("<table id='tblDatos' class='texto' style='width: 700px;'>");
            sb.Append("<colgroup><col style='width:150px;' /><col style='width:150px;' /><col style='width:400px;' /></colgroup>");
            sb.Append("<tbody>");
            while (dr.Read())
            {
                sChecked = "";
                sValor   = "";
                sb.Append("<tr style=\"height: 20px; ");
                if (dr["t474_visible"].ToString() == "N")
                {
                    sb.Append("display:none; ");
                }
                else
                {
                    sb.Append("display:table-row; ");
                }
                sb.Append("\" ");
                if ((bool)dr["t474_opcional"])
                {
                    sb.Append("opcional=1 ");
                }
                else
                {
                    sb.Append("opcional=0 ");
                }
                sb.Append("tipoparam='" + dr["t474_tipoparametro"].ToString() + "' >");
                //sb.Append("<td>");
                switch (dr["t474_tipoparametro"].ToString())
                {
                case "I":
                    sb.Append("<td title='Entero' style='padding-left:3px;'>" + dr["t474_nombreparametro"].ToString() + "</td>");
                    sb.Append("<td>");
                    if (dr["t474_valordefecto"].ToString() != "")
                    {
                        sValor = int.Parse(dr["t474_valordefecto"].ToString()).ToString("#,###");
                    }
                    if (dr["t474_visible"].ToString() == "M")
                    {
                        sb.Append("<input type='text' class='txtNumM' style='width:60px;' value='" + sValor + "' onfocus='fn(this,9,0)' />");
                    }
                    else
                    {
                        sb.Append("<input type='text' class='txtNumL' style='width:60px;' value='" + dr["t474_valordefecto"].ToString() + "' readonly />");
                    }
                    break;

                case "V":
                    sb.Append("<td title='Carácter' style='padding-left:3px;'>" + dr["t474_nombreparametro"].ToString() + "</td>");
                    sb.Append("<td title='" + dr["t474_valordefecto"].ToString() + "'>");
                    if (dr["t474_visible"].ToString() == "M")
                    {
                        sb.Append("<input type='text' class='txtM' style='width:100px;' maxlength='7500' value='" + dr["t474_valordefecto"].ToString() + "' />");
                    }
                    else
                    {
                        sb.Append("<input type='text' class='txtL' style='width:140px;' value='" + dr["t474_valordefecto"].ToString() + "' readonly />");
                    }
                    break;

                case "M":
                    sb.Append("<td title='Importe' style='padding-left:3px;'>" + dr["t474_nombreparametro"].ToString() + "</td>");
                    sb.Append("<td>");
                    if (dr["t474_valordefecto"].ToString() != "")
                    {
                        sValor = double.Parse(dr["t474_valordefecto"].ToString()).ToString("N");
                    }
                    if (dr["t474_visible"].ToString() == "M")
                    {
                        sb.Append("<input type='text' class='txtNumM' style='width:60px;' value='" + sValor + "' onfocus='fn(this,9,2)' />");
                    }
                    else
                    {
                        sb.Append("<input type='text' class='txtNumL' style='width:60px;' value='" + sValor + "' readonly />");
                    }
                    break;

                case "D":
                    sb.Append("<td title='Fecha' style='padding-left:3px;'>" + dr["t474_nombreparametro"].ToString() + "</td>");
                    sb.Append("<td>");
                    if (dr["t474_visible"].ToString() == "M")
                    {
                        if (Session["BTN_FECHA"].ToString() == "I")
                        {
                            sb.Append("<input type='text' id='" + dr["t472_idconsulta"].ToString() + dr["t474_textoparametro"].ToString().Trim() + "' class='txtM MANO' style='width:60px;' value='" + dr["t474_valordefecto"].ToString() + "' Calendar='oCal' onclick='mc(event);' readonly='true' />");
                        }
                        else
                        {
                            sb.Append("<input type='text' id='" + dr["t472_idconsulta"].ToString() + dr["t474_textoparametro"].ToString().Trim() + "' class='txtM MANO' style='width:60px;' value='" + dr["t474_valordefecto"].ToString() + "' Calendar='oCal' onfocus='focoFecha(event);' onmousedown='mc1(event)'/>");
                        }
                    }
                    else
                    {
                        sb.Append("<input type='text' id='" + dr["t472_idconsulta"].ToString() + dr["t474_textoparametro"].ToString().Trim() + "' class='txtM MANO' style='width:60px;' value='" + dr["t474_valordefecto"].ToString() + "' readonly />");
                    }
                    break;

                case "B":
                    sb.Append("<td title='Booleano' style='padding-left:3px;'>" + dr["t474_nombreparametro"].ToString() + "</td>");
                    sb.Append("<td>");
                    if (dr["t474_valordefecto"].ToString() == "1")
                    {
                        sChecked = "checked";
                    }
                    else
                    {
                        sChecked = "";
                    }
                    if (dr["t474_visible"].ToString() == "M")
                    {
                        sb.Append("<input type='checkbox' class='check' " + sChecked + " />");
                    }
                    else
                    {
                        sb.Append("<input type='checkbox' class='check' " + sChecked + " disabled />");
                    }
                    break;

                case "A":
                    sb.Append("<td title='Mes y año' style='padding-left:3px;'>" + dr["t474_nombreparametro"].ToString() + "</td>");
                    sb.Append("<td>");
                    if (dr["t474_visible"].ToString() == "M")
                    {
                        sb.Append("<input type='text' class='txtM MANO' style='width:90px;text-align:center;' value='" + dr["t474_valordefecto"].ToString() + " 'readonly onclick='getMesValor(this)' />");
                    }
                    else
                    {
                        sb.Append("<input type='text' class='txtM MANO' style='width:90px;text-align:center;' value='" + dr["t474_valordefecto"].ToString() + "' readonly />");
                    }
                    break;
                }
                sb.Append("</td>");

                sb.Append("<td style='padding-left:3px;'><nobr class='NBR W300'>" + dr["t474_comentarioparametro"].ToString() + "</nobr></td>");
                sb.Append("</tr>");
            }
            dr.Close();
            dr.Dispose();
            sb.Append("</tbody>");
            sb.Append("</table>");
            strTablaHTML = sb.ToString();
        }
        catch (Exception ex)
        {
            sErrores = Errores.mostrarError("Error al obtener la relación de parámetros.", ex);
        }
    }