Ejemplo n.º 1
0
        //Search button
        private void buttonOrdSearch_Click(object sender, EventArgs e)
        {
            Order aorder = new Order();

            if (!string.IsNullOrEmpty(textBoxOrdSearch.Text))
            {
                switch (comboBoxOrdSearch.SelectedIndex)
                {
                case 0:
                    int tempId;
                    if (!int.TryParse(textBoxOrdSearch.Text, out tempId))
                    {
                        MessageBox.Show("Please enter a valid term to be searched.", "No search information!");
                        return;
                    }
                    aorder = OrderDA.SearchID(Convert.ToInt32(textBoxOrdSearch.Text));
                    break;

                case 1:
                    if (!int.TryParse(textBoxOrdSearch.Text, out tempId))
                    {
                        MessageBox.Show("Please enter a valid term to be searched.", "No search information!");
                        return;
                    }
                    aorder = OrderDA.SearchByClientID(Convert.ToInt32(textBoxOrdSearch.Text));
                    break;

                case 2:
                    aorder = OrderDA.SearchByClientName(textBoxOrdSearch.Text);
                    break;
                }

                if (aorder == null)
                {
                    MessageBox.Show("Order not found!", "Not found!");
                    textBoxOrdSearch.Clear();
                    textBoxOrdSearch.Focus();
                    return;
                }

                OrderDA.ListSearch(aorder, listViewOrder);
                return;
            }
            MessageBox.Show("Please enter a valid term to be searched.", "No search information!");
            return;
        }
Ejemplo n.º 2
0
 //Enable the buttons delete and update in case of a valid entered ID
 private void textBoxOrId_TextChanged(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(textBoxOrId.Text))
     {
         buttonOrdDel.Enabled = false;
         buttonOrdUpd.Enabled = false;
         return;
     }
     if (OrderDA.SearchID(Convert.ToInt32(textBoxOrId.Text)) != null)
     {
         buttonOrdDel.Enabled = true;
         buttonOrdUpd.Enabled = true;
         return;
     }
     buttonOrdDel.Enabled = false;
     buttonOrdUpd.Enabled = false;
 }
Ejemplo n.º 3
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();
        }
Ejemplo n.º 4
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();
            }
        }