Beispiel #1
0
        public void Edit_Book_Tag_for_emp(string name, string description, string cover_path_file)
        {
            show_employee     = (Microwave_v1._0.Forms.ShowEmployee)Application.OpenForms["ShowEmployee"];
            lbl_bookname.Text = name;
            this.lbl_description.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            lbl_description.Text           = description;
            lbl_author.Text = " ";

            this.pic_book.Image = Picture_Events.Get_Copy_Image_Bitmap(System.IO.Path.GetDirectoryName(Application.ExecutablePath) + "\\" + cover_path_file);
        }
Beispiel #2
0
        public void Delete_Book_from_List(int book_id, bool delete_picture)
        {
            book_node iterator = root;

            if (root == null)
            {
                return;
            }

            if (root.book.Book_id == book_id)
            {
                root.book.Delete();
                if (delete_picture == true)
                {
                    Picture_Events.Delete_The_Picture(root.book.Cover_path_file);
                }
                root.book = null;
                root      = root.next;
                return;
            }

            while (iterator.next.book.Book_id != book_id)
            {
                iterator = iterator.next;
                if (iterator.next == null)
                {
                    MessageBox.Show("CANT FOUND");
                    return;
                }
            }

            iterator.next.book.Delete();
            if (delete_picture == true)
            {
                Picture_Events.Delete_The_Picture(iterator.next.book.Cover_path_file);
            }
            iterator.next.book = null;
            iterator.next      = iterator.next.next;
            return;
        }
Beispiel #3
0
        public AddBook(Book book)
        {
            InitializeComponent();
            this.btn_add.Image = global::Microwave_v1._0.Properties.Resources.pencil__1_;

            main_page = (Microwave)Application.OpenForms["Microwave"];
            System.IO.Directory.CreateDirectory(pic_dest_path);
            picture_event         = new Picture_Events(pic_dest_path, pic_default_file, ref this.pic_book);
            this.lbl_message.Text = "";

            book_to_edit = book;

            // Read Authors, Publishers, Categories, Shelves from Database
            Fill_Comboboxes();

            // Make comboboxes default
            this.cb_author.SelectedIndex    = this.cb_author.Items.IndexOf(book.Author_name);
            this.cb_publisher.SelectedIndex = this.cb_publisher.Items.IndexOf(book.Publisher_name);
            this.cb_category.SelectedIndex  = this.cb_category.Items.IndexOf(book.Category_name);
            this.cb_shelf.SelectedIndex     = this.cb_shelf.Items.IndexOf(book.Shelf_name);
            this.cb_author.ForeColor        = Color.LightGray;
            this.cb_publisher.ForeColor     = Color.LightGray;
            this.cb_category.ForeColor      = Color.LightGray;
            this.cb_shelf.ForeColor         = Color.LightGray;

            // Make other properties default
            this.tb_name.Text             = book.Name;
            this.tb_name.ForeColor        = Color.LightGray;
            this.tb_description.Text      = book.Description;
            this.tb_description.ForeColor = Color.LightGray;
            this.numUpDown_count.Value    = book.Count;

            pic_new_source_path = picture_event.Pic_source_file = book.Cover_path_file;
            pic_book.Image      = main_page.Cover_image_list.Images[book.Book_id.ToString()];

            is_edit = true;

            this.BringToFront();
        }
Beispiel #4
0
        public AddBook()
        {
            InitializeComponent();
            main_page = (Microwave)Application.OpenForms["Microwave"];
            System.IO.Directory.CreateDirectory(pic_dest_path);
            picture_event         = new Picture_Events(pic_dest_path, pic_default_file, ref this.pic_book);
            pic_new_source_path   = picture_event.Pic_source_file;
            this.lbl_message.Text = "";


            // Read Authors, Publishers, Categories, Shelves from Database
            Fill_Comboboxes();

            // Make comboboxes default
            this.cb_author.SelectedIndex    = 0;
            this.cb_publisher.SelectedIndex = 0;
            this.cb_category.SelectedIndex  = 0;
            this.cb_shelf.SelectedIndex     = 0;



            this.BringToFront();
        }
Beispiel #5
0
        private void Add_Click_Func(bool is_edit)
        {
            description         = tb_description.Text.Replace('\'', ' ');
            name                = (tb_name.Text.Trim()).Replace('\'', ' ');
            author              = cb_author.SelectedItem.ToString();
            publisher           = cb_publisher.SelectedItem.ToString();
            category            = cb_category.SelectedItem.ToString();
            shelf               = cb_shelf.SelectedItem.ToString();
            count               = (int)numUpDown_count.Value;
            date                = DateTime.Now.ToString();
            pic_new_source_path = picture_event.Pic_source_file;

            lbl_message.Text = "";

            // Validations
            if (tb_name.Text.Trim() == "Book's Name" || tb_name.Text.Trim() == "")
            {
                lbl_message.Text      = "* Please enter book's name.";
                lbl_message.ForeColor = Color.Red;
                tb_name.Focus();
                return;
            }
            if (cb_author.SelectedIndex == 0)
            {
                lbl_message.Text      = "* Please choose an author.";
                lbl_message.ForeColor = Color.Red;
                cb_author.Focus();
                return;
            }
            if (cb_publisher.SelectedIndex == 0)
            {
                lbl_message.Text      = "* Please choose a publisher.";
                lbl_message.ForeColor = Color.Red;
                cb_publisher.Focus();
                return;
            }
            if (cb_category.SelectedIndex == 0)
            {
                lbl_message.Text      = "* Please choose a category.";
                lbl_message.ForeColor = Color.Red;
                cb_category.Focus();
                return;
            }
            if (tb_description.Text == "Description..." || tb_description.Text == "")
            {
                lbl_message.Text      = "* Please enter description.";
                lbl_message.ForeColor = Color.Red;
                tb_description.Focus();
                return;
            }
            if (cb_shelf.SelectedIndex == 0)
            {
                lbl_message.Text      = "* Please choose a shelf.";
                lbl_message.ForeColor = Color.Red;
                cb_shelf.Focus();
                return;
            }
            if (pic_new_source_path == null || pic_new_source_path == pic_default_file)
            {
                lbl_message.Text      = "* Please choose a picture.";
                lbl_message.ForeColor = Color.Red;
                tb_description.Focus();
                picture_event.Choose_Image();
                return;
            }
            Join_Tables();


            if (is_edit == false)
            {
                picture_event.Copy_The_Picture(name);
                pic_new_source_path = picture_event.Pic_source_file;

                Book book = new Book(0, author_id, publisher_id, category_id, main_page.Manager.Employee_id, shelf_id, name, count, date, description, pic_new_source_path, 0, 0);
                book.Add();

                Clear();
            }
            else
            {
                if (change_image)
                {
                    Picture_Events.Delete_The_Picture(book_to_edit.Cover_path_file);
                    picture_event.Copy_The_Picture(name);
                    main_page.Remove_Image_From_Cover_List(book_to_edit.Book_id);
                    book_to_edit.Cover_path_file = picture_event.Pic_source_file;
                    book_to_edit.Cover_Pic_to_Image_List();
                    change_image = false;
                }

                lbl_message.Text      = "*Book changed successfully";
                lbl_message.ForeColor = Color.LightGreen;

                book_to_edit.Author_id    = author_id;
                book_to_edit.Publisher_id = publisher_id;
                book_to_edit.Category_id  = category_id;
                book_to_edit.Shelf_id     = shelf_id;
                book_to_edit.Count        = count;
                book_to_edit.Name         = name;
                book_to_edit.Description  = description;

                book_to_edit.Edit();

                main_page.Pnl_book_list.VerticalScroll.Value = 0;
                main_page.Book_search_list.Delete_All_List();
                main_page.Main_book_list.Draw_All_Books();
                main_page.Book_searched_already = false;

                main_page.Main_shelf_list.Delete_All_List();
                Shelf.Show_All_Shelf(main_page);
            }
        }