コード例 #1
0
        private void buttonSaveOrder_Click_1(object sender, EventArgs e)
        {
            List <Orders> listO = OrderDA.ListOrder();

            if (IsValidOrderData())
            {
                Inventory product         = InventoryDA.Search(Convert.ToInt32(textBoxISBN.Text));
                Client    client          = ClientDA.Search(Convert.ToInt32(comboBoxClientID.Text));
                string    isbn            = textBoxISBN.Text;
                int       quantityproduct = Convert.ToInt32(textBoxOQty.Text);
                int       id = (Convert.ToInt32(comboBoxClientID.Text));

                if (product == null)
                {
                    MessageBox.Show("Wrong Information product, try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (product.ProductQuantity < Convert.ToInt32(textBoxOQty.Text))
                {
                    MessageBox.Show("We do not have the quantity required on Inventory", "Missing Product");
                    textBoxOQty.Clear();
                    return;
                }
                else
                {
                    if (client.ClientID == (Convert.ToInt32(comboBoxClientID.Text)))
                    {
                        textBoxClientName.Text = client.InstitutionName;
                    }

                    Int32  quantityselected = Convert.ToInt32(textBoxOQty.Text);
                    Double priceselected    = Convert.ToDouble(textBoxProductPrice.Text);
                    Double finalamout       = quantityselected * priceselected;
                    textBoxFinalAmount.Text = finalamout.ToString();
                    Orders aOrder = new Orders();
                    aOrder.OrderNumber        = Convert.ToInt32(textBoxOnumber.Text);
                    aOrder.ISBNProduct        = Convert.ToInt32(textBoxISBN.Text);
                    aOrder.ProductTitle       = textBoxOProductTitle.Text;
                    aOrder.ProductDescription = textBoxProductDescription.Text;
                    aOrder.ClientID           = (Convert.ToInt32(comboBoxClientID.Text));
                    aOrder.ClientName         = textBoxClientName.Text;
                    aOrder.OrderDate          = dateTimePickerOdate.Text;
                    aOrder.ShippingDate       = dateTimePickerSDate.Text;
                    aOrder.OrderQuantity      = Convert.ToInt32(textBoxOQty.Text);
                    aOrder.ProductPrice       = Convert.ToDouble(textBoxProductPrice.Text);
                    aOrder.FinalAmount        = Convert.ToDouble(textBoxFinalAmount.Text);
                    OrderDA.Save(aOrder);
                    listO.Add(aOrder);
                    ClearAll();
                }
            }
        }
コード例 #2
0
        private void buttonSearchBook_Click(object sender, EventArgs e)
        {
            int choice = comboBoxSearchBook.SelectedIndex;

            switch (choice)
            {
            case -1:     // The user didn't select any search option
                MessageBox.Show("Please select the search option");
                break;

            case 0:     //The user selected the search by Customer ID
                Inventory products = InventoryDA.Search(Convert.ToInt32(textBoxInfoBook.Text));
                if (products != null)
                {
                    textBoxISBN.Text                = Convert.ToString(products.ISBNProduct);
                    textBoxBookTitle.Text           = products.ProductTitle;
                    comboboxProductDescription.Text = products.ProductDescription;
                    comboBoxAuthorId.Text           = Convert.ToString(products.AuthorID);
                    comboBoxPublisherName.Text      = products.PublisherName;
                    textBoxYearPushlished.Text      = Convert.ToString(products.ProductYearPublished);
                    textBoxBookPrice.Text           = Convert.ToString(products.ProductPrice);
                    textBoxQuantityOnHand.Text      = Convert.ToString(products.ProductQuantity);
                    textBoxAuthorInfo.Clear();
                    textBoxISBN.Enabled = false;
                }
                else
                {
                    MessageBox.Show("Product not Found!");
                    textBoxISBN.Clear();
                    textBoxISBN.Focus();
                }
                break;

            default:
                break;
            }
        }