private void okBtn_Click(object sender, EventArgs e) { foreach (Module item in moduleCbx.Items.Cast <Module>()) { if (item.Name == moduleCbx.Text) { moduleCbx.SelectedItem = item; } } Module module = moduleCbx.SelectedItem as Module; IDialogService dialogService = MetaManagerServices.GetDialogService(); try { if (module == null) { if (string.IsNullOrEmpty(moduleCbx.Text)) { MessageBox.Show("You must select or enter a module."); return; } else { module = dialogService.CreateModule(moduleCbx.Text, FrontendApplication); PopulateModuleCombobox(); foreach (Module item in moduleCbx.Items.Cast <Module>()) { if (item.Id == module.Id) { moduleCbx.SelectedItem = item; } } } } if (beCbx.SelectedItem == null) { MessageBox.Show("You must select a business entity."); return; } // Save selected Module and Business Entity Config.Frontend.LastImportDialogModule = module.Name; Config.Frontend.LastImportDialogBusinessEntity = (beCbx.SelectedItem as BusinessEntity).Name; Config.Save(); DialogFactory f = new DialogFactory(FrontendApplication); List <Dialog> dialogs = f.CreateDialogs(filenameTbx.Text, beCbx.SelectedItem as BusinessEntity, cbAddDrilldownViews.Checked, tbUniqueness.Text.Trim()); string addReport = ""; if (!previewCb.Checked) { SelectImportDialogs selectDialogForm = new SelectImportDialogs(); selectDialogForm.Dialogs = dialogs; selectDialogForm.MaySelectDialogs = !cbAddDrilldownViews.Checked; DialogResult dr = selectDialogForm.ShowDialog(this); dialogs = selectDialogForm.SelectedDialogs; if (dialogs.Count > 0) { // Persist module, cascading down to dialog etc. dialogService.AddDialogsToModule(module, dialogs); addReport = "\nDatabase was updated."; } } if (dialogs.Count > 0) { string end = ""; if (dialogs.Count > 1) { end = "s"; } string dialogNames = ""; foreach (Dialog dialog in dialogs) { dialogNames += "\n " + dialog.Name; } MessageBox.Show(string.Format("The import created {0} new dialog{1} :\n{2}\n{3}\n", dialogs.Count, end, dialogNames, addReport)); if (previewCb.Checked) { foreach (Dialog d in dialogs) { using (DialogObjectViewer viewer = new DialogObjectViewer()) { viewer.Owner = this; viewer.Dialog = d; viewer.ShowDialog(); } } } filenameTbx.Text = ""; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }