public JsonResult Listar(GridTable grid)
        {
            var jqgrid = new JGrid();

            try
            {
                var nombreFiltros = new[] { "IdOperacion", "Documento", "FechaDocumento", "AlmacenOrigen", "AlmacenDestino", "Estado" };
                var lista         = CrearJGrid(SalidaTransferenciaAlmacenBL.Instancia, grid, nombreFiltros, ref jqgrid);

                jqgrid.rows = lista.Select(item => new JRow
                {
                    id   = item.IdTransaccion.ToString(),
                    cell = new[]
                    { item.IdTransaccion.ToString(),
                      item.Documento,
                      item.FechaDocumento.ToShortDateString(),
                      AlmacenBL.Instancia.Single(item.IdAlmacen).Nombre,
                      AlmacenBL.Instancia.Single(item.IdAlmacenAlterno).Nombre,
                      item.NombreEstado }
                }).ToArray();
            }
            catch (Exception ex)
            {
                MostrarError(ex.Message);
            }

            return(Json(jqgrid));
        }
Esempio n. 2
0
        protected JGrid CrearJgrid(GridTable grid, int cantidad)
        {
            var totalPaginas = 0;

            grid.page = (grid.page == 0) ? 1 : grid.page;
            grid.rows = (grid.rows == 0) ? 100 : grid.rows;

            if (cantidad > 0 && grid.rows > 0)
            {
                var div   = cantidad / (decimal)grid.rows;
                var round = Math.Ceiling(div);
                totalPaginas = Convert.ToInt32(round);
                totalPaginas = totalPaginas == 0 ? 1 : totalPaginas;
            }

            grid.page = grid.page > totalPaginas ? totalPaginas : grid.page;

            var start = grid.rows * grid.page - grid.rows;

            if (start < 0)
            {
                start = 0;
            }

            var jqgrid = new JGrid
            {
                total   = totalPaginas,
                page    = grid.page,
                records = cantidad,
                start   = start,
            };

            return(jqgrid);
        }
Esempio n. 3
0
        public JsonResult Listar(GridTable grid)
        {
            var jqgrid = new JGrid();

            try
            {
                var nombreFiltros = new[] { "Nombre", "Empresa", "EsPrincipal", "Estado" };
                var lista         = CrearJGrid(SucursalBL.Instancia, grid, nombreFiltros, ref jqgrid);

                jqgrid.rows = lista.Select(item => new JRow
                {
                    id   = item.IdSucursal.ToString(),
                    cell = new[]
                    {
                        item.IdSucursal.ToString(),
                        item.NombreEmpresa,
                        item.Nombre,
                        item.Telefono,
                        item.EsPrincipal ? "SI" : "NO",
                        item.NombreEstado
                    }
                }).ToArray();
            }
            catch (Exception ex)
            {
                MostrarError(ex.Message);
            }
            return(Json(jqgrid));
        }
Esempio n. 4
0
        public JsonResult Listar(GridTable grid)
        {
            var jqgrid = new JGrid();

            try
            {
                var nombreFiltros = new[] { "Nombre", "Username", "NombreRol", "Estado" };
                var lista         = CrearJGrid(UsuarioBL.Instancia, grid, nombreFiltros, ref jqgrid);

                jqgrid.rows = lista.Select(item => new JRow
                {
                    id   = item.IdEmpleado.ToString(),
                    cell = new[]
                    {
                        item.IdEmpleado.ToString(),
                        item.NombreEmpleado,
                        item.Username,
                        item.NombreRol,
                        item.NombreEstado
                    }
                }).ToArray();
            }
            catch (Exception ex)
            {
                MostrarError(ex.Message);
            }
            return(Json(jqgrid));
        }
Esempio n. 5
0
        public JsonResult Listar(GridTable grid)
        {
            var jqgrid = new JGrid();

            try
            {
                var nombreFiltros = new[] { "NombrePersona", "NombreCargo", "FechaCreacion", "Telefono", "Estado", "IdFuncion" };
                var lista         = CrearJGrid(EmpleadoBL.Instancia, grid, nombreFiltros, ref jqgrid);

                jqgrid.rows = lista.Select(item => new JRow
                {
                    id   = item.IdEmpleado.ToString(),
                    cell = new[]
                    {
                        item.IdEmpleado.ToString(),
                        item.NombrePersona,
                        item.NombreCargo,
                        item.FechaCreacion.ToShortDateString(),
                        item.NumeroTelefono,
                        item.NombreEstado
                    }
                }).ToArray();
            }
            catch (Exception ex)
            {
                MostrarError(ex.Message);
            }

            return(Json(jqgrid));
        }
Esempio n. 6
0
        public JsonResult Listar(GridTable grid)
        {
            var jqgrid = new JGrid();

            try
            {
                var nombreFiltros = new[] { "Codigo", "CodigoAlterno", "Nombre", "Descripcion", "TipoProducto" };
                var lista         = CrearJGrid(ProductoBL.Instancia, grid, nombreFiltros, ref jqgrid);

                jqgrid.rows = lista.Select(item => new JRow
                {
                    id   = item.IdProducto.ToString(),
                    cell = new[]
                    {
                        item.IdProducto.ToString(),
                        item.Codigo,
                        item.CodigoAlterno,
                        item.Nombre,
                        item.Descripcion.ToString(),
                    }
                }).ToArray();
            }
            catch (Exception ex)
            {
                MostrarError(ex.Message);
            }

            return(Json(jqgrid));
        }
        public JsonResult Listar(GridTable grid, int id)
        {
            var jqgrid = new JGrid();

            try
            {
                var nombreFiltros = new[] { "Nombre", "Descripcion", "IdParent", "IdEstructuraProducto" };
                var lista         = CrearJGrid(DatoEstructuraBL.Instancia, grid, nombreFiltros, ref jqgrid);

                jqgrid.rows = lista.Select(item => new JRow
                {
                    id   = item.IdDatoEstructura.ToString(),
                    cell = new[]
                    {
                        item.IdDatoEstructura.ToString(),
                        item.Nombre,
                        item.Descripcion,
                        item.IdParent.HasValue ? DatoEstructuraBL.Instancia.Single(item.IdParent).Nombre : string.Empty,
                        item.IdEstructuraProducto.ToString()
                    }
                }).ToArray();
            }
            catch (Exception ex)
            {
                MostrarError(ex.Message);
            }
            return(Json(jqgrid));
        }
Esempio n. 8
0
        public JsonResult Listar(GridTable grid)
        {
            var jqgrid = new JGrid();

            try
            {
                var nombreFiltros = new[] { "Codigo", "FullName", "Direccion", "Telefono", "Estado", "IdFuncion" };
                var lista         = CrearJGrid(PersonaBL.Instancia, grid, nombreFiltros, ref jqgrid);

                jqgrid.rows = lista.Select(item => new JRow
                {
                    id   = item.IdPersona.ToString(),
                    cell = new[]
                    {
                        item.Codigo.ToString(),
                        item.FullName,
                        item.Direccion ?? "",
                        item.Telefono != null
                                        ? item.Telefono.ToString()
                                        : "",
                        item.NombreEstado
                    }
                }).ToArray();
            }
            catch (Exception ex)
            {
                MostrarError(ex.Message);
            }

            return(Json(jqgrid));
        }
        public JsonResult Listar(GridTable grid)
        {
            var jqgrid = new JGrid();

            try
            {
                var nombreFiltros = new[] { "IdOperacion", "Documento", "FechaDocumento", "Estado" };
                var lista         = CrearJGrid(DistribucionMercaderiaBL.Instancia, grid, nombreFiltros, ref jqgrid);

                jqgrid.rows = lista.Select(item => new JRow
                {
                    id   = item.IdTransaccion.ToString(),
                    cell = new[]
                    { item.IdTransaccion.ToString(),
                      item.Documento,
                      item.NumeroDocumentoRef,
                      item.FechaDocumento.ToShortDateString(),
                      item.NombreEstado }
                }).ToArray();
            }
            catch (Exception ex)
            {
                MostrarError(ex.Message);
            }

            return(Json(jqgrid));
        }
Esempio n. 10
0
        public JsonResult ListarGeneral(GridTable grid)
        {
            var jqgrid = new JGrid();

            try
            {
                var nombreFiltros = new[] { "Nombre", "Descripcion", "Estado" };
                var lista         = CrearJGrid(TablaBL.Instancia, grid, nombreFiltros, ref jqgrid);

                jqgrid.rows = lista.Select(item => new JRow
                {
                    id   = item.IdTabla.ToString(),
                    cell = new[]
                    {
                        item.IdTabla.ToString(),
                        item.Nombre,
                        item.Descripcion,
                        item.NombreEstado
                    }
                }).ToArray();
            }
            catch (Exception ex)
            {
                MostrarError(ex.Message);
            }
            return(Json(jqgrid));
        }
Esempio n. 11
0
        public JsonResult Listar(GridTable grid)
        {
            var jqgrid = new JGrid();

            try
            {
                var nombreFiltros = new[] { "TipoDocumento", "Serie", "NumeroActual", "NumeroInicio", "NumeroFinal", "FechaCreacion" };
                var lista         = CrearJGrid(SerieDocumentoBL.Instancia, grid, nombreFiltros, ref jqgrid);

                jqgrid.rows = lista.Select(item => new JRow
                {
                    id   = item.IdSerieDocumento.ToString(),
                    cell = new[]
                    {
                        item.IdSerieDocumento.ToString(),
                        ItemTablaBL.Instancia.Single((int)TipoTabla.TipoComprobante, item.TipoDocumento).Nombre,
                        item.Serie,
                        item.NumeroActual,
                        item.NumeroInicio,
                        item.NumeroFinal,
                        item.FechaCreacion.ToShortDateString(),
                    }
                }).ToArray();
            }
            catch (Exception ex)
            {
                MostrarError(ex.Message);
            }
            return(Json(jqgrid));
        }
Esempio n. 12
0
        public JsonResult Listar(GridTable grid)
        {
            var jqgrid = new JGrid();

            try
            {
                var nombreFiltros = new[] { "Codigo", "Nombre", "SignoStock", "SignoCaja", "SignoContable", "Estado" };
                var lista         = CrearJGrid(OperacionBL.Instancia, grid, nombreFiltros, ref jqgrid);

                jqgrid.rows = lista.Select(item => new JRow
                {
                    id   = item.IdOperacion.ToString(),
                    cell = new[]
                    {
                        item.IdOperacion.ToString(),
                        item.Codigo,
                        item.Nombre,
                        item.SignoStock.ToString(),
                        item.SignoCaja.ToString(),
                        item.SignoContable.ToString(),
                        item.NombreEstado
                    }
                }).ToArray();
            }
            catch (Exception ex)
            {
                MostrarError(ex.Message);
            }
            return(Json(jqgrid));
        }
Esempio n. 13
0
        public JsonResult Listar(GridTable grid)
        {
            var jqgrid = new JGrid();

            try
            {
                var nombreFiltros = new[] { "IdOperacion", "Documento", "RazonSocial", "FechaDocumento", "Estado" };
                var lista         = CrearJGrid(VentaBL.Instancia, grid, nombreFiltros, ref jqgrid);

                jqgrid.rows = lista.Select(item => new JRow
                {
                    id   = item.IdTransaccion.ToString(),
                    cell = new[]
                    { item.IdTransaccion.ToString(),
                      ItemTablaBL.Instancia.Single((int)TipoTabla.TipoComprobante, item.IdTipoDocumento).Valor + " - " + item.Documento,
                      item.RazonSocial,
                      item.FechaDocumento.ToShortDateString(),
                      item.MontoNeto.ToString(),
                      item.NombreEstado }
                }).ToArray();
            }
            catch (Exception ex)
            {
                MostrarError(ex.Message);
            }

            return(Json(jqgrid));
        }
Esempio n. 14
0
        public JsonResult Listar(GridTable grid)
        {
            var jqgrid = new JGrid();

            try
            {
                var nombreFiltros = new[] { "Nombre", "RazonSocial", "Estado" };
                var lista         = CrearJGrid(RolBL.Instancia, grid, nombreFiltros, ref jqgrid);

                jqgrid.rows = lista.Select(item => new JRow
                {
                    id   = item.IdRol.ToString(),
                    cell = new[]
                    {
                        item.IdRol.ToString(),
                        item.Nombre,
                        item.Empresa.RazonSocial,
                        item.NombreEstado
                    }
                }).ToArray();
            }
            catch (Exception ex)
            {
                MostrarError(ex.Message);
            }
            return(Json(jqgrid));
        }
Esempio n. 15
0
        public JsonResult Listar(GridTable grid)
        {
            var jqgrid = new JGrid();

            try
            {
                var nombreFiltros = new[] { "Nombre", "Abreviatura", "Simbolo", "Estado", "IdEmpresa" };
                var lista         = CrearJGrid(MonedaBL.Instancia, grid, nombreFiltros, ref jqgrid);

                jqgrid.rows = lista.Select(item => new JRow
                {
                    id   = item.IdMoneda.ToString(),
                    cell = new[]
                    {
                        item.IdMoneda.ToString(),
                        item.Nombre,
                        item.Abreviatura,
                        item.Simbolo,
                        item.NombreEstado
                    }
                }).ToArray();
            }
            catch (Exception ex)
            {
                MostrarError(ex.Message);
            }
            return(Json(jqgrid));
        }
Esempio n. 16
0
        public JsonResult Listar(GridTable grid)
        {
            var jqgrid = new JGrid();

            try
            {
                var nombreFiltros = new[] { "Nombre", "Fecha", "ValorCompra", "ValorVenta", "IdEmpresa" };
                var lista         = CrearJGrid(TipoCambioBL.Instancia, grid, nombreFiltros, ref jqgrid);

                jqgrid.rows = lista.Select(item => new JRow
                {
                    id   = item.IdTipoCambio.ToString(),
                    cell = new[]
                    {
                        item.IdTipoCambio.ToString(),
                        item.Nombre,
                        item.Fecha.Value.ToShortDateString(),
                        item.ValorCompra.ToString(),
                        item.ValorVenta.ToString(),
                    }
                }).ToArray();
            }
            catch (Exception ex)
            {
                MostrarError(ex.Message);
            }
            return(Json(jqgrid));
        }
Esempio n. 17
0
 public void RowColFromId()
 {
     Assert.AreEqual((2, 4), JGrid.RowFromId("cell2_4"));
     Assert.AreEqual((12, 4), JGrid.RowFromId("cell12_4"));
     Assert.AreEqual((12, 40), JGrid.RowFromId("cell12_40"));
     Assert.AreEqual((1, 10), JGrid.RowFromId("cell1_10"));
 }
Esempio n. 18
0
        public JsonResult ListarPresentaciones(GridTable grid, int productoId)
        {
            var jqgrid = new JGrid();

            try
            {
                var totalPaginas = 0;
                var cantidad     = Presentaciones.Count;

                grid.page = (grid.page == 0) ? 1 : grid.page;
                grid.rows = (grid.rows == 0) ? 100 : grid.rows;

                if (cantidad > 0 && grid.rows > 0)
                {
                    var div   = cantidad / (decimal)grid.rows;
                    var round = Math.Ceiling(div);
                    totalPaginas = Convert.ToInt32(round);
                    totalPaginas
                        = totalPaginas == 0 ? 1 : totalPaginas;
                }

                grid.page = grid.page > totalPaginas ? totalPaginas : grid.page;

                var start = grid.rows * grid.page - grid.rows;
                if (start < 0)
                {
                    start = 0;
                }

                jqgrid.total   = totalPaginas;
                jqgrid.page    = grid.page;
                jqgrid.records = cantidad;
                jqgrid.start   = start;

                jqgrid.rows = Presentaciones.Select(item => new JRow
                {
                    id   = item.IdProducto.ToString(),
                    cell = new[]
                    {
                        item.IdPresentacion.ToString(),
                        item.Nombre,
                        item.Peso.ToString(),
                        item.Equivalencia.ToString(),
                        item.EsBase.ToString(),
                    }
                }).ToArray();
            }
            catch (Exception ex)
            {
                MostrarError(ex.Message);
            }

            return(Json(jqgrid));
        }
Esempio n. 19
0
        public JsonResult ListarDocumentos(GridTable grid, int operacionId)
        {
            var jqgrid = new JGrid();

            try
            {
                var totalPaginas = 0;
                var cantidad     = Documentos.Count;

                grid.page = (grid.page == 0) ? 1 : grid.page;
                grid.rows = (grid.rows == 0) ? 100 : grid.rows;

                if (cantidad > 0 && grid.rows > 0)
                {
                    var div   = cantidad / (decimal)grid.rows;
                    var round = Math.Ceiling(div);
                    totalPaginas = Convert.ToInt32(round);
                    totalPaginas = totalPaginas == 0 ? 1 : totalPaginas;
                }

                grid.page = grid.page > totalPaginas ? totalPaginas : grid.page;

                var start = grid.rows * grid.page - grid.rows;
                if (start < 0)
                {
                    start = 0;
                }

                jqgrid.total   = totalPaginas;
                jqgrid.page    = grid.page;
                jqgrid.records = cantidad;
                jqgrid.start   = start;

                jqgrid.rows = Documentos.Select(item => new JRow
                {
                    id   = item.TipoDocumento.ToString(),
                    cell = new[]
                    {
                        item.TipoDocumento.ToString(),
                        ItemTablaBL.Instancia.Single((int)TipoTabla.TipoComprobante, item.TipoDocumento).Nombre,
                        item.Orden.ToString(),
                        item.Posicion.ToString(),
                        item.NombreEstado
                    }
                }).ToArray();
            }
            catch (Exception ex)
            {
                MostrarError(ex.Message);
            }
            return(Json(jqgrid));
        }
Esempio n. 20
0
    private bool Composite(int i, int j, int num)
    {
        if (i < 0 || i > 3 || j < 0 || j > 3)
        {
            return(false);
        }
        JGrid jGrid = m_arrGrid[i, j];

        if (jGrid.f_uValue == num)
        {
            JMain.instance.f_uScore += jGrid.f_uValue;
            jGrid.f_uValue           = 0;
            return(true);
        }
        return(false);
    }
Esempio n. 21
0
 void Awake()
 {
     for (int i = 0; i < 4; i++)
     {
         for (int j = 0; j < 4; j++)
         {
             GameObject go = Instantiate(_go) as GameObject;
             go.transform.parent     = transform;
             go.transform.localScale = Vector3.one;
             int uIndex = i * 4 + j;
             go.name = "Grid_" + uIndex;
             JGrid jGrid = go.GetComponent <JGrid>();
             jGrid.f_uIndex  = uIndex;
             m_arrGrid[i, j] = jGrid;
         }
     }
 }
Esempio n. 22
0
    public bool CheckAroundGrid(int uIndex)
    {
        int   uCount = 0;
        int   i      = uIndex / 4;
        int   j      = uIndex % 4;
        JGrid jGrid  = m_arrGrid[i, j];
        int   num    = jGrid.f_uValue;

        if (Composite(i - 1, j, num))
        {
            uCount++;
        }
        if (Composite(i + 1, j, num))
        {
            uCount++;
        }
        if (Composite(i, j - 1, num))
        {
            uCount++;
        }
        if (Composite(i, j + 1, num))
        {
            uCount++;;
        }
        if (uCount > 0)
        {
            JMain.instance.f_uScore += jGrid.f_uValue;
            JMain.instance.AddNewNext(jGrid.f_uValue);
            jGrid.f_uValue *= 2;
            if (uCount > 1)
            {
                jGrid.ShowPlus();
            }
            CheckAroundGrid(uIndex);
            return(true);
        }
        return(false);
    }
Esempio n. 23
0
        protected IList <T> CrearJGrid <T>(IPaged <T> iPaged, GridTable gridTable, string [] nombreFiltros, ref JGrid jGrid) where T : class
        {
            var totalPaginas = 0;
            var filtros      = new List <object>();

            if (!string.IsNullOrEmpty(gridTable.filters))
            {
                var filters = JsonConvert.DeserializeObject <JOERP.Helpers.JqGrid.Filter>(gridTable.filters);

                foreach (var nombreFiltro in nombreFiltros)
                {
                    var filtro = filters.rules.FirstOrDefault(p => p.field == nombreFiltro);
                    filtros.Add(filtro == null ? null : filtro.data);
                }
            }
            else
            {
                foreach (var nombreFiltro in nombreFiltros)
                {
                    filtros.Add(null);
                }
            }

            if (gridTable.rules != null)
            {
                var index = 0;
                foreach (var nombreFiltro in nombreFiltros)
                {
                    foreach (var rule in gridTable.rules)
                    {
                        if (rule.field != nombreFiltro)
                        {
                            continue;
                        }
                        filtros[index] = rule.data;
                    }
                    index++;
                }
            }

            var cantidad = iPaged.Count(filtros.ToArray());

            gridTable.page = (gridTable.page == 0) ? 1 : gridTable.page;
            gridTable.rows = (gridTable.rows == 0) ? 100 : gridTable.rows;

            if (cantidad > 0 && gridTable.rows > 0)
            {
                var div   = cantidad / (decimal)gridTable.rows;
                var round = Math.Ceiling(div);
                totalPaginas = Convert.ToInt32(round);
                totalPaginas = totalPaginas == 0 ? 1 : totalPaginas;
            }

            gridTable.page = gridTable.page > totalPaginas ? totalPaginas : gridTable.page;

            var start = gridTable.rows * gridTable.page - gridTable.rows;

            if (start < 0)
            {
                start = 0;
            }

            jGrid.total   = totalPaginas;
            jGrid.page    = gridTable.page;
            jGrid.records = cantidad;
            jGrid.start   = start;

            filtros.Insert(0, gridTable.sidx);
            filtros.Insert(1, gridTable.sord);
            filtros.Insert(2, gridTable.rows);
            filtros.Insert(3, start);
            filtros.Insert(4, cantidad);

            var lista = iPaged.GetPaged(filtros.ToArray());

            return(lista);
        }