/// <summary> /// 打开新窗体 /// </summary> private void OpenForm(TreeNode treeNode) { //DataRow dataRow = treeNode.Tag as DataRow; BaseModuleEntity moduleEntity = treeNode.Tag as BaseModuleEntity; // 若又没C\S窗体,又没B\S网址,那就是空的,不执行任何操作 //if (string.IsNullOrEmpty(dataRow[BaseModuleEntity.FieldFormName].ToString()) // && string.IsNullOrEmpty(dataRow[BaseModuleEntity.FieldAssemblyName].ToString()) // && string.IsNullOrEmpty(dataRow[BaseModuleEntity.FieldNavigateUrl].ToString())) if (string.IsNullOrEmpty(moduleEntity.FormName) && string.IsNullOrEmpty(moduleEntity.AssemblyName) && string.IsNullOrEmpty(moduleEntity.NavigateUrl)) { return; } // 如果打开的是消息窗口 if (moduleEntity.FormName == "FrmMessage") { if (barLeft.Items.Contains("dockContainerItem2")) { barLeft.AutoHide = false; barLeft.SelectedDockContainerItem = dockContainerItem2; } if (barRightN.Items.Contains("dockContainerItem2")) { barRightN.AutoHide = false; barRightN.SelectedDockContainerItem = dockContainerItem2; } if (barRight.Items.Contains("dockContainerItem2")) { barRight.AutoHide = false; barRight.SelectedDockContainerItem = dockContainerItem2; barRight.Focus(); } return; } // 如果为锁定窗体 if (moduleEntity.FormName == "FrmLock") { tmrLock.Stop(); DotNet.WinForm.FrmScreenLock frmLock = new FrmScreenLock(); if (frmLock.ShowDialog(this) == DialogResult.OK) { LoadFormLockInfo(); } return; } // 优先打开C\S窗体 if (!string.IsNullOrEmpty(moduleEntity.FormName)) { // 通过数据库的值获得要打开的模块对应的窗体类型。 System.Type type = System.Type.GetType(moduleEntity.AssemblyName + "." + moduleEntity.FormName + "," + moduleEntity.AssemblyName); if (type == null) { // MessageBox.Show(AppMessage.MSG1000, AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } object obj = (object)Activator.CreateInstance(type, null); BaseForm mdiForm = obj as BaseForm; // 判断是否弹出窗口,进行特殊处理 if (mdiForm.ShowDialogOnly) { mdiForm.HelpButton = false; mdiForm.ShowInTaskbar = false; mdiForm.MinimizeBox = false; mdiForm.ShowDialog(this); return; } // 打开窗口 if (!this.AllowSameMenu) { if (TabIsExist(moduleEntity.Code)) { return; } } CreateTabControl(mdiForm, moduleEntity.Code, moduleEntity.Code); return; } // 这里是直接打开可执行文件的方法 if (string.IsNullOrEmpty(moduleEntity.FormName) && !string.IsNullOrEmpty(moduleEntity.AssemblyName)) { string assemblyName = moduleEntity.AssemblyName; assemblyName = this.UserInfo.GetUserParameter(assemblyName); System.Diagnostics.Process.Start(assemblyName); return; } // 最后判断是否为要打开的网址 string url = moduleEntity.NavigateUrl; if (!string.IsNullOrEmpty(url)) { url = this.UserInfo.GetUrl(url); if (treeNode.Text == "办公管理") { this.webBrowser.Url = new Uri(url); // tabControlMain.Refresh(); tabControlMain.SelectedTab = this.tabItemMain; return; } if (TabIsExist("Browser")) { FrmIE frmIE = (FrmIE)tabControlMain.SelectedPanel.Controls[0]; frmIE.webBrowser.Navigate(url); } else { FrmIE frmIE = new FrmIE { MUrl = url }; // 浏览器为了标识Name保持只打开一个 CreateTabControl(frmIE, "Browser", moduleEntity.Code); } } }
/// <summary> /// 打开新窗体 /// </summary> private void OpenForm(TreeNode treeNode) { //DataRow dataRow = treeNode.Tag as DataRow; BaseModuleEntity moduleEntity = treeNode.Tag as BaseModuleEntity; // 若又没C\S窗体,又没B\S网址,那就是空的,不执行任何操作 //if (string.IsNullOrEmpty(dataRow[BaseModuleEntity.FieldFormName].ToString()) // && string.IsNullOrEmpty(dataRow[BaseModuleEntity.FieldAssemblyName].ToString()) // && string.IsNullOrEmpty(dataRow[BaseModuleEntity.FieldNavigateUrl].ToString())) if (string.IsNullOrEmpty(moduleEntity.FormName) && string.IsNullOrEmpty(moduleEntity.AssemblyName) && string.IsNullOrEmpty(moduleEntity.NavigateUrl)) { return; } // 如果打开的是消息窗口 if (moduleEntity.FormName == "FrmMessage") { if (barLeft.Items.Contains("dockContainerItem2")) { barLeft.AutoHide = false; barLeft.SelectedDockContainerItem = dockContainerItem2; } if (barRightN.Items.Contains("dockContainerItem2")) { barRightN.AutoHide = false; barRightN.SelectedDockContainerItem = dockContainerItem2; } if (barRight.Items.Contains("dockContainerItem2")) { barRight.AutoHide = false; barRight.SelectedDockContainerItem = dockContainerItem2; barRight.Focus(); } return; } // 如果为锁定窗体 if (moduleEntity.FormName == "FrmLock") { tmrLock.Stop(); var frmLock = new FrmScreenLock(); if (frmLock.ShowDialog(this) == DialogResult.OK) { LoadFormLockInfo(); } return; } // 优先打开C\S窗体 if (!string.IsNullOrEmpty(moduleEntity.FormName)) { // 通过数据库的值获得要打开的模块对应的窗体类型。 System.Type type = System.Type.GetType(moduleEntity.AssemblyName + "." + moduleEntity.FormName + "," + moduleEntity.AssemblyName); if (type == null) { // MessageBox.Show(AppMessage.MSG1000, AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } object obj = (object)Activator.CreateInstance(type, null); BaseForm mdiForm = obj as BaseForm; // 判断是否弹出窗口,进行特殊处理 if (mdiForm.ShowDialogOnly) { mdiForm.HelpButton = false; mdiForm.ShowInTaskbar = false; mdiForm.MinimizeBox = false; mdiForm.ShowDialog(this); return; } // 打开窗口 if (!this.AllowSameMenu) { if (TabIsExist(moduleEntity.Code)) { return; } } CreateTabControl(mdiForm, moduleEntity.Code, moduleEntity.Code); return; } // 这里是直接打开可执行文件的方法 if (string.IsNullOrEmpty(moduleEntity.FormName) && !string.IsNullOrEmpty(moduleEntity.AssemblyName)) { string assemblyName = moduleEntity.AssemblyName; assemblyName = this.UserInfo.GetUserParameter(assemblyName); System.Diagnostics.Process.Start(assemblyName); return; } // 最后判断是否为要打开的网址 string url = moduleEntity.NavigateUrl; if (!string.IsNullOrEmpty(url)) { url = this.UserInfo.GetUrl(url); if (treeNode.Text == "办公管理") { this.webBrowser.Url = new Uri(url); // tabControlMain.Refresh(); tabControlMain.SelectedTab = this.tabItemMain; return; } if (TabIsExist("Browser")) { FrmIE frmIE = (FrmIE)tabControlMain.SelectedPanel.Controls[0]; frmIE.webBrowser.Navigate(url); } else { FrmIE frmIE = new FrmIE { MUrl = url }; // 浏览器为了标识Name保持只打开一个 CreateTabControl(frmIE, "Browser", moduleEntity.Code); } } }