Exemple #1
0
        /// <summary>
        ///     Deletes an order line from the database.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DeleteButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (orderLineIdInput.Text.Equals(""))
                {
                    MessageBox.Show("Please input the text box.");
                    orderLineIdInput.Focus();
                    return;
                }
                else if (!Regex.IsMatch(orderLineIdInput.Text, "^[0-9]*$"))
                {
                    MessageBox.Show("Please input only numerical characters into the text box.");
                    orderLineIdInput.Focus();
                    return;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error has occurred, please contact your administrator." + "\n\n" + "The error message is: " + "\n\n" + ex.ToString());
            }

            OrderLineObject orderLine = businessLogicLayer.CheckOrderLinesByID(int.Parse(orderLineIdInput.Text));

            try
            {
                // Order Line Does not Exist
                if (!int.Parse(orderLineIdInput.Text).Equals(orderLine.order_line_id))
                {
                    MessageBox.Show("The Order Line ID provided does not exist.");
                    orderLineIdInput.Focus();
                    return;
                }
                // Delete Order Line
                else
                {
                    orderLine = businessLogicLayer.DeleteCurrentOrderLine(int.Parse(orderLineIdInput.Text));
                    MessageBox.Show("The provided Order Line has been deleted from the system.");
                    return;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error has occurred, please contact your administrator." + "\n\n" + "The error message is: " + "\n\n" + ex.ToString());
            }
        }