Example #1
0
        /// <summary>
        /// When the "Update Shipped Date" button is clicked, the Orders table in the database
        /// is updated accordingly.  A message indicating success or failure of the update is
        /// displayed.
        /// </summary>
        private void btnUpdateShippedDate_Click(object sender, EventArgs e)
        {
            // Local variable
            DateTime?newShippedDate;            // The new ShippedDate entered in the DateTimePicker

            // (may be null)

            // If the DateTimePicker is unchecked, the ShippedDate will be set to null.
            if (dtpShippedDate.Checked)
            {
                newShippedDate = dtpShippedDate.Value;
            }
            else
            {
                newShippedDate = null;
            }

            try
            {
                bool result = OrderDB.UpdateShippedDate(order, newShippedDate);

                if (result)
                {
                    MessageBox.Show("The shipping date has been updated in the database.", "Success");
                }
                else
                {
                    MessageBox.Show("No rows updated.  Please try again.", "Retry");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, ex.GetType().ToString());
            }
        }
Example #2
0
        /// <summary>
        /// When the selected Order ID is changed in the combo box, retrieve the Order and
        /// Order Details information from the database and display it.
        /// </summary>
        private void cboOrderID_SelectedIndexChanged(object sender, EventArgs e)
        {
            // There is no need to check for invalid orderID here, since it can only be
            // selected from the drop-down list and not manually entered.

            int orderID = Convert.ToInt32(cboOrderID.SelectedItem);

            try
            {
                order = OrderDB.GetOrder(orderID);
                this.DisplayOrder();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, ex.GetType().ToString());
                this.ClearControls();
            }

            try
            {
                orderDetailsList = OrderDetailsDB.GetOrderDetails(orderID);
                this.DisplayOrderDetails();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, ex.GetType().ToString());
                this.ClearControls();
            }
        }
Example #3
0
        private void frmOrders_Load(object sender, EventArgs e)
        {
            List <int> orderIDs;     // Empty list for the order ID values

            // Retrieve all of the order IDs from the database and populate the combo box.
            try
            {
                orderIDs = OrderDB.GetOrderIDs();
                foreach (int id in orderIDs)
                {
                    cboOrderID.Items.Add(id);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, ex.GetType().ToString());
            }
        }