public void ViewFrameUnActive(object sender, EventArgs e) { PLViewModel model = new PLViewModel(); bool flag = false; try { flag = model.HasUsedViewModel(((DEViewModel)this.thePanal.mainWindow.Tag).Oid); } catch (ViewException exception) { MessageBox.Show(exception.Message, "视图模型", MessageBoxButtons.OK, MessageBoxIcon.Hand); return; } catch (Exception) { MessageBox.Show("判断视图模型" + ((DEViewModel)this.thePanal.mainWindow.Tag).Name + "是否已经与业务对象绑定失败!", "视图模型", MessageBoxButtons.OK, MessageBoxIcon.Hand); return; } if (!flag) { if (MessageBox.Show("取消激活后,该视图模型将暂时无法绑定。您是否要继续?", "取消激活", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.Cancel) { return; } } else if (MessageBox.Show("已存在零部件与视图模型“" + ((DEViewModel)this.thePanal.mainWindow.Tag).Name + "”绑定,且取消激活后,该视图模型将暂时无法绑定。您是否要继续?", "视图模型", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.No) { return; } try { DEViewModel tag = (DEViewModel)this.thePanal.mainWindow.Tag; model.ActiveViewModelOrNot(tag.Oid, false); tag.IsActive = 'U'; this.thePanal.mainWindow.Tag = tag; ((FrmMain)this.thePanal.mainWindow.MdiParent).tvwNavigator.SelectedNode.Tag = tag; } catch { MessageBox.Show("取消激活视图模型" + ((DEViewModel)this.thePanal.mainWindow.Tag).Name + "操作失败!", "视图模型", MessageBoxButtons.OK, MessageBoxIcon.Hand); return; } }
public void ViewFrameActive(object sender, EventArgs e) { if (MessageBox.Show("激活该视图模型后,该视图模型将在英泰全生命周期系统使用。\n是否确定要激活该视图?", "激活视图模型", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.Cancel) { PLViewModel model = new PLViewModel(); try { DEViewModel tag = (DEViewModel)this.thePanal.mainWindow.Tag; model.ActiveViewModelOrNot(tag.Oid, true); tag.IsActive = 'A'; this.thePanal.mainWindow.Tag = tag; ((FrmMain)this.thePanal.mainWindow.MdiParent).tvwNavigator.SelectedNode.Tag = tag; } catch { MessageBox.Show("激活视图模型" + ((DEViewModel)this.thePanal.mainWindow.Tag).Name + "操作失败!", "视图模型", MessageBoxButtons.OK, MessageBoxIcon.Hand); } } }