Esempio n. 1
0
        private void Book_add_Click(object sender, EventArgs e)
        {
            if (code.Text.Split(';').Count() == Convert.ToInt32(num.Text))
            {
                string Surname_author = "Surname";
                if (author.Text.Split(' ').Count() > 1)
                {
                    Surname_author = author.Text.Split(' ')[1];
                }

                Form1 main = this.Owner as Form1;
                Book  b    = new Book(new List <Person>(), Convert.ToInt32(year.Text), nameb.Text, name_iz.Text, place_pub.Text, code.Text);
                b.Authors_book.Add(new Person(author.Text.Split(' ')[0], "author", Surname_author));
                List <string> buff = new List <string>();
                buff.AddRange(code.Text.Split(';'));
                b.Libray_code = buff[0];
                main.L.Codes.AddRange(buff);

                if (main.L.In_catalog(nameb.Text) && main.L.Search_book_by_name(nameb.Text).BookL[0].Authors_book[0].Surname == Surname_author)
                {
                    BookInLibrary lib = main.L.Search_book_by_name(nameb.Text);
                    //lib.BookL.Add(lib.);
                    int i     = lib.Total_number_copies;
                    int index = i;
                    lib.Total_number_copies        += Convert.ToInt32(num.Text);
                    lib.Number_of_available_copies += Convert.ToInt32(num.Text);
                    lib.Add_Books(i);
                    while (i < lib.Total_number_copies)
                    {
                        lib.BookL[i].Libray_code = buff[i - index];
                        i++;
                    }
                }
                else
                {
                    main.L.Catalog.Add(new BookInLibrary(Convert.ToInt32(num.Text)));
                    main.L.Catalog[main.L.Catalog.Count - 1].BookL.Add(b);
                    main.L.Catalog[main.L.Catalog.Count - 1].Add_Books(1);
                    int i = 1;
                    while (i < Convert.ToInt32(num.Text))
                    {
                        main.L.Catalog[main.L.Catalog.Count - 1].BookL[i].Libray_code = buff[i];
                        i++;
                    }
                }
                num.Clear();
                nameb.Clear();
                author.Clear();
                name_iz.Clear();
                place_pub.Clear();
                code.Clear();
                year.Clear();
                pictureBox1.Visible = true;
            }
            else
            {
                MessageBox.Show("Количество библиотечных шифров не совпадает с количеством книг!");
            }
        }
Esempio n. 2
0
        public void RemoveBook(object sender, EventArgs e)
        {
            Form1         main = this.Owner as Form1;
            Book          b    = main.L.Search_book_by_code(textBox1.Text);
            BookInLibrary bl   = main.L.Search_book_by_name(b.Name_book);

            b.tr = TakesorReturns.Taken;
            bl.Number_of_available_copies--;
            bl.Total_number_copies--;
            main.L.Codes.Remove(b.Libray_code);
            b.Libray_code = "00";
            form.Close();
            Close();
        }
Esempio n. 3
0
        public void Read_from_exel(Microsoft.Office.Interop.Excel.Worksheet workshhet)
        {
            int           n, j;
            int           i            = 2;
            List <string> buff_authors = new List <string>();
            BookInLibrary b;

            while (workshhet.Cells[i, 1].Value != null)
            {
                if (In_catalog(Convert.ToString(workshhet.Cells[i, 1].Value)))
                {
                    b = Search_book_by_name(workshhet.Cells[i, 1].Value);
                    b.BookL.Add(new Book());
                    j = b.BookL.Count - 1;

                    if (workshhet.Cells[i, 7].Text != "Нет")
                    {
                        b.Number_of_available_copies++; b.BookL[j].tr = TakesorReturns.Returned;
                    }
                    else
                    {
                        b.BookL[j].tr = TakesorReturns.Taken;
                    }

                    b.Total_number_copies++;
                }
                else
                {
                    b = new BookInLibrary(); j = 0;
                    b.BookL.Add(new Book());
                    if (workshhet.Cells[i, 7].Value != "Нет")
                    {
                        b.Number_of_available_copies = 1;
                        b.BookL[j].tr = TakesorReturns.Returned;
                    }
                    else
                    {
                        b.Number_of_available_copies = 0;
                        b.BookL[j].tr = TakesorReturns.Taken;
                    }
                    b.Total_number_copies = 1;
                    catalog.Add(b);
                }

                b.BookL[j].Name_book = workshhet.Cells[i, 1].Value;
                buff_authors.AddRange(workshhet.Cells[i, 2].Value.Split(','));
                foreach (string s in buff_authors)
                {
                    if (s.Split(' ').Count() == 1)
                    {
                        b.BookL[j].Authors_book.Add(new Person(s, "", "Surname"));
                    }
                    else
                    {
                        b.BookL[j].Authors_book.Add(new Person(s.Split(' ')[0], "", s.Split(' ')[1]));
                    }
                }
                if (Int32.TryParse(Convert.ToString(workshhet.Cells[i, 3].Value), out n))
                {
                    b.BookL[j].Date_publishing = n;
                }
                else
                {
                    b.BookL[j].Date_publishing = 2014;
                }
                b.BookL[j].Place_of_publishing = workshhet.Cells[i, 4].Value;
                b.BookL[j].Name_publisher      = workshhet.Cells[i, 5].Value;
                b.BookL[j].Libray_code         = workshhet.Cells[i, 6].Value;
                codes.Add(b.BookL[j].Libray_code);
                i++;
                buff_authors.Clear();
            }
        }
Esempio n. 4
0
        private void button1_Click(object sender, EventArgs e)
        {
            button1.Text         = "Готово";
            search_table.Visible = true;
            textBox1.Visible     = false;
            textBox2.Visible     = false;
            label1.Visible       = false;
            label2.Visible       = false;
            pictureBox1.Visible  = false;
            Form1 main = this.Owner as Form1;

            if (flag == Search.book_by_name)
            {
                search_table.Rows.Clear();
                search_table.Columns.Clear();
                search_table.Visible = true;
                search_table.Columns.Add("book", "Название книги");
                search_table.Columns.Add("Authors", "Авторы");
                search_table.Columns.Add("pub", "Издательство");
                search_table.Columns.Add("year", "Год издания");
                search_table.Columns.Add("place", "Место издания");
                search_table.Columns.Add("total_num", "В наличии");
                search_table.Columns.Add("aviable_num", "Библиотечный шифр");
                BookInLibrary buff = main.L.Search_book_by_name(textBox1.Text);
                int           i    = 0;
                foreach (var b in buff.BookL)
                {
                    if (b.Libray_code != "00")
                    {
                        search_table.Rows.Add();
                        search_table.Rows[i].Cells[0].Value = b.Name_book;
                        search_table.Rows[i].Cells[1].Value = b.Authors_to_string();
                        search_table.Rows[i].Cells[2].Value = b.Name_publisher;
                        search_table.Rows[i].Cells[3].Value = b.Date_publishing;
                        search_table.Rows[i].Cells[4].Value = b.Place_of_publishing;
                        if (b.tr == TakesorReturns.Returned)
                        {
                            search_table.Rows[i].Cells[5].Value = "Да";
                        }
                        else
                        {
                            search_table.Rows[i].Cells[5].Value = "Нет";
                        }
                        search_table.Rows[i].Cells[6].Value = b.Libray_code;
                        i++;
                    }
                }
            }
            if (flag == Search.book_by_code)
            {
                search_table.Rows.Clear();
                search_table.Columns.Clear();
                search_table.Visible = true;
                search_table.Columns.Add("book", "Название книги");
                search_table.Columns.Add("Authors", "Авторы");
                search_table.Columns.Add("pub", "Издательство");
                search_table.Columns.Add("year", "Год издания");
                search_table.Columns.Add("place", "Место издания");
                search_table.Columns.Add("total_num", "В наличии");
                search_table.Columns.Add("aviable_num", "Библиотечный шифр");
                Book buff = main.L.Search_book_by_code(textBox1.Text);
                if (buff.Authors_book.Count != 0 && buff.Libray_code != "00")
                {
                    search_table.Rows.Add();
                    search_table.Rows[0].Cells[0].Value = buff.Name_book;
                    search_table.Rows[0].Cells[1].Value = buff.Authors_to_string();
                    search_table.Rows[0].Cells[2].Value = buff.Name_publisher;
                    search_table.Rows[0].Cells[3].Value = buff.Date_publishing;
                    search_table.Rows[0].Cells[4].Value = buff.Place_of_publishing;
                    if (buff.tr == TakesorReturns.Returned)
                    {
                        search_table.Rows[0].Cells[5].Value = "Да";
                    }
                    else
                    {
                        search_table.Rows[0].Cells[5].Value = "Нет";
                    }
                    search_table.Rows[0].Cells[6].Value = buff.Libray_code;
                }
            }
            if (flag == Search.reader_by_name)
            {
                search_table.Rows.Clear();
                search_table.Columns.Clear();
                search_table.Visible = true;
                search_table.Columns.Add("book", "Имя ");
                search_table.Columns.Add("Authors", "Отчество");
                search_table.Columns.Add("Authors", "Фамилия");
                search_table.Columns.Add("pub", "Дата полученя чит.билета");
                search_table.Columns.Add("year", "Номер чит.билета");
                int i = 0;
                foreach (var r in main.L.Current_info_of_reader(textBox1.Text, textBox2.Text))
                {
                    search_table.Rows.Add();
                    search_table.Rows[i].Cells[0].Value = r.Name_Person;
                    search_table.Rows[i].Cells[1].Value = r.Patronymic_Name;
                    search_table.Rows[i].Cells[2].Value = r.Surname;
                    search_table.Rows[i].Cells[3].Value = r.Date_get;
                    search_table.Rows[i].Cells[4].Value = r.Number_readticket;
                    i++;
                }
            }
            if (flag == Search.reader_by_ticket)
            {
                search_table.Rows.Clear();
                search_table.Columns.Clear();
                search_table.Visible = true;
                search_table.Columns.Add("book", "Имя ");
                search_table.Columns.Add("Authors", "Отчество");
                search_table.Columns.Add("Authors", "Фамилия");
                search_table.Columns.Add("pub", "Дата полученя чит.билета");
                search_table.Columns.Add("year", "Номер чит.билета");
                try {
                    Reader r = main.L.Search_reader(Convert.ToInt32(textBox1.Text));
                    search_table.Rows.Add();
                    int i = 0;
                    search_table.Rows[i].Cells[0].Value = r.Name_Person;
                    search_table.Rows[i].Cells[1].Value = r.Patronymic_Name;
                    search_table.Rows[i].Cells[2].Value = r.Surname;
                    search_table.Rows[i].Cells[3].Value = r.Date_get;
                    search_table.Rows[i].Cells[4].Value = r.Number_readticket;
                }
                catch (Exception) { }
            }
            button1.Click += Button1_Click;
        }