void menu_exportToBiblioSearchForm_Click(object sender, EventArgs e) { string strError = ""; if (this.listView_records.SelectedItems.Count == 0) { strError = "尚未选定要装入其它查询窗的行"; goto ERROR1; } BiblioSearchForm form = new BiblioSearchForm(); form.MdiParent = this.MainForm; form.Show(); form.EnableControls(false); foreach (ListViewItem item in this.listView_records.SelectedItems) { string strLine = Global.BuildLine(item); form.AddLineToBrowseList(strLine); } form.EnableControls(true); return; ERROR1: MessageBox.Show(this, strError); }
// TODO: 优化后,和导出书目记录路径文件合并代码 // 将从属的书目记录装入书目查询窗 void menu_exportToBiblioSearchForm_Click(object sender, EventArgs e) { string strError = ""; int nRet = 0; if (this.listView_records.SelectedItems.Count == 0) { strError = "尚未选定要装入书目查询窗的行"; goto ERROR1; } BiblioSearchForm form = new BiblioSearchForm(); form.MdiParent = this.MainForm; form.Show(); int nWarningLineCount = 0; int nDupCount = 0; stop.Style = StopStyle.EnableHalfStop; stop.OnStop += new StopEventHandler(this.DoStop); stop.Initial("正在装入记录到书目查询窗 ..."); stop.BeginLoop(); form.EnableControls(false); try { #if NO List<string> biblio_recpaths = new List<string>(); Hashtable table = new Hashtable(); foreach (ListViewItem item in this.listView_records.SelectedItems) { Application.DoEvents(); // 出让界面控制权 if (stop != null && stop.State != 0) { strError = "用户中断"; goto ERROR1; } int nCol = -1; string strBiblioRecPath = ""; // 获得事项所从属的书目记录的路径 // return: // -1 出错 // 0 相关数据库没有配置 parent id 浏览列 // 1 找到 nRet = GetBiblioRecPath(item, true, out nCol, out strBiblioRecPath, out strError); if (nRet == -1) goto ERROR1; if (nRet == 0) { // TODO: 转而采用检索法获得书目记录路径 nWarningLineCount++; continue; } // 去重,并保持原始顺序 if (table.ContainsKey(strBiblioRecPath) == false) { biblio_recpaths.Add(strBiblioRecPath); table[strBiblioRecPath] = 1; } else nDupCount++; } #endif List<string> biblio_recpaths = new List<string>(); nRet = GetSelectedBiblioRecPath(out biblio_recpaths, ref nWarningLineCount, ref nDupCount, out strError); if (nRet == -1) goto ERROR1; foreach (string path in biblio_recpaths) { form.AddLineToBrowseList(path); } } finally { form.EnableControls(true); stop.EndLoop(); stop.OnStop -= new StopEventHandler(this.DoStop); stop.Initial(""); stop.HideProgress(); stop.Style = StopStyle.None; } form.RefreshAllLines(); string strText = ""; if (nWarningLineCount > 0) strText = "有 " + nWarningLineCount.ToString() + " 行因为相关库浏览格式没有包含父记录 ID 列而被忽略"; if (nDupCount > 0) { if (string.IsNullOrEmpty(strText) == false) strText += "\r\n\r\n"; strText += "书目记录有 " + nDupCount.ToString() + " 项重复被忽略"; } if (string.IsNullOrEmpty(strText) == false) MessageBox.Show(this, strText); return; ERROR1: MessageBox.Show(this, strError); }