protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.Form["data"] != null)
                {
                    string data      = Request.Form["data"].ToString();
                    var    req       = DataTableParameters.Get(data);
                    var    resultSet = new DataTableResultSet();

                    resultSet.draw            = req.Draw;
                    resultSet.recordsTotal    = 20;
                    resultSet.recordsFiltered = 20;

                    //foreach (var recordFromDb in queryDb)
                    //{ /* this is pseudocode */
                    //    var columns = new List<string>();
                    //    columns.Add("first column value");
                    //    columns.Add("second column value");
                    //    columns.Add("third column value");
                    //    /* you may add as many columns as you need. Each column is a string in the List<string> */
                    //    resultSet.data.Add(columns);
                    //}
                    SendResponse(HttpContext.Current.Response, resultSet);
                }
            }
        }
Esempio n. 2
0
        public void Data(object parameters)
        {
            var req       = DataTableParameters.Get(parameters);
            var resultSet = new DataTableResultSet();

            Secciones Datos = new Secciones();

            Datos.Start       = req.Start;
            Datos.Length      = req.Length;
            Datos.SearchValue = req.SearchValue;
            Datos.OrderBy     = -1;
            if (req.Order.Count > 0)
            {
                foreach (var aux in req.Order.Keys)
                {
                    Datos.OrderBy        = req.Order[aux].Column;
                    Datos.OrderDirection = req.Order[aux].Direction;
                }
            }
            Datos.Conexion = Comun.Conexion;
            SeccionesNegocio neg = new SeccionesNegocio();

            neg.ObtenerSeccionesAJAX(Datos);
            resultSet.draw            = req.Draw;
            resultSet.recordsTotal    = Datos.RecordTotal;
            resultSet.recordsFiltered = Datos.RecordFilter;

            foreach (Secciones Item in Datos.ListaSecciones)
            {
                var columns = new List <string>();
                columns.Add(Item.IDSeccion.ToString());
                columns.Add(Item.TipoSeccion);
                string acciones = @"<div class='visible-md visible-lg hidden-sm hidden-xs'>
                                        <a href='frmSeccionDetalle.aspx?id=" + Item.IDSeccion + @"' class='btn btn-xs btn-blue tooltips' data-placement='top' data-original-title='Ver'> <i class='fa fa-edit'> </i> </a>
									</div>
									<div class='visible-xs visible-sm hidden-md hidden-lg'>
									    <div class='btn-group'>
											<a class='btn btn-green dropdown-toggle btn-sm' data-toggle='dropdown' href='#'>
												<i class='fa fa-cog'></i> <span class='caret'></span>
											</a>
											<ul role = 'menu' class='dropdown-menu pull-right dropdown-dark'>
												<li>														
                                                    <a href='frmSeccionDetalle.aspx?id=" + Item.IDSeccion + @"' role='menuitem' tabindex='-1' class='tooltips' data-placement='top' data-original-title='Ver'><i class='fa fa-edit'></i>Ver</a>
												</li>
											</ul>
										</div>
									</div>"                                    ;
                columns.Add(acciones);


                resultSet.data.Add(columns);
            }
            SendResponse(HttpContext.Current.Response, resultSet);
        }
        public void Data(object parameters, bool bandDatosComp)
        {
            var req       = DataTableParameters.Get(parameters);
            var resultSet = new DataTableResultSet();

            Afiliados Datos = new Afiliados();

            Datos.Start            = req.Start;
            Datos.Length           = req.Length;
            Datos.SearchValue      = req.SearchValue;
            Datos.OrderBy          = -1;
            Datos.TipoBusqueda     = -1;
            Datos.FechaInicio      = DateTime.Today;
            Datos.FechaFin         = DateTime.Today;
            Datos.DatosCompletados = bandDatosComp;
            if (req.Order.Count > 0)
            {
                foreach (var aux in req.Order.Keys)
                {
                    Datos.OrderBy        = req.Order[aux].Column;
                    Datos.OrderDirection = req.Order[aux].Direction;
                }
            }

            foreach (var busq in req.Columns.Keys)
            {
                if (!string.IsNullOrEmpty(req.Columns[busq].SearchValue))
                {
                    Datos.TipoBusqueda = busq;
                    Datos.SearchValue  = req.Columns[busq].SearchValue;
                    break;
                }
            }

            switch (Datos.TipoBusqueda)
            {
            case 2:
                DateTime Fecha1 = DateTime.Today;
                DateTime Fecha2 = DateTime.Today;
                string[] s      = Datos.SearchValue.Split('-');
                if (s.Length == 2)
                {
                    DateTime.TryParseExact(s[0].Trim(), "MMddyyyy", CultureInfo.CurrentCulture, System.Globalization.DateTimeStyles.None, out Fecha1);
                    DateTime.TryParseExact(s[1].Trim(), "MMddyyyy", CultureInfo.CurrentCulture, System.Globalization.DateTimeStyles.None, out Fecha2);
                    Datos.FechaInicio = Fecha1;
                    Datos.FechaFin    = Fecha2;
                }
                break;

            case 1:
                int Ratificado = 0;
                int.TryParse(Datos.SearchValue, out Ratificado);
                Datos.Ratificado = (Ratificado == 1);
                break;

            case 3:
                int Seccion = 0;
                int.TryParse(Datos.SearchValue, out Seccion);
                Datos.Seccion = Seccion;
                break;

            case -1:
                if (!string.IsNullOrEmpty(Datos.SearchValue))
                {
                    Datos.TipoBusqueda = 0;
                }
                break;

            default:
                break;
            }

            Datos.Conexion = Comun.Conexion;
            AfiliadosNegocio neg = new AfiliadosNegocio();

            neg.ObtenerAfiliadosAJAX(Datos);
            resultSet.draw            = req.Draw;
            resultSet.recordsTotal    = Datos.RecordTotal;
            resultSet.recordsFiltered = Datos.RecordFilter;

            foreach (Afiliados Item in Datos.ListaAfiliados)
            {
                var columns = new List <string>();
                columns.Add(Item.Nombre);
                columns.Add(Item.FechaAfiliacionString);
                string estatusHtml = Item.Ratificado ? "<span class='label label-sm label-success'>Ratificado</span>" : "<span class='label label-sm label-danger'>No ratificado</span>";
                columns.Add(estatusHtml);
                columns.Add(Item.Seccion.ToString());
                columns.Add(Item.ClaveElector);
                columns.Add(Item.Operador);
                string acciones = @"<div class='visible-md visible-lg hidden-sm hidden-xs'>
                                        <a href='" + (!bandDatosComp ? string.Format("frmCompletarAfiliado.aspx?op=2&id={0}", Item.IDAfiliado): string.Format("frmNuevoAfiliado.aspx?op=2&id={0}", Item.IDAfiliado)) + @"' class='btn btn-xs btn-blue tooltips' data-placement='top' data-original-title='Ver'> <i class='fa fa-edit fa fa-white'> </i> </a>
                                        <a href='/afiliadosService.asmx/Delete' class='btn btn-xs btn-red tooltips deleteRow' data-sku='" + Item.IDAfiliado + @"' data-placement='top' data-original-title='Ver'> <i class='fa fa-times fa fa-white'> </i> </a>
									</div>
									<div class='visible-xs visible-sm hidden-md hidden-lg'>
									    <div class='btn-group'>
											<a class='btn btn-green dropdown-toggle btn-sm' data-toggle='dropdown' href='#'>
												<i class='fa fa-cog'></i> <span class='caret'></span>
											</a>
											<ul role = 'menu' class='dropdown-menu pull-right dropdown-dark'>
												<li>														
                                                    <a href='" + (!bandDatosComp ? string.Format("frmCompletarAfiliado.aspx?op=2&id={0}", Item.IDAfiliado) : string.Format("frmNuevoAfiliado.aspx?op=2&id={0}", Item.IDAfiliado)) + @"' role='menuitem' tabindex='-1' class='tooltips' data-placement='top' data-original-title='Ver'><i class='fa fa-edit'></i>Ver</a>
												</li>
                                                <li>
                                                    <a href='/afiliadosService.asmx/Delete' role='menuitem' tabindex='-1' class='tooltips deleteRow' data-placement='top' data-sku='" + Item.IDAfiliado + @"' data-original-title='Ver'><i class='fa fa-times'></i>Eliminar</a>
												</li>
											</ul>
										</div>
									</div>"                                    ;
                columns.Add(acciones);


                resultSet.data.Add(columns);
            }
            SendResponse(HttpContext.Current.Response, resultSet);
        }