private void buttonOrdUpdate_Click(object sender, EventArgs e)
        {
            if (!Validator.IsEmpty(textBoxOrdQuantity))
            {
                MessageBox.Show("Orders must have a valid quantity.", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                textBoxAutID.Clear();
                textBoxAutID.Focus();
                return;
            }

            Order aorder = createOrder();
            Order xorder = OrderDA.SearchByNumber(Convert.ToInt32(textBoxOrdNumber.Text));

            Books   abook   = BooksDA.SearchByTitle(comboBoxOrdProduct.Text);
            Clients aclient = ClientsDA.Search(comboBoxOrdClient.Text);

            abook.QOH = (abook.QOH + xorder.OrdQuantity) - aorder.OrdQuantity;
            BooksDA.Update(abook);

            aclient.creditLimit = (aclient.creditLimit + aorder.OrdTotal) - aorder.OrdTotal;
            ClientsDA.Update(aclient);

            OrderDA.Update(aorder);
            OrderDA.ListOrder(listViewOrd);

            buttonOrdList.PerformClick();
            UpdateComboBoxes();
        }
        private void buttonUpdateOrder_Click(object sender, EventArgs e)
        {
            List <Orders> listO = OrderDA.ListOrder();

            if (IsValidOrderData())
            {
                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.ClientName         = comboBoxClientID.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);
                DialogResult ans = MessageBox.Show("Do you really want to update this Order?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                if (ans == DialogResult.Yes)
                {
                    OrderDA.Update(aOrder);
                    MessageBox.Show("Order record has been updated successfully", "Confirmation");
                    ClearAll();
                    textBoxOnumber.Focus();
                }
            }
        }
        private void buttonOrdDelete_Click(object sender, EventArgs e)
        {
            DialogResult answer = MessageBox.Show("Do you want to delete this Order?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

            if (answer == DialogResult.Yes)
            {
                OrderDA.Delete(Convert.ToInt32((textBoxOrdNumber.Text)));

                //int BookQuantity = OrderDA.SearchByNumber(Convert.ToInt32(textBoxOrdNumber.Text)).OrdQuantity;
                //decimal orderCost = OrderDA.SearchByNumber(Convert.ToInt32(textBoxOrdNumber.Text)).OrdTotal;

                //Books abook = new Books();
                //Clients aclient = new Clients();


                //abook = BooksDA.SearchByTitle(comboBoxOrdProduct.Text);
                //aclient = ClientsDA.Search(comboBoxOrdClient.Text);

                //abook.QOH = abook.QOH + BookQuantity;
                //aclient.creditLimit = aclient.creditLimit + orderCost;

                OrderDA.ListOrder(listViewOrd);
                buttonOrdList.PerformClick();

                UpdateComboBoxes();
            }
        }
        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();
                }
            }
        }
Beispiel #5
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 #6
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();
            }
        }
 private void buttonOrdList_Click(object sender, EventArgs e)
 {
     listViewOrd.Items.Clear();
     OrderDA.ListOrder(listViewOrd);
 }
Beispiel #8
0
 //List
 private void buttonOrdList_Click(object sender, EventArgs e)
 {
     OrderDA.ListOrder(listViewOrder);
 }