private async void LoadDataFromFile() { _maxRedniBroj = BookItems.Count > 0 ? BookItems.Max(y => y.RedniBroj) : 0; OpenFileDialog ofd = new OpenFileDialog { Filter = "Xlsx Files *.xlsx|*.xlsx|Xls Files *.xls|*.xls|Csv files *.csv|*.csv", FilterIndex = 1, Multiselect = false }; Nullable <bool> result = ofd.ShowDialog(); if (result != null && result == true) { IsLoading = true; FilePath = ofd.FileName; var data = _xlsFileReader.Convert(FilePath, "PREGLED PROMETA BLAGAJNE"); if (data != null) { FromStringToList(data); _loaded = true; } await Application.Current.Dispatcher.BeginInvoke(new Action(DatagridLoaded), DispatcherPriority.ContextIdle, null); } }
private async void SaveToDatabase() { IEnumerable <CashRegisterModel> primke = BookItems.Where(x => x.RedniBroj > _maxRedniBroj); var list = new List <CashRegisterModel>(primke); IsLoading = true; await _cashRegisterBookEndpoint.PostItems(list); _loaded = false; LoadBook(); }
private void AddDataToList(DataRow val) { BookItems.Add(new CashRegisterModel { RedniBroj = int.Parse(val[0].ToString()), Datum = DateTime.Parse(val[1].ToString()), Gotovina = decimal.Parse(val[2].ToString()), KreditneKartice = decimal.Parse(val[3].ToString()), Sveukupno = decimal.Parse(val[6].ToString()), IznosSudjelovanja = decimal.Parse(val[8].ToString()), }); }
private async void SaveToDatabase() { IEnumerable <CashRegisterModel> primke = BookItems.Where(x => x.RedniBroj > _maxRedniBroj); var list = new List <CashRegisterModel>(primke); StatusMessage = "Zapisujem u bazu podataka..."; await _cashRegisterBookEndpoint.PostItems(list); StatusMessage = "";; _loaded = false; LoadBook(); }
public async Task <IActionResult> Create([Bind("Id,Name,Author,Price,Popular")] BookCreateViewModel book) { if (ModelState.IsValid) { book.Id = Guid.NewGuid(); var result = new BookItems { Id = book.Id, Name = book.Name, Author = book.Author, Popular = book.Popular, Price = book.Price }; await _addBook.AddItemsAsync(result); return(RedirectToAction(nameof(Index))); } return(View()); }
public async Task <IActionResult> Edit(Guid id, [Bind("Id,Name,Author,Price,Popular")] BookView book) { if (id != book.Id) { return(NotFound()); } if (ModelState.IsValid) { try { var editBook = new BookItems { Id = book.Id, Author = book.Author, Name = book.Name, Popular = book.Popular, Price = book.Price }; await _addBook.EditAsync(editBook); } catch (DbUpdateConcurrencyException) { if (!BookExists(book.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(book)); }
private void LoadDataFromFile() { _maxRedniBroj = BookItems.Count > 0 ? BookItems.Max(y => y.Id) : 0; OpenFileDialog ofd = new OpenFileDialog { Filter = "Xlsx Files *.xlsx|*.xlsx|Xls Files *.xls|*.xls|Csv files *.csv|*.csv", FilterIndex = 1, Multiselect = false }; Nullable <bool> result = ofd.ShowDialog(); if (result != null && result == true) { FilePath = ofd.FileName; var data = _xlsFileReader.Convert(FilePath, "PREGLED PROMETA BLAGAJNE"); if (data != null) { FromStringToList(data); _loaded = true; } } }
protected override async void OnNavigatedTo(NavigationEventArgs e) { if (e.NavigationMode == NavigationMode.New) { var button = e.Parameter as Button; switch (button.Name) { case "hotNovelsButton": RequestURI = BaseURIs.hotNovelsURI; kind = "normal"; localTitle = MainPage.TitleTextBlock.Text = "热门轻小说"; break; case "animatedNovelsButton": RequestURI = BaseURIs.animatedNovelsURI; kind = "normal"; localTitle = MainPage.TitleTextBlock.Text = "动画化作品"; break; case "updatedNovelsButton": RequestURI = BaseURIs.updatedNovelsURI; kind = "normal"; localTitle = MainPage.TitleTextBlock.Text = "今日更新"; break; case "newNovelsButton": RequestURI = BaseURIs.newNovelsURI; kind = "normal"; localTitle = MainPage.TitleTextBlock.Text = "新书一览"; break; case "completeNovelsButton": RequestURI = BaseURIs.completeNovelsURI; kind = "normal"; localTitle = MainPage.TitleTextBlock.Text = "完结全本"; break; case "favouriteNovelsButton": RequestURI = BaseURIs.favouriteNovelsURI; kind = "special"; localTitle = MainPage.TitleTextBlock.Text = "特别收藏"; break; default: break; } pageNum = 1; string htmlPage = null; if (kind == "normal") { htmlPage = await HTMLParser.Instance.GetHtml(RequestURI + "&page=" + pageNum++); } else { htmlPage = await HTMLParser.Instance.GetHtml(RequestURI); } if (htmlPage == null) { await MainPage.PopMessageDialog("网络或服务器故障!"); return; } try { BookItems.Clear(); BookItemParser.Instance.GetBookItems(htmlPage, BookItems, kind); MainPage.ProgressRing.IsActive = false; MainPage.ProgressRing.Visibility = Windows.UI.Xaml.Visibility.Collapsed; } catch (Exception) { await MainPage.PopMessageDialog("网络或服务器故障!"); } } else if (e.NavigationMode == NavigationMode.Back) { MainPage.TitleTextBlock.Text = localTitle; MainPage.ProgressRing.IsActive = false; MainPage.ProgressRing.Visibility = Windows.UI.Xaml.Visibility.Collapsed; } }