public void AddSelectedOldView(ArrayList selectedViewList) { if ((selectedViewList != null) && (selectedViewList.Count != 0)) { for (int i = 0; i < selectedViewList.Count; i++) { DEView view = (DEView)selectedViewList[i]; ArrayList list = new ArrayList(); list.AddRange(this.dataDoc.nodeList); for (int j = 0; j < list.Count; j++) { VMNode1 node = (VMNode1)list[j]; Guid guid2 = new Guid(view.GetName()); if (guid2.Equals(node.OID)) { MessageBox.Show("视图“" + view.Label + "”在视图模型中已经存在,不用再添加了!", "添加原有视图", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); selectedViewList.RemoveAt(i); i--; list.RemoveAt(j); j--; break; } } } if ((selectedViewList != null) && (selectedViewList.Count != 0)) { foreach (DEView view2 in selectedViewList) { Guid oID = new Guid(view2.GetName()); int x = new Random().Next(0, 500); int y = new Random().Next(0, 400); Point startPoint = new Point(x, y); VMNode1 node2 = new VMNode1(oID, startPoint, view2.Label); this.AddOldNode(node2); } PLViewModel model = new PLViewModel(); try { this.dataDoc.TheDataSet = model.FillOldViewInfoToDataSet(this.dataDoc.TheDataSet, selectedViewList); } catch (Exception) { throw new ViewException("添加原有视图失败!"); } } } }
public void ViewFrameFinishEdit(object sender, EventArgs e) { if (MessageBox.Show("是否确定要结束对视图模型的编辑?", "结束编辑视图模型", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.Cancel) { switch (MessageBox.Show("是否保存视图模型?", "保存视图模型", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)) { case DialogResult.Yes: try { this.thePanal.saveFile(); break; } catch (ViewException exception) { MessageBox.Show(exception.Message, "视图模型", MessageBoxButtons.OK, MessageBoxIcon.Hand); return; } catch { MessageBox.Show("保存视图模型“" + ((DEViewModel)this.thePanal.mainWindow.Tag).Name + "”失败!", "视图模型", MessageBoxButtons.OK, MessageBoxIcon.Hand); return; } break; case DialogResult.No: this.thePanal.mainWindow.RefreshViewModel(); break; case DialogResult.Cancel: return; } try { PLViewModel model = new PLViewModel(); DEViewModel tag = (DEViewModel)this.thePanal.mainWindow.Tag; model.ChangeVMLocker(tag.Oid, Guid.Empty); tag.Locker = Guid.Empty; 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 ViewFrameCancelEdit(object sender, EventArgs e) { if (MessageBox.Show("取消编辑会丢失视图模型的所有修改!\n您确定要取消编辑?", "视图模型", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) != DialogResult.Cancel) { PLViewModel model = new PLViewModel(); try { DEViewModel tag = (DEViewModel)this.thePanal.mainWindow.Tag; model.ChangeVMLocker(tag.Oid, Guid.Empty); } catch { MessageBox.Show("编辑视图模型" + ((DEViewModel)this.thePanal.mainWindow.Tag).Name + "操作失败!", "视图模型", MessageBoxButtons.OK, MessageBoxIcon.Hand); return; } this.thePanal.mainWindow.RefreshViewModel(); } }
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); } } }
public void ViewFrameEdit(object sender, EventArgs e) { PLViewModel model = new PLViewModel(); try { DEViewModel tag = (DEViewModel)this.thePanal.mainWindow.Tag; if (tag == null) { MessageBox.Show("编辑视图模型" + ((DEViewModel)this.thePanal.mainWindow.Tag).Name + "操作失败!", "视图模型", MessageBoxButtons.OK, MessageBoxIcon.Hand); } else { model.ChangeVMLocker(tag.Oid, ClientData.LogonUser.Oid); tag.Locker = ClientData.LogonUser.Oid; 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); } }