Example #1
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();
            }
        }
Example #2
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();
        }
Example #3
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);
        }
Example #4
0
        //Search
        private void buttonClSearch_Click(object sender, EventArgs e)
        {
            Client aclient = new Client();

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

                case 0:
                    int tempId;
                    if (!int.TryParse(textBoxClSearch.Text, out tempId))
                    {
                        MessageBox.Show("Please enter a valid term to be searched.", "No search information!");
                        return;
                    }
                    aclient = ClientDA.SearchID(Convert.ToInt32(textBoxClSearch.Text));
                    break;

                case 1:
                    aclient = ClientDA.SearchName(textBoxClSearch.Text);
                    break;
                }

                if (aclient == null)
                {
                    MessageBox.Show("Client not found!", "Not found!");
                    textBoxClSearch.Clear();
                    textBoxClSearch.Focus();
                    return;
                }

                ClientDA.ListSearch(aclient, listViewSales);
                return;
            }
            MessageBox.Show("Please enter a valid term to be searched.", "No search information!");
            return;
        }
Example #5
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();
            }
        }
Example #6
0
 //Displays the selected client Credit
 private void comboBoxOrdClient_SelectedIndexChanged(object sender, EventArgs e)
 {
     textBoxOrdClCredit.Text = ClientDA.SearchName(comboBoxOrdClient.Text).ClientCredit.ToString();
 }