//use this constructor to get the getOrders method from the DB class and catch exception private void GetOrder(int orderID) { try { order = OrdersDB.getOrders(orderID); } catch (Exception ex) { MessageBox.Show(ex.Message, ex.GetType().ToString()); } }
//when update button is clicked, the data updates the database private void btnUpdate_Click(object sender, EventArgs e) { DateTime?newShippedDate; if (txtShippedDate.Text == "") { newShippedDate = null; try { if (newShippedDate > OrderDATE && newShippedDate < ReqDATE || newShippedDate == null) //validation to ensure the newshippedDate is between orderDate and requiredDate or is null { OrdersDB.UpdateOrder(OrderID, oldShippedDate, newShippedDate); this.DialogResult = DialogResult.OK; } //sends back response else { MessageBox.Show("You have provided the wrong Shipped Date"); this.DialogResult = DialogResult.Retry; } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.GetType().ToString()); } } }