protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); infoFromNavPage = (Tuple <LibrarySystem, bool, Sale>)e.Parameter; system = infoFromNavPage.Item1; if (infoFromNavPage.Item2 == true) { GenreSale_radioBtn.Visibility = Visibility.Collapsed; otherSale_radioBtn_.Visibility = Visibility.Collapsed; isDateChange = true; Name_txtBox.Text = infoFromNavPage.Item3.Name; discount_comboBox.SelectedIndex = (infoFromNavPage.Item3.PrecentageOfDicrease) / 10 - 1; endDate_calendar.Date = infoFromNavPage.Item3.EndDate; CreateSale_btn.Content = "Edit sale"; GenreSale sale = infoFromNavPage.Item3 as GenreSale; if (sale == null) { StringSale sale1 = infoFromNavPage.Item3 as StringSale; otherSale_radioBtn_.IsChecked = true; search_combox.SelectedIndex = sale1.Filter; word_txtBox.Text = sale1.Word; } else { GenreSale_radioBtn.IsChecked = true; genreCombox.SelectedIndex = (int)sale.Genre; } } }
private void Item_Tapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e) { Tuple <LibrarySystem, List <LibraryItem>, int> t; ListViewItem item = sender as ListViewItem; Sale sale = (Sale)item.DataContext; GenreSale genreSale = sale as GenreSale; if (genreSale == null) { StringSale stringSale = sale as StringSale; t = new Tuple <LibrarySystem, List <LibraryItem>, int> (System, System.SearchByString(stringSale.Word, stringSale.Filter), 1); Frame.Navigate(typeof(SearchResultPage), t); } else { t = new Tuple <LibrarySystem, List <LibraryItem>, int> (System, System.SearchByGenre((int)genreSale.Genre), 1); Frame.Navigate(typeof(SearchResultPage), t); } }
private async void CreateSale_btn_Click(object sender, RoutedEventArgs e) { if (Name_txtBox.Text == "" || discount_comboBox.SelectedIndex == -1) { MessageDialog message = new MessageDialog("YOU MUST FILL ALL FIELDS", "EROR!"); await message.ShowAsync(); return; } if (GenreSale_radioBtn.IsChecked == false && otherSale_radioBtn_.IsChecked == false) { MessageDialog message = new MessageDialog("YOU MUST FILL ALL FIELDS", "EROR!"); await message.ShowAsync(); return; } if (GenreSale_radioBtn.IsChecked == true && genreCombox.SelectedIndex == -1 || otherSale_radioBtn_.IsChecked == true && word_txtBox.Text == "") { MessageDialog message = new MessageDialog("YOU MUST FILL ALL FIELDS", "EROR!"); await message.ShowAsync(); return; } if (!isDateChange) { MessageDialog message = new MessageDialog("YOU MUST SELECT A DATE", "EROR!"); await message.ShowAsync(); return; } if (infoFromNavPage.Item2 == true) { infoFromNavPage.Item3.Name = Name_txtBox.Text; infoFromNavPage.Item3.PrecentageOfDicrease = (discount_comboBox.SelectedIndex + 1) * 10; DateTimeOffset timeOffset = (DateTimeOffset)endDate_calendar.Date; infoFromNavPage.Item3.EndDate = timeOffset.DateTime; GenreSale sale = infoFromNavPage.Item3 as GenreSale; if (sale == null) { StringSale sale1 = infoFromNavPage.Item3 as StringSale; sale1.Filter = search_combox.SelectedIndex; sale1.Word = word_txtBox.Text; } else { sale.Genre = (Genres)genreCombox.SelectedIndex; } Frame.Navigate(typeof(ActionsPage), system); return; } DateTimeOffset endDate = (DateTimeOffset)endDate_calendar.Date; if (otherSale_radioBtn_.IsChecked == true) { system.AddSale(new StringSale(word_txtBox.Text, search_combox.SelectedIndex, Name_txtBox.Text, (discount_comboBox.SelectedIndex + 1) * 10, endDate.DateTime)); } else { system.AddSale(new GenreSale((Genres)genreCombox.SelectedIndex, Name_txtBox.Text, (discount_comboBox.SelectedIndex + 1) * 10, endDate.DateTime)); } genreCombox.Visibility = Visibility.Collapsed; popup_canvas.Visibility = Visibility.Visible; Name_txtBox.Text = ""; word_txtBox.Text = ""; genreCombox.SelectedIndex = -1; search_combox.SelectedIndex = 0; discount_comboBox.SelectedIndex = -1; GenreSale_radioBtn.IsChecked = false; otherSale_radioBtn_.IsChecked = false; endDate_calendar.Date = DateTime.Now; }