public OutputGoods() { InitializeComponent(); ComboBoxThemes.SelectionChanged += ThemeChange; items = XmlSerializeWrapper.Deserialize <ObservableCollection <Item> >("basket.xml"); ListViewTable.ItemsSource = items; CommandBinding commandHome = new CommandBinding(); commandHome.Command = NavigationCommands.BrowseHome; commandHome.Executed += ButtonBrowseHome_Click; ButtonBrowseHome.CommandBindings.Add(commandHome); CommandBinding commandEdit = new CommandBinding(); commandEdit.Command = ApplicationCommands.CorrectionList; commandEdit.Executed += ButtonEditBasket_Click; ButtonEditBasket.CommandBindings.Add(commandEdit); CommandBinding commandAdd = new CommandBinding(); commandAdd.Command = ApplicationCommands.New; commandAdd.Executed += ButtonAddGood_Click; ButtonAddGood.CommandBindings.Add(commandAdd); }
public Form1() { InitializeComponent(); if (!XmlSerializeWrapper.isEmpty()) { accounts.AddRange(XmlSerializeWrapper.Deserialize <List <Account> >(Account.mainFilePath)); foreach (Account acc in accounts) { listBox1.Items.Add(acc.Number + " " + acc.Owner1.Surname + " " + acc.Owner1.Name + " " + acc.Owner1.Midname + " " + acc.Owner1.PassNumber + " " + acc.Balance); Account.count++; } tb = new ToolBar(this); Point point = new Point(this.Location.X + this.Width - 15, this.Location.Y); tb.Location = point; tb.LocationChanged += new System.EventHandler(Locate); toolStripStatusLabel4.Text = Account.count.ToString(); //toolStripStatusLabel6.Text = DateTime.Now.Date.ToShortDateString(); timer = new Timer() { Interval = 1000 }; timer.Tick += Timer1_Tick; timer.Start(); } }
private void setDefaultSettings() { try { IsShowSplash = true; IsStayAuthorized = true; OptionsPack.CurrentAppTheme = "Light"; OptionsPack.CurrentAppAccent = "ForestGreen"; List <OptionsPack> optionsPacks = XmlSerializeWrapper <List <OptionsPack> > .Deserialize("../appSettings.xml", FileMode.OpenOrCreate); optionsPacks.Remove(optionsPacks.Find(x => x.OptionUserId == DeserializedUser.deserializedUser.Id)); optionsPacks.Add(OptionsPack); XmlSerializeWrapper <List <OptionsPack> > .Serialize(optionsPacks, "../appSettings.xml"); ThemeManager.Current.ChangeThemeColorScheme(Application.Current, OptionsPack.CurrentAppAccent); ThemeManager.Current.ChangeThemeBaseColor(Application.Current, OptionsPack.CurrentAppTheme); Application.Current?.MainWindow?.Activate(); TextMessage = "Установлены настройки по умолчанию! Перезагрузите приложение для обновления цветовой палитры."; } catch (Exception exception) { MessageBox.Show("Сообщение ошибки: " + exception.Message, "Произошла ошибка"); } }
private void ButtonRedo_Click(object sender, RoutedEventArgs e) { itemsCollection.Add(lastItem); lastItems.Add(lastItem); XmlSerializeWrapper.Serialize(itemsCollection, "basket.xml"); MessageBox.Show($"Последний добавленный элемент ({lastItem.NameItem}) добавлен!"); }
private void LogIn() { try { using (UnitOfWork uow = new UnitOfWork()) { List <User> result = uow.UserRepository.Get(x => x.UserLogin == User.UserLogin).ToList(); if (result.Count() == 0) { Message = "Логин или пароль неверный!"; return; } else if (PasswordHash.IsPasswordValid(UserPassword, int.Parse(result.First <User>().Salt), result.First <User>().UserPassword)) { User deserializedeUser = result.First(); XmlSerializeWrapper <User> .Serialize(deserializedeUser, "../lastUser.xml"); DeserializedUser.deserializedUser = XmlSerializeWrapper <User> .Deserialize("../lastUser.xml", FileMode.OpenOrCreate); List <OptionsPack> optionsPacks = XmlSerializeWrapper <List <OptionsPack> > .Deserialize("../appSettings.xml", FileMode.OpenOrCreate); OptionsViewModel.OptionsPack = optionsPacks.Find(x => x.OptionUserId == deserializedeUser.Id); MainWindow mainWindow = new MainWindow(); mainWindow.Show(); OptionsViewModel.OptionsPack?.setAppAccent(); OptionsViewModel.OptionsPack?.setAppTheme(); OptionsPack optionsPackUser = optionsPacks.Find(x => x.OptionUserId == DeserializedUser.deserializedUser.Id); if (optionsPackUser == null) { optionsPacks.Add(new OptionsPack()); XmlSerializeWrapper <List <OptionsPack> > .Serialize(optionsPacks, "../appSettings.xml"); } foreach (Window window in Application.Current.Windows) { if (window is LogInWindow) { window.Close(); break; } } } else { Message = "Логин или пароль неверный!"; return; } } } catch (Exception exception) { MessageBox.Show("Сообщение ошибки: " + exception.Message, "Произошла ошибка"); } }
private void openToolStripMenuItem_Click(object sender, EventArgs e) { var resultDes = XmlSerializeWrapper.Deserialize <Plane[]>("save.xml"); foreach (var i in resultDes) { _planeList.Add(i); } }
public MainWindow() { InitializeComponent(); App.LanguageChanged += LanguageChanged; CultureInfo currLang = App.Language; ObservableCollection <Item> items = new ObservableCollection <Item>(); XmlSerializeWrapper.Serialize(items, "foreignBasket.xml"); }
static DeserializedUser() { try { deserializedUser = XmlSerializeWrapper <User> .Deserialize("../lastUser.xml", FileMode.Open); } catch (Exception exception) { MessageBox.Show("Сообщение ошибки: " + exception.Message, "Произошла ошибка"); } }
private void Sort_Click(object sender, EventArgs e) { var result = from u in houses orderby u.Length_of_House select u; foreach (House u in result) { MessageBox.Show(u.Length_of_House); } XmlSerializeWrapper.Serialize(houses, "House.xml"); }
public void Save(string name) { if (buffer.Count == 0) { throw new Exception("Буфер пуст"); } else { List <Account> buf = new List <Account>(); buf.AddRange(buffer); XmlSerializeWrapper.Serialize <List <Account> >(buf, name + ".xml"); MessageBox.Show("Результат сохранён", "window"); } }
private void RadioButtonNotAvailable_Checked(object sender, RoutedEventArgs e) { ObservableCollection <Item> tempItems = new ObservableCollection <Item>(); foreach (var item in items) { if (item.IsAvailable == "ОТСУТСТВУЕТ" || item.IsAvailable == "NOT AVAILABLE") { tempItems.Add(item); } } items = tempItems; ListViewTable.ItemsSource = items; items = XmlSerializeWrapper.Deserialize <ObservableCollection <Item> >("basket.xml"); }
private void ButtonUndo_Click(object sender, RoutedEventArgs e) { try { lastItems.RemoveAt(lastItems.Count - 1); itemsCollection.RemoveAt(itemsCollection.Count - 1); MessageBox.Show($"Последний добавленный элемент ({lastItem.NameItem}) удален!"); XmlSerializeWrapper.Serialize(itemsCollection, "basket.xml"); } catch (Exception) { MessageBox.Show("Вы удалили все только что добавленные товары!"); ButtonUndo.IsEnabled = false; } }
public AddGood() { InitializeComponent(); itemsCollection = XmlSerializeWrapper.Deserialize <List <Item> >("basket.xml"); CommandBinding commandHome = new CommandBinding(); commandHome.Command = NavigationCommands.BrowseHome; commandHome.Executed += ButtonBrowseHome_Click; ButtonBrowseHome.CommandBindings.Add(commandHome); CommandBinding commandEdit = new CommandBinding(); commandEdit.Command = ApplicationCommands.CorrectionList; commandEdit.Executed += ButtonEditBasket_Click; ButtonEditBasket.CommandBindings.Add(commandEdit); }
private void ButtonDeleteItem_Click(object sender, RoutedEventArgs e) { int counter = 0; foreach (var item in items) { if (counter == ListViewTable.SelectedIndex) { items.RemoveAt(counter); XmlSerializeWrapper.Serialize(items, "basket.xml"); MessageBox.Show($"Товар {item.NameItem} удалён!"); break; } counter++; } ListViewTable.ItemsSource = items; }
public EditBasket() { InitializeComponent(); items = XmlSerializeWrapper.Deserialize <List <Item> >("basket.xml"); ListViewTable.ItemsSource = items; //Привязка command CommandBinding commandAdd = new CommandBinding(); commandAdd.Command = ApplicationCommands.New; commandAdd.Executed += ButtonAddGood_Click; ButtonAddGood.CommandBindings.Add(commandAdd); CommandBinding commandHome = new CommandBinding(); commandHome.Command = NavigationCommands.BrowseHome; commandHome.Executed += ButtonBrowseHome_Click; ButtonBrowseHome.CommandBindings.Add(commandHome); }
private void saveApplicationSettings() { try { List <OptionsPack> optionsPacks = XmlSerializeWrapper <List <OptionsPack> > .Deserialize("../appSettings.xml", FileMode.OpenOrCreate); optionsPacks.Remove(optionsPacks.Find(x => x.OptionUserId == DeserializedUser.deserializedUser.Id)); optionsPacks.Add(OptionsPack); XmlSerializeWrapper <List <OptionsPack> > .Serialize(optionsPacks, "../appSettings.xml"); TextMessage = "Настройки сохранены!"; } catch (Exception exception) { MessageBox.Show("Сообщение ошибки: " + exception.Message, "Произошла ошибка"); } }
private void exit() { try { User deserializedeUser = new(); XmlSerializeWrapper <User> .Serialize(deserializedeUser, "../lastUser.xml"); var window = Application.Current.Windows.OfType <Window>().SingleOrDefault(x => x.IsActive && x.Name == "MainAppWindow"); LogInWindow logInWindow = new LogInWindow(); logInWindow.Show(); window.Close(); } catch (Exception exception) { MessageBox.Show("Сообщение ошибки: " + exception.Message, "Произошла ошибка"); } }
private void Application_Startup(object sender, StartupEventArgs e) { List <OptionsPack> optionsPacks = XmlSerializeWrapper <List <OptionsPack> > .Deserialize("../appSettings.xml", FileMode.Open); OptionsPack currentUserSettings = optionsPacks.Find(x => x.OptionUserId == DeserializedUser.deserializedUser.Id); if (currentUserSettings?.IsSplashScreenShown ?? true) { SplashScreen splash = new SplashScreen("../Resources/foodTrackSplash.png"); splash.Show(autoClose: false, topMost: false); splash.Close(TimeSpan.FromSeconds(1)); } using (UnitOfWork unit = new UnitOfWork()) { IEnumerable <User> resultUserFound = unit.UserRepository.Get(x => x.UserLogin == DeserializedUser.deserializedUser.UserLogin); if (resultUserFound.Count() != 0 && (currentUserSettings?.IsStayAuthorized ?? false)) { if (resultUserFound.First <User>().UserPassword.SequenceEqual <byte>(DeserializedUser.deserializedUser.UserPassword)) { MainWindow mainWindow = new MainWindow(); mainWindow.Show(); currentUserSettings.setAppTheme(); currentUserSettings.setAppAccent(); OptionsViewModel.OptionsPack = currentUserSettings; } else { LogInWindow logInWindow = new LogInWindow(); logInWindow.Show(); } } else { LogInWindow logInWindow = new LogInWindow(); logInWindow.Show(); } } }
private void ButtonSaveEditings_Click(object sender, RoutedEventArgs e) { try { int counter = 0; foreach (var item in items) { if (numItem == counter) { item.NameItem = TextBoxNameGood.Text; item.Category = ComboBoxCategory.Text; item.Country = TextBoxCountry.Text; if (Double.TryParse(TextBoxPrice.Text, out double result)) { item.Price = result; } item.PicturePath = ItemPicture.Source.ToString(); if (RadioButtonAvailable.IsChecked == true) { item.IsAvailable = "В НАЛИЧИИ"; } if (RadioButtonNotAvailable.IsChecked == true) { item.IsAvailable = "ОТСУТСТВУЕТ"; } break; } counter++; } XmlSerializeWrapper.Serialize(items, "basket.xml"); } catch (Exception) { MessageBox.Show($"Ошибка записи в файл!"); return; } MessageBox.Show("Информация о товаре изменена!"); this.Hide(); }
private void ButtonAddItem_Click(object sender, RoutedEventArgs e) { try { Item tempItem = new Item(); tempItem.NameItem = TextBoxNameItem.userTBox.Text; tempItem.Category = ComboBoxCategory.Text; if (Double.TryParse(TextBoxPrice.Text, out double price)) { tempItem.Price = price; } else { throw new Exception("Неверные данные в поле с ценой"); } tempItem.Country = TextBoxCountry.Text; if (RadioButtonAvailable.IsChecked == true) { tempItem.IsAvailable = TextBlockAvailable.Text; } if (RadioButtonNotAvailable.IsChecked == true) { tempItem.IsAvailable = TextBlockNotAvailable.Text; } tempItem.Description = TBoxDescription.Content.ToString(); tempItem.PicturePath = ItemPicture.Source.ToString(); lastItem = tempItem; itemsCollection.Add(tempItem); lastItems.Add(tempItem); ButtonUndo.IsEnabled = true; ButtonRedo.IsEnabled = true; XmlSerializeWrapper.Serialize(itemsCollection, "basket.xml"); } catch (Exception ex) { MessageBox.Show($"Ошибка записи в файл! \n {ex.Message}"); return; } MessageBox.Show($"Товар добавлен в корзину!\nКоличество товаров в корзине : {itemsCollection.Count}\nОтправитель:{sender}\nИсточник:{e.Source}\nПрямое событие Click"); }
private void ButtonAddItem_Click(object sender, RoutedEventArgs e) { try { Item tempItem = new Item(); tempItem.NameItem = TextBoxNameGood.Text; tempItem.Category = ComboBoxCategory.Text; if (Double.TryParse(TextBoxPrice.Text, out double price)) { tempItem.Price = price; } else { throw new Exception("Неверные данные в поле с ценой"); } tempItem.Country = TextBoxCountry.Text; if (RadioButtonAvailable.IsChecked == true) { tempItem.IsAvailable = TextBlockAvailable.Text; } if (RadioButtonNotAvailable.IsChecked == true) { tempItem.IsAvailable = TextBlockNotAvailable.Text; } tempItem.Description = TextBoxDescription.Text; tempItem.PicturePath = ItemPicture.Source.ToString(); itemsCollection.Add(tempItem); XmlSerializeWrapper.Serialize(itemsCollection, "basket.xml"); } catch (Exception) { MessageBox.Show("Ошибка записи в файл!"); return; } MessageBox.Show($"Товар добавлен в корзину!\nКоличество товаров в корзине : {itemsCollection.Count}"); }
private void Go_Click(object sender, EventArgs e) { bool flagRoom = false, flagMaterial = false; List <string> room = new List <string>(); List <string> material = new List <string>(); try { #region Rooms if (this.bath.Checked == true) { room.Add("Ванная"); flagRoom = true; } if (this.kitchen.Checked == true) { room.Add("Кухня"); flagRoom = true; } if (this.toilet.Checked == true) { room.Add("Туалет"); flagRoom = true; } if (this.balcony.Checked == true) { room.Add("Балкон"); flagRoom = true; } if (this.basement.Checked == true) { room.Add("Подвал"); flagRoom = true; } #endregion #region Material if (this.TreeMaterial.Checked == true) { material.Add("Дерево"); flagMaterial = true; } if (this.BlockMaterial.Checked == true) { material.Add("Блок"); flagMaterial = true; } if (this.AnotherM.Checked == true) { material.Add("Другое"); flagMaterial = true; } #endregion if (this.Length.Text.Equals("") || this.NumberOfRoom.Text.Equals("") || flagRoom == false || flagMaterial == false || this.Year.Text.Equals("") || this.FloatNumber.Text.Equals("")) { MessageBox.Show("information isn't found"); } else { //textBox1.Text = "Length of house: " + this.Length.Text + "\nNumber of room: " + this.NumberOfRoom.Text + "\nYear: " + //this.Year.Text + "\nMaterial: " + material.First() + "\nFloat: " + this.FloatNumber.Text; House house = new House(this.Length.Text, NumberOfRoom.Text, this.Year.Text, material, this.FloatNumber.Text, room); houses.Add(house); XmlSerializeWrapper.Serialize(houses, "House.xml"); } } catch (Exception ex) { MessageBox.Show("error: " + ex.Message); } }
private void ButtonSetFilters_Click(object sender, RoutedEventArgs e) { items = XmlSerializeWrapper.Deserialize <ObservableCollection <Item> >("basket.xml"); double minPrice = 0; double maxPrice = 0; string Category = null; if (TextBoxMinPrice.Text != string.Empty && TextBoxMaxPrice.Text != string.Empty) { if (Double.TryParse(TextBoxMinPrice.Text, out double result)) { minPrice = result; } if (Double.TryParse(TextBoxMaxPrice.Text, out double resultt)) { maxPrice = resultt; } } else { MessageBox.Show("Заполните минимальную и максимальную цены!"); return; } if (ComboBoxCategoryFilter.SelectedIndex != -1) { Category = ComboBoxCategoryFilter.Text; } else { MessageBox.Show("Выберите категорию товара!"); return; } if (RadioButtonAvailable.IsChecked == false && RadioButtonNotAvailable.IsChecked == false) { MessageBox.Show("Выберите наличие товара!"); return; } ObservableCollection <Item> tempItems = new ObservableCollection <Item>(); foreach (var item in items) { if (item.Price > minPrice && item.Price < maxPrice && item.Category == Category) { tempItems.Add(item); } } items = new ObservableCollection <Item>(); if (tempItems.Count < 1) { MessageBox.Show("По заданным критериями не найдено ни одного товара!"); return; } if (RadioButtonAvailable.IsChecked == true) { foreach (var item in tempItems) { if (item.IsAvailable == "В НАЛИЧИИ" || item.IsAvailable == "AVAILABLE") { items.Add(item); } } } else { foreach (var item in tempItems) { if (item.IsAvailable == "ОТСУТСТВУЕТ" || item.IsAvailable == "NOT AVAILABLE") { items.Add(item); } } } if (items.Count < 1) { MessageBox.Show("По заданным критерям не найдено ни одного товара!"); return; } else { ListViewTable.ItemsSource = items; } items = XmlSerializeWrapper.Deserialize <ObservableCollection <Item> >("basket.xml"); }
private void saveToolStripMenuItem_Click(object sender, EventArgs e) { XmlSerializeWrapper.Serialize(_planeList, "save.xml"); }
private void button1_Click(object sender, EventArgs e) { int dpType = 0; if (radioButton1.Checked) { dpType = 0; } else if (radioButton2.Checked) { dpType = 1; } else if (radioButton3.Checked) { dpType = 2; } else { throw new Exception("Не выбран тип вклада"); } if (textBox5.Text == "") { throw new Exception("Поле номера паспорта пусто"); } else if (monthCalendar1.SelectionRange.Start.Date == monthCalendar1.TodayDate) { throw new Exception("Дата рождения не выбрана"); } else if ((new DateTime().AddTicks(DateTime.Now.Ticks - monthCalendar1.SelectionRange.Start.Date.Ticks)).Year < 19) { throw new Exception("Вам должно быть больше восемнадцати лет"); } else if (comboBox1.Text == "") { throw new Exception("Поле с суммой вклада пусто"); } long passNum = -1; long.TryParse(textBox5.Text, out passNum); float balance = -1; float.TryParse(comboBox1.Text, out balance); account = new Account(textBox2.Text, textBox3.Text, textBox1.Text, passNum, monthCalendar1.SelectionRange.Start.Date, dpType, balance, checkBox1.Checked, checkBox2.Checked, Account.OperationType.deposit); //account = new Account(); ValidationContext valCont = new ValidationContext(account); List <ValidationResult> results = new List <ValidationResult>(); if (!Validator.TryValidateObject(account, valCont, results, true)) { foreach (var error in results) { throw new Exception(error.ErrorMessage); } } valCont = new ValidationContext(account.Owner1); results = new List <ValidationResult>(); if (!Validator.TryValidateObject(account.Owner1, valCont, results, true)) { foreach (var error in results) { throw new Exception(error.ErrorMessage); } } Account.count++; stripStatus(sender); accounts.Add(account); //listBox1.Items.Add("0 Makarov Victor Alekseevich"); listBox1.Items.Add(account.Number + " " + textBox1.Text + " " + textBox2.Text + " " + textBox3.Text + " " + account.Owner1.PassNumber + " " + account.Balance); //var convertedjson = JsonConvert.SerializeObject(accounts, Formatting.Indented); XmlSerializeWrapper.Serialize(accounts, Account.mainFilePath); //accounts = XmlSerializeWrapper.Deserialize<List<Account>>("users.xml"); }