private void obtenerConsultas()
    {
        try
        {
            StringBuilder sb = new StringBuilder();
            SqlDataReader dr = CONSULTAPERSONAL.ObtenerCatalogo(null, true);

            sb.Append("<table id='tblDatos' class='texto MANO' style='WIDTH: 500px;'>");
            sb.Append("<colgroup><col style='width:500px;' /></colgroup>");
            while (dr.Read())
            {
                sb.Append("<tr id='" + dr["t472_idconsulta"].ToString() + "' onclick='ms(this);getProf(this.id)'>");
                //sb.Append("<td><input type='text' class='txtL' style='width:500px' value='" + dr["t472_denominacion"].ToString() + "' maxlength='50'></td></tr>");
                sb.Append("<td>" + dr["t472_denominacion"].ToString() + "</td></tr>");
            }
            dr.Close();
            dr.Dispose();

            sb.Append("</table>");
            strTablaHTML = sb.ToString();
        }
        catch (Exception ex)
        {
            Errores.mostrarError("Error al cargar las consultas", ex);
        }
    }
    public string ObtenerIntegrantes(int iCodCons)
    {// Devuelve el código HTML del catalogo de personas que están asociadas a la consulta que se pasa como parametro
        StringBuilder sb = new StringBuilder();
        string        sCod, sDes;
        bool          bActivo;

        try
        {
            SqlDataReader dr = CONSULTAPERSONAL.GetProf(null, iCodCons);
            sb.Append("<table id='tblOpciones2' class='texto MM' style='width:400px;' mantenimiento='1'>");
            sb.Append("<colgroup>");
            sb.Append(" <col style='width:15px;' />");
            sb.Append(" <col style='width:20px;' />");
            sb.Append(" <col style='width:330px;' />");
            sb.Append(" <col style='width:35px;' />");
            sb.Append("</colgroup>");
            sb.Append("<tbody id='tbodyDestino'>");
            while (dr.Read())
            {
                sCod    = dr["t314_idusuario"].ToString();
                sDes    = dr["nombre"].ToString();
                bActivo = bool.Parse(dr["t473_estado"].ToString());

                sb.Append("<tr id='" + sCod + "' bd='' onClick='mm(event)' style='height:20px' onmousedown='DD(event)' ");
                //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>" + sDes.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) + "<br><label style='width:70px;'>Empresa:</label>" + dr["empresa"].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>" + sDes.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(" sexo='" + dr["t001_sexo"].ToString() + "' ");
                sb.Append(" baja='" + dr["baja"].ToString() + "' ");
                //if (dr["t303_denominacion"].ToString() == "") sb.Append("tipo='E' ");
                //else sb.Append("tipo='P' ");
                sb.Append("tipo='" + dr["tipo"].ToString() + "' ");

                sb.Append("><td></td><td></td><td><nobr class='NBR W320'>" + sDes + "</NOBR></label></td>");
                sb.Append("<td style='padding-rigth:10px;'><input type='checkbox' class='checkTabla'");
                if (bActivo)
                {
                    sb.Append(" checked='true' ");
                }
                sb.Append(" onclick=\"activarGrabar();mfa(this.parentNode.parentNode,'U')\"></td></tr>");
            }
            sb.Append("</tbody></table>");
            dr.Close();
            dr.Dispose();
            return("OK@#@" + sb.ToString());
        }
        catch (Exception)
        {
            //Master.sErrores = Errores.mostrarError("Error al obtener las personas", ex);
            return("error@#@");
        }
    }
Example #3
0
    protected string preEliminarConsulta(string strIDAE)
    {
        string sResul    = "";
        int    iNumElems = 0;

        #region abrir conexión y transacción
        try
        {
            oConn = Conexion.Abrir();
            tr    = Conexion.AbrirTransaccion(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

        try
        {
            string[] aAE = Regex.Split(strIDAE, "##");
            foreach (string oAE in aAE)
            {
                //AE.Delete(tr, int.Parse(oAE));
                iNumElems = CONSULTAPERSONAL.numUsuarios(int.Parse(oAE));
            }
            Conexion.CommitTransaccion(tr);

            sResul = "OK@#@" + iNumElems.ToString();
        }
        catch (Exception ex)
        {
            Conexion.CerrarTransaccion(tr);
            sResul = "Error@#@" + Errores.mostrarError("Error al intentar eliminar consultas", ex);
        }
        finally
        {
            Conexion.Cerrar(oConn);
        }

        return(sResul);
    }
    private void getConsultaPersonalizada(string sParametros)
    {
        svcEXCEL.IsvcEXCELClient osvcEXCEL = null;
        try
        {
            string   sExtension = "xls";
            string[] aParam     = Regex.Split(sParametros, "@#@");
            //string sNombreArchivo = SUPER.Capa_Negocio.Utilidades.unescape(aParam[0]) + "_" + DateTime.Now.ToString() + "." + sExtension;
            string   sNombreArchivo = aParam[0] + "-" + DateTime.Now.ToString() + "." + sExtension;
            string   sProdAlm       = aParam[1];
            string[] aParametros    = Regex.Split(aParam[2], "///");
            //object[] aObjetos = new object[(sParametros == "") ? 1 : aParametros.Length + 1];
            object[] aObjetos = new object[(aParam[2] == "") ? 1 : aParametros.Length + 1];
            aObjetos[0] = Utilidades.GetUserActual();
            #region Cargo parámetros
            int v = 1;
            foreach (string oParametro in aParametros)
            {
                if (oParametro == "")
                {
                    continue;
                }
                string[] aDatos = Regex.Split(oParametro, "##");
                switch (aDatos[0])
                {
                case "A": aObjetos[v] = int.Parse(aDatos[1]); break;

                case "M": aObjetos[v] = double.Parse(aDatos[1].Replace(".", ",")); break;

                case "B": aObjetos[v] = (aDatos[1] == "1") ? true : false; break;

                default: aObjetos[v] = aDatos[1]; break;
                }
                v++;
            }
            #endregion
            DataSet ds = CONSULTAPERSONAL.EjecutarConsultaDS(sProdAlm, aObjetos);

            osvcEXCEL      = new svcEXCEL.IsvcEXCELClient();
            ArchivoBinario = osvcEXCEL.getExcelFromDataSet(ds, sExtension);

            Response.AddHeader("Content-Disposition", "attachment; filename=\"" + Utilidades.CleanFileName(sNombreArchivo) + "\"");
            Response.BinaryWrite(ArchivoBinario);

            if (Response.IsClientConnected)
            {
                Response.Flush();
            }
        }
        catch (FaultException <svcEXCEL.IBOfficeException> cex)
        {
            Response.ContentType = "text/HTML";
            this.hdnError.Value  = "Error: Código:" + cex.Detail.ErrorCode + ". Descripción: " + cex.Detail.Message;// +" " + cex.Detail.InnerMessage;

            if (cex.InnerException != null)
            {
                this.hdnError.Value += ". InnerException: descripción=" + cex.InnerException.Message;
            }
        }
        catch (Exception ex)
        {
            Response.ContentType = "text/HTML";
            this.hdnError.Value  = "Error: " + ex.ToString();
        }
        finally
        {
            if (osvcEXCEL != null && osvcEXCEL.State != System.ServiceModel.CommunicationState.Closed)
            {
                if (osvcEXCEL.State != System.ServiceModel.CommunicationState.Faulted)
                {
                    osvcEXCEL.Close();
                }
                else if (osvcEXCEL.State != System.ServiceModel.CommunicationState.Closed)
                {
                    osvcEXCEL.Abort();
                }
            }
        }
    }
Example #5
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);
    }
Example #6
0
    private string obtenerConsultas(string sActivos)
    {
        try
        {
            string        sParams = "", sProcAlm;
            StringBuilder sb = new StringBuilder();
            SqlDataReader dr = CONSULTAPERSONAL.ObtenerCatalogo(null, (sActivos == "1") ? true : false);

            sb.Append("<table id='tblDatos' class='texto MA' style='width:940px;' mantenimiento='1'>");
            sb.Append("<colgroup><col style='width:10px;' /><col style='width:300px;' /><col style='width:65px;' /><col style='width:220px;' /><col style='width:30px;' /><col style='width:200px;' /><col style='width:115px;' /></colgroup>");
            sb.Append("<tbody id='tbodyDatos'>");

            while (dr.Read())
            {
                sb.Append("<tr id='" + dr["t472_idconsulta"].ToString() + "' bd='' ");
                sb.Append("style='height:20px;' onclick='ms(this);refrescarParams(this.id);habCom();' ondblclick='setProfesionales(this.id)'>");
                sb.Append("<td><img src='../../../../images/imgFN.gif'></td>");
                sb.Append("<td><input type='text' class='txtL' style='width:295px' value='" + dr["t472_denominacion"].ToString() + "' maxlength='50' onKeyUp='fm(event)'></td>");

                //sb.Append("<td>SUP_USER_</td>");
                sb.Append("<td><input type='text' class='txtL' style='width:65px' value='SUP_USER_' readonly='true'></td>");
                sb.Append("<td><input type='text' class='txtL' style='width:220px' value='");
                sProcAlm = dr["t472_procalm"].ToString();
                if (sProcAlm.Length < 8)
                {
                    sb.Append(sProcAlm);
                }
                else
                {
                    if (sProcAlm.StartsWith("SUP_USER_"))
                    {
                        sb.Append(sProcAlm.Substring(9));
                    }
                    else
                    {
                        int iLen = sProcAlm.Length;
                        if (iLen > 21)
                        {
                            iLen = 21;
                        }
                        sb.Append(sProcAlm.Substring(0, iLen));
                    }
                }
                sb.Append("' maxlength='21' onKeyUp='fm(event)'></td>");
                sb.Append("<td><input type='checkbox' style='width:15px;' class='check' onclick='fm(event)' ");
                if ((bool)dr["t472_estado"])
                {
                    sb.Append("checked=true");
                }
                sb.Append("></td>");
                sb.Append("<td><nobr class='NBR W190' onmouseover='TTip(event)' style='height:16px;'>" + dr["t472_descripcion"].ToString().Replace(((char)13).ToString(), "<br>") + "</nobr></td>");
                if (User.IsInRole("DIS"))
                {
                    sb.Append("<td><input type='text' class='txtL' style='width:105px' value='" + dr["t472_clavews"].ToString() + "' maxlength='20' onKeyUp='fm(event)'></td>");
                }
                else
                {
                    sb.Append("<td><input type='text' class='txtL' style='width:105px' value='" + dr["t472_clavews"].ToString() + "' maxlength='20' readonly='true'></td>");
                }
                sb.Append("</tr>");
            }
            dr.Close();
            dr.Dispose();

            sb.Append("</tbody>");
            sb.Append("</table>");
            //Cargo un array con todos los valores de todas las consultas
            //Ese array es necesario para poder realizar la grabación de los parametros de las diferentes consultas del catálogo
            sParams = ObtenerParametrosConsulta(sActivos);

            return("OK@#@" + sb.ToString() + "@#@" + sParams);
        }
        catch (Exception ex)
        {
            return("Error@#@" + Errores.mostrarError("Error al cargar las consultas", ex));
        }
    }