示例#1
0
        /// <summary>
        ///
        /// Sortear la grilla. comportamiento general
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void GV_COnvocatoria_Sorting(object sender, GridViewSortEventArgs e)
        {
            var dt = HttpContext.Current.Session["dtEmpresas"] as DataTable;

            if (dt != null)
            {
                dt.DefaultView.Sort        = e.SortExpression + " " + GetSortDirection(e.SortExpression);
                GV_COnvocatoria.DataSource = HttpContext.Current.Session["dtEmpresas"];
                GV_COnvocatoria.DataBind();
            }
        }
示例#2
0
        protected void GV_COnvocatoria_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            var dt = HttpContext.Current.Session["dtEmpresas"] as DataTable;

            if (dt != null)
            {
                GV_COnvocatoria.PageIndex  = e.NewPageIndex;
                GV_COnvocatoria.DataSource = dt;
                GV_COnvocatoria.DataBind();
            }
        }
示例#3
0
        private void llenarGrilla(String str)
        {
            txtCondicion = "";

            if (DDL_Convocatoria.SelectedValue != "")
            {
                String sql = " SELECT DISTINCT P.ID_PROYECTO 'CODIGO', P.NOMPROYECTO 'NOMPROYECTO', " +
                             " CASE WHEN PC.CODCONTACTO IS NULL THEN 'No Asignado' ELSE 'Asignado' END 'Acreditador', " +
                             " (C.NOMBRES + ' ' + C.APELLIDOS) 'NOMACREDITADOR', " +
                             " PC.CODCONTACTO, MAX(PC.FECHAINICIO) 'FechaAsignacion' " +
                             " FROM PROYECTO P JOIN CONVOCATORIAPROYECTO CP " +
                             " ON (CP.CODCONVOCATORIA=" + DDL_Convocatoria.SelectedValue + " AND CP.CODPROYECTO=P.ID_PROYECTO) " +
                             " LEFT JOIN PROYECTOCONTACTO PC " +
                             " ON (PC.INACTIVO=0 AND PC.CODCONVOCATORIA = CP.CODCONVOCATORIA AND PC.ACREDITADOR=1 " +
                             " AND PC.CODPROYECTO=P.ID_PROYECTO) LEFT JOIN CONTACTO C " +
                             " ON (PC.CODCONTACTO = C.ID_CONTACTO AND PC.CODPROYECTO=P.ID_PROYECTO) " +
                             " where P.CodEstado in (3,10,11,12,15,16) and not exists(select * from ConvocatoriaProyecto where codproyecto = P.Id_Proyecto and ConvocatoriaProyecto.codConvocatoria >" + DDL_Convocatoria.SelectedValue + " )";

                if (str.Trim() != "")
                {
                    if (txtCondicion.Length > 0)
                    {
                        txtCondicion = txtCondicion + " AND ";
                    }
                    else
                    {
                        txtCondicion = " AND ";
                    }
                    txtCondicion = txtCondicion + " P.NOMPROYECTO LIKE '" + str + "%'";
                }

                if (!String.IsNullOrEmpty(txtBuscar))
                {
                    if (txtCondicion.Length > 0)
                    {
                        txtCondicion = txtCondicion + " AND ";
                    }
                    else
                    {
                        txtCondicion = " AND ";
                    }

                    Int32 number;
                    if (Int32.TryParse(txtBuscar, out number))
                    {
                        txtCondicion = txtCondicion + " (P.NOMPROYECTO LIKE '%" + txtBuscar + "%'   OR P.ID_PROYECTO = " + txtBuscar + ")";
                    }
                    else
                    {
                        txtCondicion = txtCondicion + " P.NOMPROYECTO LIKE '%" + txtBuscar + "%'";
                    }
                }

                sql = sql + txtCondicion + " GROUP BY P.ID_PROYECTO,P.NOMPROYECTO,C.NOMBRES,C.APELLIDOS,PC.CODCONTACTO ";

                //Inicializar grilla.
                llenadoGrilla = new DataTable();

                //Asignar los resultados de la consulta a variable DataTable.
                llenadoGrilla = consultas.ObtenerDataTable(sql, "text");

                //Nueva columna para mostrar los valores formateados.
                llenadoGrilla.Columns.Add("a_FechaAsignacion", typeof(System.String));

                //Recorrer cada fila de la grilla para que en la columna generada se agregue la fecha de asignación formateada.
                foreach (DataRow row in llenadoGrilla.Rows)
                {
                    if (row["FechaAsignacion"].ToString().Trim() != "")
                    {
                        DateTime fecha = new DateTime();
                        String   dat   = "";
                        fecha = DateTime.Parse(row["FechaAsignacion"].ToString());
                        dat   = fecha.ToString("dd/MM/yyyy hh:mm:ss tt", System.Globalization.CultureInfo.CreateSpecificCulture("es-CO"));
                        try { row["a_FechaAsignacion"] = dat; }
                        catch { row["FechaAsignacion"] = row["FechaAsignacion"]; }
                        fecha = new DateTime();
                        dat   = null;
                    }
                    else
                    {
                        try { row["a_FechaAsignacion"] = ""; }
                        catch { row["FechaAsignacion"] = ""; }
                    }
                }

                //Bindear la grilla.
                HttpContext.Current.Session["dtEmpresas"] = llenadoGrilla;
                GV_COnvocatoria.DataSource = llenadoGrilla;
                GV_COnvocatoria.DataBind();
            }
            else
            {
                System.Web.UI.ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Mensaje", "alert('Debe seleccionar una convocatoria.')", true);
                return;
            }
        }