Beispiel #1
0
        private void buttonUpdate_Click(object sender, EventArgs e)
        {
            if (inputtedValues())
            {
                Issues[dataGridView.SelectedCells[0].RowIndex].Name                    = textBoxName.Text;
                Issues[dataGridView.SelectedCells[0].RowIndex].Edition                 = Convert.ToInt16(textBoxEdition.Text);
                Issues[dataGridView.SelectedCells[0].RowIndex].Periodicity             = checkBoxPeriodicity.Checked;
                Issues[dataGridView.SelectedCells[0].RowIndex].Category.NatureOfInfo   = textBoxNature.Text;
                Issues[dataGridView.SelectedCells[0].RowIndex].Category.Originality    = checkBoxOriginality.Checked;
                Issues[dataGridView.SelectedCells[0].RowIndex].Category.TargetAudience = textBoxAudience.Text;

                comboBoxType.SelectedIndex = 0;
                if (Issues[dataGridView.SelectedCells[0].RowIndex] is Book)
                {
                    comboBoxType.SelectedIndex = 1;
                    Book curr = Issues[dataGridView.SelectedCells[0].RowIndex] as Book;
                    curr.Author             = textBox1.Text;
                    curr.Binding            = textBox2.Text;
                    curr.IllustratedBookend = checkBoxIllustr.Checked;
                    Issues[dataGridView.SelectedCells[0].RowIndex] = curr;
                }
                else if (Issues[dataGridView.SelectedCells[0].RowIndex] is Journal)
                {
                    comboBoxType.SelectedIndex = 2;
                    Journal curr = Issues[dataGridView.SelectedCells[0].RowIndex] as Journal;
                    curr.SerialNumber = Convert.ToInt16(textBox1.Text);
                    curr.Topic        = textBox2.Text;
                    curr.Redactors    = textBox3.Text;
                    Issues[dataGridView.SelectedCells[0].RowIndex] = curr;
                }
                else if (Issues[dataGridView.SelectedCells[0].RowIndex] is Mini_Issue)
                {
                    comboBoxType.SelectedIndex = 3;
                    Mini_Issue curr = Issues[dataGridView.SelectedCells[0].RowIndex] as Mini_Issue;
                    curr.Kind = textBox1.Text;
                    Issues[dataGridView.SelectedCells[0].RowIndex] = curr;
                }
                else if (Issues[dataGridView.SelectedCells[0].RowIndex] is Brochure)
                {
                    comboBoxType.SelectedIndex = 4;
                    Brochure curr = Issues[dataGridView.SelectedCells[0].RowIndex] as Brochure;
                    curr.Author             = textBox1.Text;
                    curr.Binding            = textBox2.Text;
                    curr.IllustratedBookend = checkBoxIllustr.Checked;
                    curr.IsCatalog          = checkBoxCatalog.Checked;
                    Issues[dataGridView.SelectedCells[0].RowIndex] = curr;
                }
                dataGridAndAllListsUpdate();
                ClearTextBoxes();
            }
            else
            {
                MessageBox.Show("Заполните все поля!");
            }
        }
Beispiel #2
0
        private void FillTextBoxes()
        {
            textBoxName.Text            = Issues[dataGridView.SelectedCells[0].RowIndex].Name;
            textBoxEdition.Text         = Issues[dataGridView.SelectedCells[0].RowIndex].Edition.ToString();
            checkBoxPeriodicity.Checked = Issues[dataGridView.SelectedCells[0].RowIndex].Periodicity;
            textBoxNature.Text          = Issues[dataGridView.SelectedCells[0].RowIndex].Category.NatureOfInfo;
            textBoxAudience.Text        = Issues[dataGridView.SelectedCells[0].RowIndex].Category.TargetAudience;
            checkBoxOriginality.Checked = Issues[dataGridView.SelectedCells[0].RowIndex].Category.Originality;

            comboBoxType.SelectedIndex = 0;
            if (Issues[dataGridView.SelectedCells[0].RowIndex] is Book)
            {
                comboBoxType.SelectedIndex = 1;
                Book curr = Issues[dataGridView.SelectedCells[0].RowIndex] as Book;
                textBox1.Text           = curr.Author;
                textBox2.Text           = curr.Binding;
                checkBoxIllustr.Checked = curr.IllustratedBookend;
            }
            else if (Issues[dataGridView.SelectedCells[0].RowIndex] is Journal)
            {
                comboBoxType.SelectedIndex = 2;
                Journal curr = Issues[dataGridView.SelectedCells[0].RowIndex] as Journal;
                textBox1.Text = curr.SerialNumber.ToString();
                textBox2.Text = curr.Topic;
                textBox3.Text = curr.Redactors;
            }
            else if (Issues[dataGridView.SelectedCells[0].RowIndex] is Mini_Issue)
            {
                comboBoxType.SelectedIndex = 3;
                Mini_Issue curr = Issues[dataGridView.SelectedCells[0].RowIndex] as Mini_Issue;
                textBox1.Text = curr.Kind;
            }
            else if (Issues[dataGridView.SelectedCells[0].RowIndex] is Brochure)
            {
                comboBoxType.SelectedIndex = 4;
                Brochure curr = Issues[dataGridView.SelectedCells[0].RowIndex] as Brochure;
                textBox1.Text           = curr.Author;
                textBox2.Text           = curr.Binding;
                checkBoxIllustr.Checked = curr.IllustratedBookend;
                checkBoxCatalog.Checked = curr.IsCatalog;
            }
        }
Beispiel #3
0
        private void buttonSerialize_Click(object sender, EventArgs e)
        {
            if (cbSerialize.SelectedIndex == 0)
            {
                BinaryFormatter formatter = new BinaryFormatter();
                using (FileStream fs = new FileStream("Issues.dat", FileMode.OpenOrCreate))
                {
                    formatter.Serialize(fs, Issues);
                }
            }
            else if (cbSerialize.SelectedIndex == 1)
            {
                XmlSerializer formatter = new XmlSerializer(typeof(List <Issue>),
                                                            new Type[] { typeof(Book), typeof(Journal), typeof(Mini_Issue), typeof(Brochure) });
                using (FileStream fs = new FileStream("Issues.xml", FileMode.OpenOrCreate))
                {
                    formatter.Serialize(fs, Issues);
                }
            }
            else if (cbSerialize.SelectedIndex == 2)
            {
                string infoText = String.Empty;
                for (int i = 0; i < Issues.Count; i++)
                {
                    if (Issues[i] is Book)
                    {
                        Book curr = Issues[i] as Book;
                        infoText += $"'Книга'|'{curr.Category.NatureOfInfo}'|'{curr.Category.Originality}'" +
                                    $"|'{curr.Category.TargetAudience}'|'{curr.Name}'|'{curr.Edition}'|" +
                                    $"'{curr.Periodicity}'|'{curr.Author}'|'{curr.Binding}'|'{curr.IllustratedBookend}'\r\n";
                    }
                    else if (Issues[i] is Journal)
                    {
                        Journal curr = Issues[i] as Journal;
                        infoText += $"'Журнал'|'{curr.Category.NatureOfInfo}'|'{curr.Category.Originality}'" +
                                    $"|'{curr.Category.TargetAudience}'|'{curr.Name}'|'{curr.Edition}'|" +
                                    $"'{curr.Periodicity}'|'{curr.SerialNumber}'|'{curr.Topic}'|'{curr.Redactors}'\r\n";
                    }
                    else if (Issues[i] is Mini_Issue)
                    {
                        Mini_Issue curr = Issues[i] as Mini_Issue;
                        infoText += $"'Мини-издание'|'{curr.Category.NatureOfInfo}'|'{curr.Category.Originality}'" +
                                    $"|'{curr.Category.TargetAudience}'|'{curr.Name}'|'{curr.Edition}'|" +
                                    $"'{curr.Periodicity}'|'{curr.Kind}'\r\n";
                    }
                    else if (Issues[i] is Brochure)
                    {
                        Brochure curr = Issues[i] as Brochure;
                        infoText += $"'Брошюра'|'{curr.Category.NatureOfInfo}'|'{curr.Category.Originality}'" +
                                    $"|'{curr.Category.TargetAudience}'|'{curr.Name}'|'{curr.Edition}'|" +
                                    $"'{curr.Periodicity}'|'{curr.IsCatalog}'\r\n";
                    }
                    else
                    {
                        Issue curr = Issues[i] as Issue;
                        infoText += $"'Не уточнено'|'{curr.Category.NatureOfInfo}'|'{curr.Category.Originality}'" +
                                    $"|'{curr.Category.TargetAudience}'|'{curr.Name}'|'{curr.Edition}'|" +
                                    $"'{curr.Periodicity}'\r\n";
                    }
                }

                using (FileStream fs = new FileStream("Issues.txt", FileMode.OpenOrCreate))
                {
                    byte[] array = Encoding.Default.GetBytes(infoText);
                    fs.Write(array, 0, array.Length);
                }
            }
        }
Beispiel #4
0
        private void dataGridView_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            listBoxInfo.Items.Clear();
            FillTextBoxes();
            try
            {
                listBoxInfo.Items.Add($"Название: { Issues[dataGridView.SelectedCells[0].RowIndex].Name}");
                listBoxInfo.Items.Add($"Тираж: { Issues[dataGridView.SelectedCells[0].RowIndex].Edition}");
                if (Issues[dataGridView.SelectedCells[0].RowIndex].Periodicity)
                {
                    listBoxInfo.Items.Add("Периодично");
                }
                else
                {
                    listBoxInfo.Items.Add("Не периодично");
                }
                listBoxInfo.Items.Add($"Категория: { Issues[dataGridView.SelectedCells[0].RowIndex].Category.NatureOfInfo}");
                listBoxInfo.Items.Add($"{ Issues[dataGridView.SelectedCells[0].RowIndex].Category.TargetAudience}");
                if (Issues[dataGridView.SelectedCells[0].RowIndex].Category.Originality)
                {
                    listBoxInfo.Items.Add("Оригинальное");
                }
                else
                {
                    listBoxInfo.Items.Add("Переведено");
                }


                if (Issues[dataGridView.SelectedCells[0].RowIndex] is Book)
                {
                    Book curr = Issues[dataGridView.SelectedCells[0].RowIndex] as Book;
                    listBoxInfo.Items.Add("Тип издания - книга");
                    listBoxInfo.Items.Add($"Автор: { curr.Author}");
                    listBoxInfo.Items.Add($"Переплёт: { curr.Binding}");
                    if (curr.IllustratedBookend)
                    {
                        listBoxInfo.Items.Add("Иллюстрированный форзац");
                    }
                    else
                    {
                        listBoxInfo.Items.Add("Форзац не иллюстрирован");
                    }
                }
                else if (Issues[dataGridView.SelectedCells[0].RowIndex] is Journal)
                {
                    Journal curr = Issues[dataGridView.SelectedCells[0].RowIndex] as Journal;
                    listBoxInfo.Items.Add("Тип издания - журнал");
                    listBoxInfo.Items.Add($"Тема: { curr.Topic}");
                    listBoxInfo.Items.Add($"Серийный номер: { curr.SerialNumber}");
                    listBoxInfo.Items.Add($"Редакторы: { curr.Redactors}");
                }
                else if (Issues[dataGridView.SelectedCells[0].RowIndex] is Mini_Issue)
                {
                    Mini_Issue curr = Issues[dataGridView.SelectedCells[0].RowIndex] as Mini_Issue;
                    listBoxInfo.Items.Add("Тип издания - мини-издание");
                    listBoxInfo.Items.Add($"Вид мини-издания: { curr.Kind}");
                }
                else if (Issues[dataGridView.SelectedCells[0].RowIndex] is Brochure)
                {
                    Brochure curr = Issues[dataGridView.SelectedCells[0].RowIndex] as Brochure;
                    listBoxInfo.Items.Add("Тип издания - брошюра");
                    if (curr.IsCatalog)
                    {
                        listBoxInfo.Items.Add("Является каталогом");
                    }
                    else
                    {
                        listBoxInfo.Items.Add("Не вляется каталогом");
                    }
                }
                else
                {
                    listBoxInfo.Items.Add("Издание");
                }
            }
            catch
            {
                MessageBox.Show("Выберите издание!");
            }
        }
Beispiel #5
0
 public void OutPutInfo(Brochure brochure)
 {
     Console.WriteLine("Целевая аудитория: {0}; название: {1}; тираж: {2};" +
                       " периодическое: {3}; каталог: {4}", brochure.Category.TargetAudience,
                       brochure.Name, brochure.Edition, brochure.Periodicity, brochure.IsCatalog);
 }