Пример #1
0
        private void buttonSearchBook_Click(object sender, EventArgs e)
        {
            int choice = comboBoxBook.SelectedIndex;

            switch (choice)
            {
            case -1:
                MessageBox.Show("Please select the search option");
                break;

            case 0:
                Books book = BooksDA.Search(Convert.ToInt32(textBoxEnterInformation.Text));
                if (book != null)
                {
                    textBoxISBN.Text          = book.ISBN.ToString();
                    textBoxTitle.Text         = book.Title;
                    textBoxAuthor.Text        = book.BookAuthor;
                    textBoxYearPublished.Text = (book.BookYearPublished).ToString();
                    textBoxQOH.Text           = (book.BookQOH).ToString();
                    textBoxUnitPrice.Text     = (book.BookUnitePrice).ToString();



                    textBoxISBN.Enabled = false;
                }

                else
                {
                    MessageBox.Show("ISBN not Found!");
                    textBoxEnterInformation.Clear();
                    textBoxEnterInformation.Focus();
                }
                break;

            case 1:
                Books boo = BooksDA.SearchTitle(textBoxEnterInformation.Text);
                if (boo != null)
                {
                    textBoxISBN.Text          = (boo.ISBN).ToString();
                    textBoxTitle.Text         = boo.Title;
                    textBoxAuthor.Text        = boo.BookAuthor;
                    textBoxYearPublished.Text = (boo.BookYearPublished).ToString();
                    textBoxQOH.Text           = (boo.BookQOH).ToString();
                    textBoxUnitPrice.Text     = (boo.BookUnitePrice).ToString();

                    textBoxISBN.Enabled = false;
                }

                else
                {
                    MessageBox.Show("Title not Found!");
                    textBoxEnterInformation.Clear();
                    textBoxEnterInformation.Focus();
                }
                break;

            default:
                break;
            }
        }
        private void buttonSaveEmployee_Click(object sender, EventArgs e)
        {
            if ((textBoxclientname.Text == "") || (textBoxbooktitle.Text == "") || (textBoxOrderQuantity.Text == "") || (textBoxUnitPrice.Text == "") || (textBoxSubtotal.Text == "") || (textBoxGST.Text == "") || (textBoxPST.Text == "") || (textBoxtotal.Text == ""))
            {
                MessageBox.Show("Please full fill all the fields", "Missing Data");
                ClearAll();
                return;
            }
            else
            {
                Client client = ClientsDA.SearchNM(textBoxclientname.Text);
                Books  book   = BooksDA.SearchTitle(textBoxbooktitle.Text);
                string qtfh   = textBoxclientname.Text;
                string asda   = textBoxbooktitle.Text;
                int    lalala = Convert.ToInt32(textBoxOrderQuantity.Text);
                if (book == null)
                {
                    MessageBox.Show("Wrong Information book, try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (client == null)
                {
                    MessageBox.Show("Wrong Information client, try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (book.BookQOH < Convert.ToInt32(textBoxOrderQuantity.Text))
                {
                    MessageBox.Show("The inventory does not have that quantity of products", "Missing Product");
                    ClearAll();
                    return;
                }
                else
                {
                    Order Or = new Order();

                    if ((client.Name == textBoxclientname.Text) && (book.Title.ToString() == textBoxbooktitle.Text) && (book.BookQOH < Convert.ToInt32(textBoxOrderQuantity.Text)))
                    {
                        Or.OrdernUmber  = Convert.ToInt32(textBoxOrderNumber.Text);
                        Or.OrderDate    = dateTimePickerOrder.Text;
                        Or.ShippingDate = dateTimePickerShipping.Text;
                        Or.ClientNumber = textBoxclientname.Text;
                        Or.BookName     = textBoxbooktitle.Text;
                        Or.Quantity     = Convert.ToInt32(textBoxOrderQuantity.Text);
                        Or.unit         = Convert.ToInt32(textBoxUnitPrice.Text);
                        Or.Subtotal     = Convert.ToInt32(textBoxSubtotal.Text);
                        Or.Gst          = Convert.ToInt32(textBoxGST.Text);
                        Or.Pst          = Convert.ToInt32(textBoxPST.Text);
                        Or.total        = Convert.ToInt32(textBoxtotal.Text);
                        OrdersDA.Save(Or);
                        ClearAll();
                    }
                }
            }
        }