private void button_modifyDatabase_Click(object sender, EventArgs e) { if (this.listView_databases.SelectedItems.Count == 0) { MessageBox.Show(this, "尚未选择要修改的目标数据库事项"); return; } ListViewItem item = this.listView_databases.SelectedItems[0]; TargetDatabaseDialog dlg = new TargetDatabaseDialog(); MainForm.SetControlFont(dlg, this.Font, false); dlg.BiblioDbNames = this.BiblioDbNames; dlg.UsedDbNames = this.GetUsedDbNames(); // dlg.DupCfgDialog = this.DupCfgDialog; dlg.DatabaseName = item.Text; dlg.Threshold = ListViewUtil.GetItemText(item, 1); dlg.StartPosition = FormStartPosition.CenterScreen; dlg.ShowDialog(this); if (dlg.DialogResult != DialogResult.OK) return; string strError = ""; // 查重 ListViewItem exist = FindDatabaseItem(dlg.DatabaseName); if (exist != null && exist != item) { exist.Selected = true; exist.EnsureVisible(); strError = "已经存在名为 '" + dlg.DatabaseName + "' 的目标库事项。放弃刚才对事项的修改。"; goto ERROR1; } Debug.Assert(this.m_nodeProject != null, ""); // 找到相应的<database>元素 XmlNode nodeDatabase = this.m_nodeProject.SelectSingleNode("database[@name='" + item.Text + "']"); if (nodeDatabase == null) { strError = "名为 '" + item.Text + "' 的<database>元素并不存在"; goto ERROR1; } // 兑现对DOM的修改 DomUtil.SetAttr(nodeDatabase, "name", dlg.DatabaseName); DomUtil.SetAttr(nodeDatabase, "threshold", dlg.Threshold); // 兑现对ListViewItem的修改 item.Text = dlg.DatabaseName; ListViewUtil.ChangeItemText(item, 1, dlg.Threshold); this.Changed = true; return; ERROR1: MessageBox.Show(this, strError); }
private void button_modifyDatabase_Click(object sender, EventArgs e) { if (this.listView_databases.SelectedItems.Count == 0) { MessageBox.Show(this, "尚未选择要修改的目标数据库事项"); return; } ListViewItem item = this.listView_databases.SelectedItems[0]; TargetDatabaseDialog dlg = new TargetDatabaseDialog(); MainForm.SetControlFont(dlg, this.Font, false); dlg.BiblioDbNames = this.BiblioDbNames; dlg.UsedDbNames = this.GetUsedDbNames(); // dlg.DupCfgDialog = this.DupCfgDialog; dlg.DatabaseName = item.Text; dlg.Threshold = ListViewUtil.GetItemText(item, 1); dlg.StartPosition = FormStartPosition.CenterScreen; dlg.ShowDialog(this); if (dlg.DialogResult != DialogResult.OK) { return; } string strError = ""; // 查重 ListViewItem exist = FindDatabaseItem(dlg.DatabaseName); if (exist != null && exist != item) { exist.Selected = true; exist.EnsureVisible(); strError = "已经存在名为 '" + dlg.DatabaseName + "' 的目标库事项。放弃刚才对事项的修改。"; goto ERROR1; } Debug.Assert(this.m_nodeProject != null, ""); // 找到相应的<database>元素 XmlNode nodeDatabase = this.m_nodeProject.SelectSingleNode("database[@name='" + item.Text + "']"); if (nodeDatabase == null) { strError = "名为 '" + item.Text + "' 的<database>元素并不存在"; goto ERROR1; } // 兑现对DOM的修改 DomUtil.SetAttr(nodeDatabase, "name", dlg.DatabaseName); DomUtil.SetAttr(nodeDatabase, "threshold", dlg.Threshold); // 兑现对ListViewItem的修改 item.Text = dlg.DatabaseName; ListViewUtil.ChangeItemText(item, 1, dlg.Threshold); this.Changed = true; return; ERROR1: MessageBox.Show(this, strError); }
private void button_newDatabase_Click(object sender, EventArgs e) { TargetDatabaseDialog dlg = new TargetDatabaseDialog(); MainForm.SetControlFont(dlg, this.Font, false); dlg.BiblioDbNames = this.BiblioDbNames; dlg.UsedDbNames = this.GetUsedDbNames(); // dlg.DupCfgDialog = this.DupCfgDialog; dlg.StartPosition = FormStartPosition.CenterScreen; dlg.ShowDialog(this); if (dlg.DialogResult != DialogResult.OK) return; string strError = ""; // 查重 ListViewItem exist = FindDatabaseItem(dlg.DatabaseName); if (exist != null) { exist.Selected = true; exist.EnsureVisible(); strError = "已经存在名为 '" + dlg.DatabaseName + "' 的目标库事项。放弃新创建事项。"; goto ERROR1; } Debug.Assert(this.m_nodeProject != null, ""); // 找到<project>元素 XmlNode nodeProject = this.m_nodeProject; if (nodeProject == null) { Debug.Assert(false, ""); strError = "m_nodeProject成员为空"; goto ERROR1; } // 创建新的<database>元素 XmlNode nodeDatabase = this.dom.CreateElement("database"); nodeProject.AppendChild(nodeDatabase); DomUtil.SetAttr(nodeDatabase, "name", dlg.DatabaseName); DomUtil.SetAttr(nodeDatabase, "threshold", dlg.Threshold); // 兑现对ListViewItem的增补 ListViewItem item = new ListViewItem(dlg.DatabaseName, 0); item.SubItems.Add(dlg.Threshold); this.listView_databases.Items.Add(item); item.Selected = true; // 选中刚插入的listviewitem对象 this.Changed = true; return; ERROR1: MessageBox.Show(this, strError); }
private void button_newDatabase_Click(object sender, EventArgs e) { TargetDatabaseDialog dlg = new TargetDatabaseDialog(); MainForm.SetControlFont(dlg, this.Font, false); dlg.BiblioDbNames = this.BiblioDbNames; dlg.UsedDbNames = this.GetUsedDbNames(); // dlg.DupCfgDialog = this.DupCfgDialog; dlg.StartPosition = FormStartPosition.CenterScreen; dlg.ShowDialog(this); if (dlg.DialogResult != DialogResult.OK) { return; } string strError = ""; // 查重 ListViewItem exist = FindDatabaseItem(dlg.DatabaseName); if (exist != null) { exist.Selected = true; exist.EnsureVisible(); strError = "已经存在名为 '" + dlg.DatabaseName + "' 的目标库事项。放弃新创建事项。"; goto ERROR1; } Debug.Assert(this.m_nodeProject != null, ""); // 找到<project>元素 XmlNode nodeProject = this.m_nodeProject; if (nodeProject == null) { Debug.Assert(false, ""); strError = "m_nodeProject成员为空"; goto ERROR1; } // 创建新的<database>元素 XmlNode nodeDatabase = this.dom.CreateElement("database"); nodeProject.AppendChild(nodeDatabase); DomUtil.SetAttr(nodeDatabase, "name", dlg.DatabaseName); DomUtil.SetAttr(nodeDatabase, "threshold", dlg.Threshold); // 兑现对ListViewItem的增补 ListViewItem item = new ListViewItem(dlg.DatabaseName, 0); item.SubItems.Add(dlg.Threshold); this.listView_databases.Items.Add(item); item.Selected = true; // 选中刚插入的listviewitem对象 this.Changed = true; return; ERROR1: MessageBox.Show(this, strError); }