private void OnCommandClick(object sender, EventArgs e) { //Event handler for command button click events this.Cursor = Cursors.WaitCursor; try { Button button = (Button)sender; switch (button.Name) { case "btnAdd": dlgSubscription dlg = new dlgSubscription(); dlg.ShowDialog(this); if (dlg.DialogResult == System.Windows.Forms.DialogResult.OK) { ReportingGateway.CreateSubscription(REPORT_PATH, dlg.RouteClass, dlg.Driver); this.mSubscriptionDS.Clear(); this.mSubscriptionDS.Merge(ReportingGateway.GetSubscriptions(REPORT_PATH)); } break; case "btnClose": this.Close(); break; case "btnRefresh": this.mSubscriptionDS.Clear(); this.mSubscriptionDS.Merge(ReportingGateway.GetSubscriptions(REPORT_PATH)); break; case "btnRemove": string id = this.grdSubscriptions.Selected.Rows[0].Cells["SubscriptionID"].Value.ToString(); ReportingGateway.DeleteSubscription(id); this.mSubscriptionDS.Clear(); this.mSubscriptionDS.Merge(ReportingGateway.GetSubscriptions(REPORT_PATH)); break; } OnValidateForm(null, EventArgs.Empty); } catch (Exception ex) { App.ReportError(ex, true, LogLevel.Error); } finally { this.Cursor = Cursors.Default; } }