예제 #1
0
        /// <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;
        }
예제 #2
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);
        }
예제 #3
0
        /// <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);
        }
예제 #4
0
        /// <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("Невозможно загрузить файл");
                }
            }
        }
예제 #5
0
 /// <summary>
 /// Событие при выборе поиска издания
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void SearchButton_Click(object sender, EventArgs e)
 {
     SearchEdition();
     EditionDataView.CreateTable(_searchedEditions, SearchedEditionGridView);
 }
예제 #6
0
 /// <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);
 }
예제 #7
0
 /// <summary>
 /// Загрузка формы
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void MainForm_Load(object sender, EventArgs e)
 {
     EditionDataView.CreateTable(_editions, EditionDescriptionGridView);
 }