private void toolStripButton_dup_default_modify_Click(object sender, EventArgs e) { if (this.listView_dup_defaults.SelectedItems.Count == 0) { MessageBox.Show(this, "尚未选择要修改的缺省关系事项"); return; } ListViewItem item = this.listView_dup_defaults.SelectedItems[0]; DefaultProjectDialog dlg = new DefaultProjectDialog(); MainForm.SetControlFont(dlg, this.Font, false); dlg.dom = this.m_dup_dom; dlg.DatabaseName = item.Text; dlg.DefaultProjectName = ListViewUtil.GetItemText(item, 1); dlg.ShowDialog(this); if (dlg.DialogResult != DialogResult.OK) return; // 兑现到DOM中 XmlNode nodeDefault = this.m_dup_dom.DocumentElement.SelectSingleNode("//default[@origin='" + item.Text + "']"); if (nodeDefault == null) { nodeDefault = this.m_dup_dom.CreateElement("default"); this.m_dup_dom.DocumentElement.AppendChild(nodeDefault); } DomUtil.SetAttr(nodeDefault, "origin", item.Text); DomUtil.SetAttr(nodeDefault, "project", dlg.DefaultProjectName); // 兑现到listview中 Debug.Assert(dlg.DatabaseName == item.Text, ""); ListViewUtil.ChangeItemText(item, 1, dlg.DefaultProjectName); this.DupChanged = true; }
private void toolStripButton_dup_default_new_Click(object sender, EventArgs e) { string strError = ""; DefaultProjectDialog dlg = new DefaultProjectDialog(); MainForm.SetControlFont(dlg, this.Font, false); dlg.Text = "新增缺省关系事项"; // dlg.DupCfgDialog = this; dlg.BiblioDbNames = this.GetAllBiblioDbNames(); dlg.dom = this.m_dup_dom; dlg.DatabaseName = ""; // 让填入内容 dlg.DefaultProjectName = ""; dlg.ShowDialog(this); if (dlg.DialogResult != DialogResult.OK) return; // 兑现到DOM中 XmlNode nodeDefault = this.m_dup_dom.DocumentElement.SelectSingleNode("//default[@origin='" + dlg.DatabaseName + "']"); if (nodeDefault != null) { // 查重 strError = "发起路径为 '" + dlg.DatabaseName + "' 的缺省关系事项已经存在,不能再次新增。可编辑已经存在的该事项。"; goto ERROR1; } { nodeDefault = this.m_dup_dom.CreateElement("default"); this.m_dup_dom.DocumentElement.AppendChild(nodeDefault); } DomUtil.SetAttr(nodeDefault, "origin", dlg.DatabaseName); DomUtil.SetAttr(nodeDefault, "project", dlg.DefaultProjectName); // 兑现到listview中 ListViewItem item = new ListViewItem(dlg.DatabaseName, 0); item.SubItems.Add(dlg.DefaultProjectName); this.listView_dup_defaults.Items.Add(item); // 看看数据库名字是否在已经用到的数据库名集合中?如果是,为实在颜色;如果不是,为发虚颜色 List<string> database_names = GetAllBiblioDbNames(); if (database_names.IndexOf(dlg.DatabaseName) == -1) { item.ForeColor = SystemColors.GrayText; item.Tag = null; } else { item.Tag = 1; } this.DupChanged = true; return; ERROR1: MessageBox.Show(this, strError); }