private void HomePage_Loaded(object sender, RoutedEventArgs e) { CakeList = new ObservableCollection <CakeModel>(DatabaseAccess.LoadCake()); CategoryList = new ObservableCollection <CategoryModel>(DatabaseAccess.LoadAllCategories()); CategoryList.Insert(0, new CategoryModel { CateId = -1, CateName = "Tất cả" }); cbbFilter.ItemsSource = CategoryList; string rowPerPageStr = "5"; int rowPerPageInt = 5; Setting.readSettingDB("row", ref rowPerPageStr); int.TryParse(rowPerPageStr, out rowPerPageInt); RowPerPage = rowPerPageInt; CurrentCakeList = CakeList; CurrentPage = 1; TotalPage = CurrentCakeList.Count / RowPerPage + (CurrentCakeList.Count % RowPerPage == 0 ? 0 : 1); if (TotalPage == 0) { CurrentPage = 0; } DisplayCakeList = new ObservableCollection <CakeModel>(CurrentCakeList.Skip(RowPerPage * (CurrentPage - 1)).Take(RowPerPage).ToList()); CakeListView.ItemsSource = DisplayCakeList; this.DataContext = this; cbbFilter.SelectedIndex = 0; }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); if (!File.Exists("CakeShop.db")) { MessageBox.Show("Không thể kết nối đến cơ sở dữ liệu. Vui lòng không chỉnh sửa các File hệ thống."); return; } string startupSetting = "1"; bool openSplashWindow = true; Setting.readSettingDB("startup", ref startupSetting); openSplashWindow = startupSetting == "1" ? true : false; //int rowPerPageInt = 5; //string rowPerPage = "5"; //Setting.readSettingDB("row", ref rowPerPage); //if(int.TryParse(rowPerPage, out rowPerPageInt)) //{ // Setting.RowPerPage = rowPerPageInt; //} //else //{ // Setting.RowPerPage = 5; //} if (openSplashWindow) { SplashScreen splashScreen = new SplashScreen(); splashScreen.Show(); } else { MainWindow mainWindow = new MainWindow(); mainWindow.Show(); } }
private void SettingScreen_Loaded(object sender, RoutedEventArgs e) { string rowPerPageStr = "5"; Setting.readSettingDB("row", ref rowPerPageStr); tbRowPerPage.Text = rowPerPageStr; string startupStr = "1"; Setting.readSettingDB("startup", ref startupStr); bool openStartup = startupStr == "1" ? true : false; if (openStartup) { cbSplashScreen.IsChecked = true; } else { cbSplashScreen.IsChecked = false; } }