Example #1
0
        } // save in file

        private void button_outInfo_File_Click(object sender, EventArgs e)
        {
            try
            {
                var           fileBooks = SerializateInfo.Deserialize <CollectionBooks>("books.xml");
                StringBuilder ountline  = new StringBuilder();
                foreach (var item in fileBooks.books)
                {
                    ountline.AppendLine($"Название: {item.Name}");
                    ountline.AppendLine($"Формат: {item.Format}");
                    ountline.AppendLine($"Размер файла: {item.SizeFile}Кб");
                    ountline.AppendLine($"УДК: {item.UDK}");
                    ountline.AppendLine($"Количество страниц: {item.CountPages}");
                    ountline.AppendLine($"Издательство: {item.Publishing}");
                    ountline.AppendLine($"Дата загрузки: {item.ReleaseDate}");
                    StringBuilder authors = new StringBuilder();
                    foreach (var author in item.Authors.authors)
                    {
                        authors.Append($"{author.SN}({author.ID}); ");
                    }
                    ountline.AppendLine($"Список авторов: {authors}");
                    ountline.AppendLine($"-----------------------------------------------------------------------------------------");
                }
                txtBox_fromFile.Text = ountline.ToString();
                toolStripStatusLabel_Last_do.Text = "Последние действие: Вывод с файла";
            }
            catch (Exception x)
            {
                MessageBox.Show($"Ошибка: {x.Message}");
            }
        } // out int from file
Example #2
0
        } // refrashing comBox's

        private void button_Dessereliz_Click(object sender, EventArgs e)
        {
            #region TryDesserialize

            try
            {
                infoFromFile = SerializateInfo.Deserialize <CollectionBooks>("books.xml");
                MessageBox.Show("Успешно");
                succesDesserializ = true;
            }
            catch (Exception x)
            {
                MessageBox.Show($"Ошибка: {x.Message}");
                exepDesserializ = true;
            }

            #endregion
            toolStripStatusLabel_Last_do.Text = "Последние действие: Дисериализация";
        } // Deserialize file for refrash
Example #3
0
 private void timer_Tick(object sender, EventArgs e)
 {
     countLabel.Text = "Количетсов обьектов в файле = " + SerializateInfo.Deserialize <CollectionBooks>("books.xml").books.Count.ToString();
     dateLabel.Text  = DateTime.Now.ToLongDateString();
     timeLabel.Text  = DateTime.Now.ToLongTimeString();
 }
 private void button_Search_Click(object sender, EventArgs e)
 {
     if (combBox_Sort_by.Text == string.Empty)
     {
         MessageBox.Show("Выбирете сбособ сортировки");
     }
     else if (combBox_Sort_by.Text == "Названию")
     {
         try
         {
             result_Sort = new List <Book>();
             StringBuilder ountline     = new StringBuilder();
             var           infoFromFile = SerializateInfo.Deserialize <CollectionBooks>("books.xml");
             var           result_sort  = infoFromFile.books.OrderBy(i => i.Name);
             foreach (var item in result_sort)
             {
                 ountline.AppendLine($"Название: {item.Name}");
                 ountline.AppendLine($"Формат: {item.Format}");
                 ountline.AppendLine($"Размер файла: {item.SizeFile}Кб");
                 ountline.AppendLine($"УДК: {item.UDK}");
                 ountline.AppendLine($"Количество страниц: {item.CountPages}");
                 ountline.AppendLine($"Издательство: {item.Publishing}");
                 ountline.AppendLine($"Дата загрузки: {item.ReleaseDate}");
                 StringBuilder authors = new StringBuilder();
                 foreach (var author in item.Authors.authors)
                 {
                     authors.Append($"{author.SN}({author.ID}); ");
                 }
                 ountline.AppendLine($"Список авторов: {authors}");
                 ountline.AppendLine($"----------------------------------------------------------------");
                 result_Sort.Add(item);
             }
             txtBox_Result.Text = ountline.ToString();
         }
         catch (Exception x)
         {
             MessageBox.Show($"Ошибка: {x.Message}");
         }
     }
     else if (combBox_Sort_by.Text == "Дате загрузки")
     {
         try
         {
             result_Sort = new List <Book>();
             StringBuilder ountline     = new StringBuilder();
             var           infoFromFile = SerializateInfo.Deserialize <CollectionBooks>("books.xml");
             var           result_sort  = infoFromFile.books.OrderBy(i => i.ReleaseDate.Substring(i.ReleaseDate.Length - 5));
             foreach (var item in result_sort)
             {
                 ountline.AppendLine($"Название: {item.Name}");
                 ountline.AppendLine($"Формат: {item.Format}");
                 ountline.AppendLine($"Размер файла: {item.SizeFile}Кб");
                 ountline.AppendLine($"УДК: {item.UDK}");
                 ountline.AppendLine($"Количество страниц: {item.CountPages}");
                 ountline.AppendLine($"Издательство: {item.Publishing}");
                 ountline.AppendLine($"Дата загрузки: {item.ReleaseDate}");
                 StringBuilder authors = new StringBuilder();
                 foreach (var author in item.Authors.authors)
                 {
                     authors.Append($"{author.SN}({author.ID}); ");
                 }
                 ountline.AppendLine($"Список авторов: {authors}");
                 ountline.AppendLine($"----------------------------------------------------------------");
                 result_Sort.Add(item);
             }
             txtBox_Result.Text = ountline.ToString();
         }
         catch (Exception x)
         {
             MessageBox.Show($"Ошибка: {x.Message}");
         }
     }
     else
     {
         MessageBox.Show("Ошибка");
     }
 }
        private void button_Search_Click(object sender, EventArgs e)
        {
            CollectionBooks books;

            try
            {
                books = SerializateInfo.Deserialize <CollectionBooks>("books.xml");
                if (combBox_Search_by.Text == string.Empty)
                {
                    MessageBox.Show("Выберите способ поиска и введите данные");
                }
                else if (combBox_Search_by.Text == "Издательству") // Search by Publiching
                {
                    if (txtBox_Publishing.Text == string.Empty)
                    {
                        MessageBox.Show("Заполните данные");
                        txtBox_Result.Text = string.Empty;
                    }
                    else
                    {
                        StringBuilder ountline = new StringBuilder();
                        foreach (var item in books.books)
                        {
                            if (txtBox_Publishing.Text.ToLower() == item.Publishing.ToString().ToLower() ||
                                item.Publishing.ToString().ToLower().StartsWith(txtBox_Publishing.Text.ToLower()))
                            {
                                result_Search.Add(item);
                                ountline.AppendLine($"Название: {item.Name}");
                                ountline.AppendLine($"Формат: {item.Format}");
                                ountline.AppendLine($"Размер файла: {item.SizeFile}Кб");
                                ountline.AppendLine($"УДК: {item.UDK}");
                                ountline.AppendLine($"Количество страниц: {item.CountPages}");
                                ountline.AppendLine($"Издательство: {item.Publishing}");
                                ountline.AppendLine($"Дата загрузки: {item.ReleaseDate}");
                                StringBuilder authors = new StringBuilder();
                                foreach (var author in item.Authors.authors)
                                {
                                    authors.Append($"{author.SN}({author.ID}); ");
                                }
                                ountline.AppendLine($"Список авторов: {authors}");
                                ountline.AppendLine($"----------------------------------------------------------------");
                                txtBox_Result.Text = ountline.ToString();
                            } // == or StartsWith
                        }     //checking conditions
                        if (txtBox_Result.Text == string.Empty)
                        {
                            MessageBox.Show("Не найдено");
                        }
                    }
                }
                else if (combBox_Search_by.Text == "Году издания") // Search by Relize Date
                {
                    if (dateTimePicker_realeze.Text == string.Empty)
                    {
                        MessageBox.Show("Заполните данные");
                        txtBox_Result.Text = string.Empty;
                    }
                    else
                    {
                        foreach (var item in books.books)
                        {
                            StringBuilder ountline = new StringBuilder();
                            if (dateTimePicker_realeze.Text.ToLower() == item.ReleaseDate.ToString().ToLower())
                            {
                                result_Search.Add(item);
                                ountline.AppendLine($"Название: {item.Name}");
                                ountline.AppendLine($"Формат: {item.Format}");
                                ountline.AppendLine($"Размер файла: {item.SizeFile}Кб");
                                ountline.AppendLine($"УДК: {item.UDK}");
                                ountline.AppendLine($"Количество страниц: {item.CountPages}");
                                ountline.AppendLine($"Издательство: {item.Publishing}");
                                ountline.AppendLine($"Дата загрузки: {item.ReleaseDate}");
                                StringBuilder authors = new StringBuilder();
                                foreach (var author in item.Authors.authors)
                                {
                                    authors.Append($"{author.SN}({author.ID}); ");
                                }
                                ountline.AppendLine($"Список авторов: {authors}");
                                ountline.AppendLine($"----------------------------------------------------------------");
                                txtBox_Result.Text = ountline.ToString();
                            }
                        }//checking conditions
                        if (txtBox_Result.Text == string.Empty)
                        {
                            MessageBox.Show("Не найдено");
                        }
                    }
                }
                else if (combBox_Search_by.Text == "Диапазону страниц") // Search by Range Pages
                {
                    if (txtBox_rangeFrom.Text == string.Empty || txtBox_rangeTo.Text == string.Empty)
                    {
                        MessageBox.Show("Заполните данные");
                        txtBox_Result.Text = string.Empty;
                    }
                    else
                    {
                        StringBuilder ountline = new StringBuilder();
                        foreach (var item in books.books)
                        {
                            if (item.CountPages >= int.Parse(txtBox_rangeFrom.Text) && item.CountPages <= int.Parse(txtBox_rangeTo.Text))
                            {
                                result_Search.Add(item);
                                ountline.AppendLine($"Название: {item.Name}");
                                ountline.AppendLine($"Формат: {item.Format}");
                                ountline.AppendLine($"Размер файла: {item.SizeFile}Кб");
                                ountline.AppendLine($"УДК: {item.UDK}");
                                ountline.AppendLine($"Количество страниц: {item.CountPages}");
                                ountline.AppendLine($"Издательство: {item.Publishing}");
                                ountline.AppendLine($"Дата загрузки: {item.ReleaseDate}");
                                StringBuilder authors = new StringBuilder();
                                foreach (var author in item.Authors.authors)
                                {
                                    authors.Append($"{author.SN}({author.ID}); ");
                                }
                                ountline.AppendLine($"Список авторов: {authors}");
                                ountline.AppendLine($"----------------------------------------------------------------");
                                txtBox_Result.Text = ountline.ToString();
                            }
                        }//checking conditions
                        if (txtBox_Result.Text == string.Empty)
                        {
                            MessageBox.Show("Не найдено");
                        }
                    }
                }
            }
            catch (Exception x)
            {
                MessageBox.Show($"Ошибка: {x.Message}");
            }
        }