private void LoadTemplates()
        {
            Items.Clear();
            PageItems.Clear();
            int count = 0;

            string[] files = Directory.GetFiles(Constants.TemplateThumbnailRoot);
            if (files == null)
            {
                Debug.Write("Error: Reading files from the souvenirs image folder returns null.");
                return;
            }
            foreach (var file in files)
            {
                string        name     = Path.GetFileNameWithoutExtension(file);
                TemplateModel template = new TemplateModel(name, Path.GetFullPath(file), name);
                if (count < Constants.NumberOfItemsPerPage)
                {
                    PageItems.Add(template);
                    ++count;
                }
                Items.Add(template);
            }
            PageCursor    = 1;
            NumberOfPages = (Items.Count + Constants.NumberOfItemsPerPage - 1) / Constants.NumberOfItemsPerPage;
            PageBackCommand.RaiseCanExecuteChanged();
            PageForwardCommand.RaiseCanExecuteChanged();
        }
Example #2
0
        public static PageItems <Cajas> GetCajas(int Sucursal, int PageSize, int CurrentPage)
        {
            string SqlStatement = @"select a.Id, a.FechaApertura, a.FechaCierre, a.IsOpen, a.SucursalId, b.Description as [SucursalDescripcion], 
								a.Turno, a.InicioDeCaja, a.TotalTeoricoDeCaja, a.UserId, (c.FirstName + ' ' + c.LastName) as [UserNombre] 
								from cajas a inner join Sucursales b on a.SucursalId = b.Id inner join Users c on a.UserId = c.Id 
								Where a.SucursalId = @sucursalId order by a.Id DESC OFFSET (@currentPage - 1) * @pageSize ROWS FETCH NEXT @pageSize ROWS ONLY"                                ;

            string SqlStatement2 = @"select count(*) from cajas Where SucursalId = @sucursalId";

            var rtrnObj = new PageItems <Cajas>();

            try
            {
                using (var connection = new SqlConnection(SqlConn))
                {
                    rtrnObj.Items        = GetSQL(SqlStatement, new { sucursalId = Sucursal, currentPage = CurrentPage, pageSize = PageSize }, connection);
                    rtrnObj.RecordCounts = (int)GetValueSQL(SqlStatement2, new { sucursalId = Sucursal });
                    rtrnObj.CurrentPage  = CurrentPage;
                }
            }
            catch (Exception e)
            {
                throw e;
            }

            return(rtrnObj);
        }
Example #3
0
        public async Task <IActionResult> ListByFirstLetter(string lettre, int page = 1)
        {
            var aliments = _context.Aliment.Where(a => a.Nom.Substring(0, 1) == lettre).OrderBy(a => a.Nom);
            PageItems <Aliment> pagealiments = await PageItems <Aliment> .CreateAsync(aliments, page, 20);

            ViewBag.lettre = lettre;
            return(View(pagealiments));
        }
Example #4
0
        protected void Reset()
        {
            PageCursor    = 1;
            NumberOfPages = 1;
            Items.Clear();
            PageItems.Clear();

            PageBackCommand.RaiseCanExecuteChanged();
            PageForwardCommand.RaiseCanExecuteChanged();
        }
Example #5
0
        /// <summary>
        /// 关闭Page
        /// </summary>
        /// <param name="uuid">需要关闭的Page的UUID</param>
        /// <returns>返回关闭的Page的位置</returns>
        public static int ClosePage(string uuid)
        {
            if (pages[uuid] is Pages.ProcessContainer)
            {
                ((Pages.ProcessContainer)pages[uuid]).DisposePage();//如果是进程容器则对进程和ws进行关闭
            }
            pages[uuid].Content = null;
            pages.Remove(uuid);
            int index = PageItems.IndexOf(PageItems.First(l => l.uuid == uuid));

            PageItems.RemoveAt(index);
            GC.Collect();
            return(index);
        }
Example #6
0
        private void PageForwardCommandExecute(object parameter)
        {
            PageItems.Clear();
            ++PageCursor;
            int startIndex = (PageCursor - 1) * Constants.NumberOfItemsPerPage;

            for (var i = startIndex; i < startIndex + Constants.NumberOfItemsPerPage; ++i)
            {
                if (i >= Items.Count)
                {
                    break;
                }
                PageItems.Add(Items[i]);
            }
            PageBackCommand.RaiseCanExecuteChanged();
            PageForwardCommand.RaiseCanExecuteChanged();
        }
Example #7
0
        /// <summary>
        /// 添加新的页面
        /// </summary>
        /// <param name="page">页面源,使用new Pages.xxx()初始化</param>
        /// <param name="title">页面标题</param>
        /// <returns>返回初始化后的Page</returns>
        public static Page AddPage(Page page, string title)
        {
            pages.Add(UUIDTemp, page);
            var PageInfo = new PageItemModel()
            {
                PageTitle = title, PageSource = page, uuid = UUIDTemp
            };

            UUIDTemp         = CreateNewUUID;
            page.DataContext = PageInfo;
            PageItems.Add(PageInfo);
            Dispatcher.CurrentDispatcher.Invoke(() => (Application.Current.MainWindow as MainWindow).ListView_Page.SelectedIndex = PageItems.Count - 1);
            //if (page is Pages.ProcessContainer)
            //{
            //    throw new Exception((page as Pages.ProcessContainer).StPar.ToString());
            //}
            return(page);
        }
        public void GetShopExchangedApplyListTest()
        {
            //new Guid("FE410FFD-8BF0-4DEC-AC65-26F0FD8F0D58")
            //var goods = new GoodsManager().GetGoodsSelectList("迷卡倾城灰彩色隐形眼镜");
            //var goodsIds = goods.Select(act => new Guid(act.Key)).ToList();
            var startTime = DateTime.Now.AddMonths(-6);
            var endTime   = DateTime.Now;
            var totalList = _target.GetShopExchangedApplyList(false, string.Empty, startTime, endTime, new List <Guid>(), _shopId,
                                                              -1).ToList();
            var tempList  = totalList.Skip((1 - 1) * 5).Take(5).ToList();
            var pageItems = new PageItems <ShopExchangedApplyInfo>(1, 5, totalList.Count,
                                                                   tempList);

            //IEnumerable<ShopExchangedApplyInfo> actual = _target.GetShopExchangedApplyList(false,
            //    string.Empty, startTime, endTime, goodsIds,Guid.Empty , -1);
            Assert.IsTrue(pageItems != null && pageItems.Items.Any());
            //Assert.Inconclusive("验证此测试方法的正确性。");
        }
        public async Task <IActionResult> ListByFirstLetter(string letter, int page = 1)
        {
            IQueryable <Aliment> reqAliments;

            ViewBag.Letter = letter;

            if (letter == null)
            {
                reqAliments = _context.Aliment.Include(a => a.IdFamilleNavigation);
            }
            else
            {
                reqAliments = _context.Aliment.Where(a => a.Nom.StartsWith(letter)).Include(a => a.IdFamilleNavigation);
            }

            var aliments = await PageItems <Aliment> .CreateAsync(reqAliments, page, 20);

            return(View(aliments));
        }
Example #10
0
        public void Sync(int dataTotal = -1)
        {
            if (dataTotal > -1)
            {
                this.DataTotal = dataTotal;
            }

            if (this.PageSize > 0)
            {
                this.PageTotal = DataTotal / this.PageSize;
                if (DataTotal % this.PageSize > 0)
                {
                    this.PageTotal++;
                }
            }

            if (this.PageIndex <= 0)
            {
                this.PageIndex = 1;
            }

            if (this.PageTotal <= 0)
            {
                this.PageTotal = 1;
            }

            if (this.PageIndex > this.PageTotal)
            {
                this.PageIndex = this.PageTotal;
            }

            this.PageItems = new ObservableCollection <KeyValuePair <int, bool> >();
            for (var i = 1; i <= this.PageTotal; i++)
            {
                PageItems.Add(new KeyValuePair <int, bool>(i, i != PageIndex));
            }
            IsFirst = PageIndex > 1;
            IsLast  = PageIndex < PageTotal;
        }
Example #11
0
        /// <summary>
        /// 替换Page
        /// </summary>
        /// <param name="uuid">目标Page的UUID</param>
        /// <param name="page">替换成的Page,使用new Pages.xxx()初始化</param>
        /// <param name="title">替换后的Page标题</param>
        /// <returns>返回替换后的Page的位置</returns>
        public static int ReplacePage(string uuid, Page page, string title)
        {
            //清除旧Page
            pages[uuid].Content = null;
            //创建新Page的信息
            var PageInfo = new PageItemModel()
            {
                PageTitle = title, PageSource = page, uuid = uuid
            };

            page.DataContext = PageInfo;
            int index = PageItems.IndexOf(PageItems.First(l => l.uuid == uuid));

            PageItems[index] = PageInfo;
            Dispatcher.CurrentDispatcher.Invoke(() =>
            {
                //(Application.Current.MainWindow as MainWindow).ListView_Page.Items[index] = PageInfo;
                (Application.Current.MainWindow as MainWindow).ListView_Page.SelectedIndex = index;
            });
            GC.Collect();
            //返回Page的Index
            return(index);
        }
Example #12
0
 /// <summary>
 /// 获取Page
 /// </summary>
 /// <param name="uuid">UUID</param>
 /// <returns>返回通过uuid找到的Page</returns>
 public static Page GetPage(string uuid) => PageItems.First(l => l.uuid == uuid).PageSource;
Example #13
0
 public FileFolder(string path)
 {
     Path    = path;
     Folders = new FolderItems(path);
     Pages   = new PageItems(path);
 }
        public async override void OnPageDeactivation(NavigatingCancelEventArgs e)
        {
            await Task.WhenAll(PageItems.Select(async p => await p.OnPageDeactivationAsync()));

            base.OnPageDeactivation(e);
        }
 public async override void NavigatedTo()
 {
     await Task.WhenAll(PageItems.Select(p => p.UpdateAsync()));
 }