/// <summary> /// События при загрузке формы /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SearchingForm_Load(object sender, EventArgs e) { EditionDataView.CreateTable( _searchedEditions, SearchedEditionGridView); SelectEdition.SelectedIndex = 0; }
/// <summary> /// Удаление издания /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void RemoveEdition_Click(object sender, EventArgs e) { var linesCount = EditionDescriptionGridView.SelectedRows.Count; for (int i = 0; i < linesCount; i++) { _editions.RemoveAt( EditionDescriptionGridView.SelectedRows[0].Index); } EditionDataView.CreateTable(_editions, EditionDescriptionGridView); }
/// <summary> /// Добавление издания /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void AddEdition_Click(object sender, EventArgs e) { var addingEditionForm = new AddingEditionForm(); if (addingEditionForm.ShowDialog() != DialogResult.OK) { return; } _editions.Add(addingEditionForm.EditionDone); EditionDataView.CreateTable( _editions, EditionDescriptionGridView); }
/// <summary> /// Загрузка данных /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void LoadData_Click(object sender, EventArgs e) { using (OpenFileDialog openFileDialog = new OpenFileDialog()) { openFileDialog.Filter = "zhaa files (*.zhaa)|*.zhaa"; openFileDialog.FilterIndex = 1; openFileDialog.RestoreDirectory = true; if (openFileDialog.ShowDialog() != DialogResult.OK) { return; } var binaryFormatter = new BinaryFormatter(); var filePath = openFileDialog.FileName; try { using (var fileStream = new FileStream(filePath, FileMode.OpenOrCreate)) { var newEditions = (BindingList <IEdition>)binaryFormatter. Deserialize(fileStream); foreach (var edition in newEditions) { _editions.Add(edition); } } EditionDataView.CreateTable(_editions, EditionDescriptionGridView); } catch { MessageBox.Show("Невозможно загрузить файл"); } } }
/// <summary> /// Событие при выборе поиска издания /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SearchButton_Click(object sender, EventArgs e) { SearchEdition(); EditionDataView.CreateTable(_searchedEditions, SearchedEditionGridView); }
/// <summary> /// Добавить рандомное издание /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void RandomEdition_Click(object sender, EventArgs e) { _editions.Add(RandomEdition.GetRandomEdition()); EditionDataView.CreateTable(_editions, EditionDescriptionGridView); }
/// <summary> /// Загрузка формы /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MainForm_Load(object sender, EventArgs e) { EditionDataView.CreateTable(_editions, EditionDescriptionGridView); }