Beispiel #1
0
        //Selecting a book by ISBN changes the book title automatically
        private void comboBoxOrdISBN_SelectedIndexChanged(object sender, EventArgs e)
        {
            var selection = comboBoxOrdISBN.SelectedItem;

            textBoxOrdBkTitle.Text = BookDA.SearchISBN(Convert.ToInt64(selection.ToString())).BkTitle;
            textBoxOrdBkUP.Text    = BookDA.SearchISBN(Convert.ToInt64(selection.ToString())).BkUnitPrice.ToString();
        }
Beispiel #2
0
        private void buttonSearch_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(textboxSearch.Text))
            {
                MessageBox.Show("Enter ISBN");
            }
            else
            {
                Book book = BookDA.Search(Convert.ToInt32(textboxSearch.Text));

                if (book != null)
                {
                    textboxisbn.Text          = book.isbn.ToString();
                    textboxTitle.Text         = book.Title;
                    textboxUnitPrice.Text     = book.UnitPrice.ToString();
                    textboxYearPublished.Text = book.YearPublished.ToString();
                    textboxYearPublished.Text = book.QOH.ToString();
                    textboxSearch.Clear();
                }
                else
                {
                    MessageBox.Show("Book Not Found", "Search Failed");
                    textboxSearch.Clear();
                }
            }
        }
Beispiel #3
0
        public void sel_hit_amonet(string bookID)
        {
            BookDA bookDA = new BookDA();

            bookDA.sel_hit_amonet(bookID);
            this.bookAmonet = bookDA.bookAmonet;
            this.bookhit    = bookDA.bookhit;
        }
        // GET: api/Books
        public List <Book> Get()
        {
            //return new string[] { "value1", "value2" };

            BookDA      bookDA = new BookDA();
            List <Book> books  = bookDA.SelectBooks();

            return(books);
        }
Beispiel #5
0
        //Search book by title
        private void buttonOrdSearchBk_Click(object sender, EventArgs e)
        {
            Book abook = BookDA.SearchTitle(textBoxOrdBkTitle.Text);

            if (abook != null)
            {
                MessageBox.Show("Book found, ISBN:" + abook.BkISBN.ToString(), "Book search result");
            }
        }
Beispiel #6
0
        //Add
        private void buttonBkAdd_Click(object sender, EventArgs e)
        {
            Validator checker = new Validator();

            if (checker.isValidLongID(textBoxBkISBN, 13) && checker.isNotNull(textBoxBktitle.Text, "Title") && checker.isNotNull(textBoxBkAuthorID.Text, "Category") && checker.isNotNull(comboBoxBkPub.Text, "Publisher") && checker.isNotNull(textBoxBkQOH.Text, "QOH") && checker.isNotNull(textBoxBkUP.Text, "Unit Price") && checker.isNotNull(comboBoxBkAuthor.Text, "Author"))
            {
                BookDA.Save(createBook());
                UpdateComboBoxes();
            }
        }
Beispiel #7
0
 //Automatic ComboBoxes Method
 public void UpdateComboBoxes()
 {
     comboBoxOrdClient.Items.Clear();
     comboBoxOrdISBN.Items.Clear();
     comboBoxBkAuthor.Items.Clear();
     comboBoxBkPub.Items.Clear();
     OrderDA.clientSelection(comboBoxOrdClient);
     OrderDA.bookSelection(comboBoxOrdISBN);
     BookDA.authorSelection(comboBoxBkAuthor);
     BookDA.publisherSelection(comboBoxBkPub);
 }
Beispiel #8
0
        //Update
        private void buttonBkUpdate_Click(object sender, EventArgs e)
        {
            DialogResult ans = MessageBox.Show("Are you sure you want to update the Book information?", "Update Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

            if (ans == DialogResult.Yes)
            {
                BookDA.Update(createBook());
            }
            BookDA.ListBooks(listViewBooks);
            UpdateComboBoxes();
        }
Beispiel #9
0
 public List <BookBO> GetBooks()
 {
     try
     {
         BookDA bookDA = new BookDA();
         return(bookDA.GetBooks());
     }
     catch
     {
         throw;
     }
 }
Beispiel #10
0
 public List <BookBO> Update(BookBO book, List <BookBO> books) // passing Bussiness object Here
 {
     try
     {
         BookDA bookDA = new BookDA();
         return(bookDA.Update(book, books));
     }
     catch
     {
         throw;
     }
 }
Beispiel #11
0
 public List <BookBO> DeleteById(object Id, List <BookBO> books) // passing Bussiness object Here
 {
     try
     {
         BookDA bookDA = new BookDA();
         return(bookDA.DeleteById(Convert.ToInt32(Id), books));
     }
     catch
     {
         throw;
     }
 }
Beispiel #12
0
 public List <BookBO> Add(BookBO book, List <BookBO> books) // Data Access Layer // passing Bussiness object Here
 {
     try
     {
         BookDA bookDA = new BookDA();
         // GetNextHighestBookId
         return(bookDA.Add(book, books));
     }
     catch
     {
         throw;
     }
 }
Beispiel #13
0
        private void ButtonAddToList_Click(object sender, EventArgs e)
        {
            Book book = new Book();

            if ((BookValidation.isValidisbn(textboxisbn)) && (BookValidation.isValidName(textboxTitle)) && (BookValidation.isValidValues(textboxUnitPrice)) && (BookValidation.isValidYear(textboxYearPublished)) && (BookValidation.isValidValues(textboxQuantityOnHand)))
            {
                book.isbn          = Convert.ToInt32(textboxisbn.Text);
                book.Title         = textboxTitle.Text;
                book.UnitPrice     = Convert.ToInt32(textboxUnitPrice.Text);
                book.YearPublished = Convert.ToInt32(textboxYearPublished.Text);
                book.QOH           = Convert.ToInt32(textboxQuantityOnHand.Text);
                BookDA.Add(book);
                clearall();
            }
        }
Beispiel #14
0
        //Delete
        private void buttonAutDel_Click(object sender, EventArgs e)
        {
            DialogResult ans = MessageBox.Show("Are you sure you want to delete the Author information?", "Delete Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

            if (ans == DialogResult.Yes)
            {
                if (BookDA.SearchAuthor(Convert.ToInt32(textBoxAutID.Text)) != null)
                {
                    MessageBox.Show("This author has one or more books registered in the inventory, please be sure that there are no books by this author before deleting it!", "ALERT!");
                    return;
                }
                AuthorDA.Delete(Convert.ToInt32(textBoxAutID.Text));
                AuthorDA.ListAuthors(listViewAuthor);
                UpdateComboBoxes();
            }
        }
Beispiel #15
0
        //Delete
        private void buttonBkDel_Click(object sender, EventArgs e)
        {
            DialogResult ans = MessageBox.Show("Are you sure you want to delete the Book information?", "Delete Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

            if (ans == DialogResult.Yes)
            {
                if (OrderDA.SearchByBook(Convert.ToInt64(textBoxBkISBN.Text)) != null)
                {
                    MessageBox.Show("This book has open orders in the system, please verify the orders before deleting this book.", "ALERT!");
                    return;
                }
                BookDA.Delete(createBook().BkISBN);
                BookDA.ListBooks(listViewBooks);
                UpdateComboBoxes();
            }
        }
Beispiel #16
0
        public BookBizApp()
        {
            InitializeComponent();

            //Disables the access to any other tab that the currently user is not supossed to use
            tabPage1.Enabled = false;
            tabPage2.Enabled = false;
            tabPage3.Enabled = false;
            tabPage4.Enabled = false;

            //Automatic ComboBoxes
            OrderDA.clientSelection(comboBoxOrdClient);
            OrderDA.bookSelection(comboBoxOrdISBN);
            BookDA.authorSelection(comboBoxBkAuthor);
            BookDA.publisherSelection(comboBoxBkPub);
        }
Beispiel #17
0
 //Enable the buttons delete and update in case of a valid entered ID
 private void textBoxBkISBN_TextChanged(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(textBoxBkISBN.Text))
     {
         buttonBkDel.Enabled    = false;
         buttonBkUpdate.Enabled = false;
         return;
     }
     if (BookDA.SearchISBN(Convert.ToInt64(textBoxBkISBN.Text)) != null)
     {
         buttonBkDel.Enabled    = true;
         buttonBkUpdate.Enabled = true;
         return;
     }
     buttonBkDel.Enabled    = false;
     buttonBkUpdate.Enabled = false;
 }
Beispiel #18
0
        //Add
        private void buttonOrdAdd_Click(object sender, EventArgs e)
        {
            Validator checker = new Validator();

            if (checker.isNotNull(comboBoxOrdClient.Text, "Client") && checker.isNotNull(comboBoxOrdISBN.Text, "Book ISBN") && checker.isNotNull(textBoxOrdBkQt.Text, "Quantity") && checker.isNotNull(comboBoxOrdMadeBy.Text, "Order made by?"))
            {
                Order  aorder  = createOrder();
                Book   abook   = BookDA.SearchISBN(Convert.ToInt64(comboBoxOrdISBN.Text));
                Client aclient = ClientDA.SearchName(comboBoxOrdClient.Text);
                abook.BkQOH = abook.BkQOH - aorder.OrdBkQuantity;
                BookDA.Update(abook);
                aclient.ClientCredit = aclient.ClientCredit - aorder.OrdCost;
                ClientDA.Update(aclient);
                OrderDA.SaveOrder(aorder);
                UpdateComboBoxes();
            }
        }
Beispiel #19
0
        //Update
        private void buttonOrdUpd_Click(object sender, EventArgs e)
        {
            Order aorder   = createOrder();
            Order oldorder = OrderDA.SearchID(Convert.ToInt32(textBoxOrId.Text));

            Book   abook   = BookDA.SearchISBN(Convert.ToInt64(comboBoxOrdISBN.Text));
            Client aclient = ClientDA.SearchName(comboBoxOrdClient.Text);

            abook.BkQOH = (abook.BkQOH + oldorder.OrdBkQuantity) - aorder.OrdBkQuantity;
            BookDA.Update(abook);

            aclient.ClientCredit = (aclient.ClientCredit + aorder.OrdCost) - aorder.OrdCost;
            ClientDA.Update(aclient);

            OrderDA.Update(aorder);
            OrderDA.ListOrder(listViewOrder);
            UpdateComboBoxes();
        }
Beispiel #20
0
        private void btn_Save_Click(object sender, EventArgs e)
        {
            if ((Validation.IsValidID(txt_ISBN)))
            {
                Book bk = new Book();


                bk.ISBN          = Convert.ToInt32(txt_ISBN.Text);
                bk.Title         = txt_Title.Text;
                bk.YearPublished = Convert.ToInt32(txt_Published.Text);
                bk.UnitPrice     = Convert.ToDecimal(txt_Price.Text);
                bk.QOH           = Convert.ToInt32(txt_qty.Text);

                BookDA.Save(bk);

                ClearAll();
            }
        }
Beispiel #21
0
        //年月日+流水號訂單編號
        public string orderID(string Date)
        {
            string oID;
            BookDA bookDA = new BookDA();

            bookDA.orderID(Date);
            this.order_ID = bookDA.order_ID;
            string id = this.order_ID == "" ? order_ID : this.order_ID.Substring(0, 6);

            if (id != DateTime.Now.ToString("yyyyMM"))
            {
                oID = DateTime.Now.ToString("yyyyMMdd") + "000001";
            }
            else
            {
                oID = DateTime.Now.ToString("yyyyMMdd") + (Convert.ToInt32(this.order_ID.Substring(8, 6)) + 1).ToString("000000");
            }
            return(oID);
        }
        private void buttonAddBook_Click(object sender, EventArgs e)
        {
            if (Validator.IsValidID(textBoxIsbn) && Validator.IsValidID(textBoxAuthorId) && Validator.IsValidID(textBoxCategoryId) && Validator.IsValidID(textBoxPublisherId))
            {
                Book book = new Book();

                book.ISBN          = Convert.ToInt32(textBoxIsbn.Text);
                book.title         = textBoxTitle.Text;
                book.AuthorId      = Convert.ToInt32(textBoxAuthorId.Text);
                book.YearPublished = Convert.ToInt32(textBoxYear.Text);
                book.QOH           = Convert.ToInt32(textBoxQuantity.Text);
                book.UnitPrice     = Convert.ToInt32(textBoxPrice.Text);
                book.categoryId    = Convert.ToInt32(textBoxCategoryId.Text);
                book.publisherId   = Convert.ToInt32(textBoxPublisherId.Text);
                listBook.Add(book);
                BookDA.Save(book);
                buttonListBook.Enabled = true;
                ClearAll();
            }
        }
Beispiel #23
0
        //=====================================================================================================================================
        //=============================END OF INVENTORY MANAGER PROGRAM========================================================================
        //=====================================================================================================================================


        //=====================================================================================================================================
        //=============================BEGINNING OF ORDER CLERKS PROGRAM=======================================================================
        //=====================================================================================================================================

        // Create object Order
        private Order createOrder()
        {
            Order  aorder  = new Order();
            Book   abook   = new Book();
            Client aclient = new Client();

            abook   = BookDA.SearchISBN(Convert.ToInt64(comboBoxOrdISBN.Text));
            aclient = ClientDA.SearchName(comboBoxOrdClient.Text);

            aorder.OrdId         = OrderDA.OrderID() + 1;
            aorder.OrdClient     = aclient;
            aorder.OrdBbook      = abook;
            aorder.OrdBkQuantity = Convert.ToInt32(textBoxOrdBkQt.Text);
            aorder.OrdCost       = aorder.OrdBkQuantity * BookDA.SearchISBN(Convert.ToInt64(comboBoxOrdISBN.Text)).BkUnitPrice;
            aorder.OrdDate       = Convert.ToDateTime(dateTimePickerOrder.Value);
            aorder.OrdType       = comboBoxOrdMadeBy.Text;

            textBoxOrId.Text = aorder.OrdId.ToString();
            return(aorder);
        }
Beispiel #24
0
        //Search
        private void buttonBkSearch_Click(object sender, EventArgs e)
        {
            Book abook = new Book();

            if (!string.IsNullOrEmpty(textBoxBkSearch.Text))
            {
                switch (comboBoxBkSearch.SelectedIndex)
                {
                case -1:
                    MessageBox.Show("Please select a valid search option!");
                    return;

                case 0:
                    long tempId;
                    if (!long.TryParse(textBoxBkSearch.Text, out tempId))
                    {
                        MessageBox.Show("Please enter a valid term to be searched.", "No search information!");
                        return;
                    }
                    abook = BookDA.SearchISBN(Convert.ToInt64(textBoxBkSearch.Text));
                    break;

                case 1:
                    abook = BookDA.SearchTitle(textBoxBkSearch.Text);
                    break;
                }
                if (abook == null)
                {
                    MessageBox.Show("Book not found!", "Not found!");
                    textBoxBkSearch.Clear();
                    textBoxBkSearch.Focus();
                    return;
                }
                BookDA.ListSearchResult(abook, listViewBooks);
                return;
            }

            MessageBox.Show("Please enter a valid term to be searched.", "No search information!");
            return;
        }
        private void buttonSearchBook_Click(object sender, EventArgs e)
        {
            Book book = BookDA.Search(Convert.ToInt32(textBoxSearch.Text));

            if (book != null)
            {
                textBoxIsbn.Text        = (book.ISBN).ToString();
                textBoxTitle.Text       = book.title;
                textBoxAuthorId.Text    = (book.AuthorId).ToString();
                textBoxYear.Text        = (book.YearPublished).ToString();
                textBoxQuantity.Text    = (book.QOH).ToString();
                textBoxPrice.Text       = (book.UnitPrice).ToString();
                textBoxCategoryId.Text  = (book.categoryId).ToString();
                textBoxPublisherId.Text = (book.publisherId).ToString();
            }

            else
            {
                MessageBox.Show("Book not Found!");
                textBoxSearch.Clear();
                textBoxSearch.Focus();
            }
        }
Beispiel #26
0
        //Delete
        private void buttonOrdDel_Click(object sender, EventArgs e)
        {
            DialogResult ans = MessageBox.Show("Are you sure you want to delete this Order?", "Delete Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

            if (ans == DialogResult.Yes)
            {
                OrderDA.Delete(Convert.ToInt32(textBoxOrId.Text));
                int     bkQuantity = OrderDA.SearchID(Convert.ToInt32(textBoxOrId.Text)).OrdBkQuantity;
                decimal ordCost    = OrderDA.SearchID(Convert.ToInt32(textBoxOrId.Text)).OrdCost;

                Book   abook   = new Book();
                Client aclient = new Client();

                abook   = BookDA.SearchISBN(Convert.ToInt64(comboBoxOrdISBN.Text));
                aclient = ClientDA.SearchName(comboBoxOrdClient.Text);

                abook.BkQOH          = abook.BkQOH + bkQuantity;
                aclient.ClientCredit = aclient.ClientCredit + ordCost;

                OrderDA.ListOrder(listViewOrder);
                UpdateComboBoxes();
            }
        }
Beispiel #27
0
        private void btn_Search_Click(object sender, EventArgs e)
        {
            {
                Book cust = BookDA.Search(Convert.ToInt32(txt_input.Text));
                if (cust != null)
                {
                    txt_ISBN.Text = (cust.ISBN).ToString();

                    txt_Price.Text     = (cust.UnitPrice).ToString();
                    txt_Published.Text = (cust.YearPublished).ToString();

                    txt_qty.Text   = (cust.QOH).ToString();
                    txt_Title.Text = (cust.Title);
                }

                else
                {
                    MessageBox.Show("Author not Found");
                    txt_input.Clear();
                    txt_input.Focus();
                }
            }
        }
 private void buttonDeleteBook_Click(object sender, EventArgs e)
 {
     BookDA.Delete(Convert.ToInt32(textBoxIsbn.Text));
     MessageBox.Show("Book has been deleted successfully from the database", "Confirmation");
 }
 private void buttonListBook_Click(object sender, EventArgs e)
 {
     listViewBook.Items.Clear();
     BookDA.ListBooks(listViewBook);
 }
Beispiel #30
0
        //留言板
        public int message_center(string mID, string bookID, string title, string date, string contents)
        {
            BookDA bookDA = new BookDA();

            return(bookDA.message_center(mID, bookID, title, date, contents));
        }