// dropdown事件中如果进行combobox.Enabled的修改,会造成无法留住下拉状态。可以改用防止重入的整数 private void comboBox_batchNo_DropDown(object sender, EventArgs e) { // 防止重入 if (this.m_nInDropDown > 0) { return; } ComboBox combobox = (ComboBox)sender; Cursor oldCursor = this.Cursor; this.Cursor = Cursors.WaitCursor; this.m_nInDropDown++; try { if (combobox.Items.Count == 0 && this.GetBatchNoTable != null) { GetKeyCountListEventArgs e1 = new GetKeyCountListEventArgs(); this.GetBatchNoTable(this, e1); // 2013/3/25 // 当两个 ComboBox 都显示的时候,才对 批次号 列表加入这个事项 if (this.comboBox_location.Visible == true) { combobox.Items.Add("<不指定>"); } if (e1.KeyCounts != null) { for (int i = 0; i < e1.KeyCounts.Count; i++) { KeyCount item = e1.KeyCounts[i]; combobox.Items.Add(item.Key + "\t" + item.Count.ToString() + "笔"); } } else { combobox.Items.Add("<not found>"); } } } finally { this.Cursor = oldCursor; this.m_nInDropDown--; } }
// dropdown事件中如果进行combobox.Enabled的修改,会造成无法留住下拉状态。可以改用防止重入的整数 private void comboBox_batchNo_DropDown(object sender, EventArgs e) { // 防止重入 if (this.m_nInDropDown > 0) return; ComboBox combobox = (ComboBox)sender; Cursor oldCursor = this.Cursor; this.Cursor = Cursors.WaitCursor; this.m_nInDropDown++; try { if (combobox.Items.Count == 0 && this.GetBatchNoTable != null) { GetKeyCountListEventArgs e1 = new GetKeyCountListEventArgs(); this.GetBatchNoTable(this, e1); // 2013/3/25 // 当两个 ComboBox 都显示的时候,才对 批次号 列表加入这个事项 if (this.comboBox_location.Visible == true) combobox.Items.Add("<不指定>"); if (e1.KeyCounts != null) { for (int i = 0; i < e1.KeyCounts.Count; i++) { KeyCount item = e1.KeyCounts[i]; combobox.Items.Add(item.Key + "\t" + item.Count.ToString() + "笔"); } } else { combobox.Items.Add("<not found>"); } } } finally { this.Cursor = oldCursor; this.m_nInDropDown--; } }
// 获得批次号表 // parameters: // strPubType 出版物类型。为 图书/连续出版物/(空) 之一 internal static void GetBatchNoTable(GetKeyCountListEventArgs e, IWin32Window owner, string strPubType, // 出版物类型 string strType, Stop stop, LibraryChannel Channel) { string strError = ""; long lRet = 0; if (e.KeyCounts == null) e.KeyCounts = new List<KeyCount>(); string strName = ""; if (strType == "order") strName = "订购"; else if (strType == "item") strName = "册"; else if (strType == "biblio") strName = "编目"; else throw new Exception("未知的strType '" + strType + "' 值"); // EnableControls(false); stop.OnStop += new StopEventHandler(Channel.DoStop); stop.Initial("正在列出全部" + strName + "批次号 ..."); stop.BeginLoop(); try { int nPerMax = 2000; // 一次检索命中的最大条数限制 string strLang = "zh"; string strDbName = "<all>"; if (strPubType == "图书") strDbName = "<all book>"; else if (strPubType == "连续出版物") strDbName = "<all series>"; else strDbName = "<all>"; if (strType == "order") { lRet = Channel.SearchOrder( stop, strDbName, // "<all>", "", // strBatchNo nPerMax, // -1, "批次号", "left", strLang, "batchno", // strResultSetName "desc", "keycount", // strOutputStyle out strError); } else if (strType == "biblio") { string strQueryXml = ""; lRet = Channel.SearchBiblio( stop, strDbName, // "<all>", // 尽管可以用 this.comboBox_inputBiblioDbName.Text, 以便获得和少数书目库相关的批次号实例,但是容易造成误会:因为数据库名列表刷新后,这里却不会刷新? "", // strBatchNo, nPerMax, // -1, // nPerMax "batchno", "left", strLang, "batchno", // strResultSetName "desc", "keycount", // strOutputStyle "", out strQueryXml, out strError); } else if (strType == "item") { lRet = Channel.SearchItem( stop, strDbName, // "<all>", "", // strBatchNo nPerMax, // -1, "批次号", "left", strLang, "batchno", // strResultSetName "desc", "keycount", // strOutputStyle out strError); } else { Debug.Assert(false, ""); } if (lRet == -1) goto ERROR1; if (lRet == 0) { strError = "没有找到任何" + strName + "批次号检索点"; return; } long lHitCount = lRet; long lStart = 0; long lCount = lHitCount; DigitalPlatform.LibraryClient.localhost.Record[] searchresults = null; // 装入浏览格式 for (; ; ) { Application.DoEvents(); // 出让界面控制权 if (stop != null) { if (stop.State != 0) { strError = "用户中断"; goto ERROR1; } } lRet = Channel.GetSearchResult( stop, "batchno", // strResultSetName lStart, lCount, "keycount", strLang, out searchresults, out strError); if (lRet == -1) { strError = "GetSearchResult() error: " + strError; goto ERROR1; } if (lRet == 0) { // MessageBox.Show(this, "未命中"); return; } // 处理浏览结果 for (int i = 0; i < searchresults.Length; i++) { if (searchresults[i].Cols == null) { strError = "请更新应用服务器和数据库内核到最新版本,才能使用列出" + strName + "批次号的功能"; goto ERROR1; } KeyCount keycount = new KeyCount(); keycount.Key = searchresults[i].Path; keycount.Count = Convert.ToInt32(searchresults[i].Cols[0]); e.KeyCounts.Add(keycount); } lStart += searchresults.Length; lCount -= searchresults.Length; stop.SetMessage("共命中 " + lHitCount.ToString() + " 条,已装入 " + lStart.ToString() + " 条"); if (lStart >= lHitCount || lCount <= 0) break; } } finally { stop.EndLoop(); stop.OnStop -= new StopEventHandler(Channel.DoStop); stop.Initial(""); // EnableControls(true); } return; ERROR1: MessageBox.Show(owner, strError); }
void dlg_GetBatchNoTable(object sender, GetKeyCountListEventArgs e) { Global.GetBatchNoTable(e, this, this.comboBox_load_type.Text, "item", this.stop, this.Channel); #if NOOOOOOOOOOOOOOOOOOO string strError = ""; if (e.KeyCounts == null) e.KeyCounts = new List<KeyCount>(); EnableControls(false); stop.OnStop += new StopEventHandler(this.DoStop); stop.Initial("正在列出全部册批次号 ..."); stop.BeginLoop(); try { MainForm.SetProgressRange(100); MainForm.SetProgressValue(0); long lRet = Channel.SearchItem( stop, "<all>", "", // strBatchNo 2000, // -1, "批次号", "left", this.Lang, "batchno", // strResultSetName "keycount", // strOutputStyle out strError); if (lRet == -1) goto ERROR1; if (lRet == 0) { strError = "没有找到任何册批次号检索点"; return; } long lHitCount = lRet; long lStart = 0; long lCount = lHitCount; SearchResult[] searchresults = null; // 装入浏览格式 for (; ; ) { Application.DoEvents(); // 出让界面控制权 if (stop != null) { if (stop.State != 0) { MessageBox.Show(this, "用户中断"); return; } } lRet = Channel.GetSearchResult( stop, "batchno", // strResultSetName lStart, lCount, "keycount", this.Lang, out searchresults, out strError); if (lRet == -1) { strError = "GetSearchResult() error: " + strError; goto ERROR1; } if (lRet == 0) { // MessageBox.Show(this, "未命中"); return; } // 处理浏览结果 for (int i = 0; i < searchresults.Length; i++) { if (searchresults[i].Cols == null) { strError = "请更新应用服务器和数据库内核到最新版本"; goto ERROR1; } KeyCount keycount = new KeyCount(); keycount.Key = searchresults[i].Path; keycount.Count = Convert.ToInt32(searchresults[i].Cols[0]); e.KeyCounts.Add(keycount); } lStart += searchresults.Length; lCount -= searchresults.Length; stop.SetMessage("共命中 " + lHitCount.ToString() + " 条,已装入 " + lStart.ToString() + " 条"); if (lStart >= lHitCount || lCount <= 0) break; } } finally { stop.EndLoop(); stop.OnStop -= new StopEventHandler(this.DoStop); stop.Initial(""); EnableControls(true); } return; ERROR1: MessageBox.Show(this, strError); #endif }
void dlg_GetBatchNoTable(object sender, GetKeyCountListEventArgs e) { Global.GetBatchNoTable(e, this, "连续出版物", "item", this.stop, this.Channel); }
void ItemStatisForm_GetBatchNoTable(object sender, GetKeyCountListEventArgs e) { Global.GetBatchNoTable(e, this, "", // 目前不分图书和期刊。 TODO: 其实将来可以把pubtype列表定为3态,其中一个是“书+刊” this.DbType, // "item", this.stop, this.Channel); }
private void tabComboBox_inputBatchNo_DropDown(object sender, EventArgs e) { // 防止重入 if (this.m_nInDropDown > 0) return; ComboBox combobox = (ComboBox)sender; Cursor oldCursor = this.Cursor; this.Cursor = Cursors.WaitCursor; this.m_nInDropDown++; try { if (combobox.Items.Count == 0 && this.GetBatchNoTable != null) { GetKeyCountListEventArgs e1 = new GetKeyCountListEventArgs(); this.GetBatchNoTable(this, e1); if (e1.KeyCounts != null) { for (int i = 0; i < e1.KeyCounts.Count; i++) { KeyCount item = e1.KeyCounts[i]; combobox.Items.Add(item.Key + "\t" + item.Count.ToString() + "笔"); } } else { combobox.Items.Add("<not found>"); } } } finally { this.Cursor = oldCursor; this.m_nInDropDown--; } }
void BiblioStatisForm_GetBatchNoTable(object sender, GetKeyCountListEventArgs e) { Global.GetBatchNoTable(e, this, "", // 不分图书和期刊 "biblio", this.stop, this.Channel); #if NOOOOOOOOOOOOOOOOOOOOOOOOOO string strError = ""; if (e.KeyCounts == null) e.KeyCounts = new List<KeyCount>(); EnableControls(false); stop.OnStop += new StopEventHandler(this.DoStop); stop.Initial("正在列出全部编目批次号 ..."); stop.BeginLoop(); try { string strQueryXml = ""; long lRet = Channel.SearchBiblio( stop, "<all>", // 尽管可以用 this.comboBox_inputBiblioDbName.Text, 以便获得和少数书目库相关的批次号实例,但是容易造成误会:因为数据库名列表刷新后,这里却不会刷新? "", // strBatchNo, 2000, // -1, // nPerMax "batchno", "left", this.Lang, "batchno", // strResultSetName "keycount", // strOutputStyle out strQueryXml, out strError); /* long lRet = Channel.SearchItem( stop, "<all>", "", // strBatchNo -1, "批次号", "left", this.Lang, "batchno", // strResultSetName "keycount", // strOutputStyle out strError); * */ if (lRet == -1) goto ERROR1; if (lRet == 0) { strError = "没有找到任何编目批次号检索点"; return; } long lHitCount = lRet; long lStart = 0; long lCount = lHitCount; SearchResult[] searchresults = null; // 装入浏览格式 for (; ; ) { Application.DoEvents(); // 出让界面控制权 if (stop != null) { if (stop.State != 0) { MessageBox.Show(this, "用户中断"); return; } } lRet = Channel.GetSearchResult( stop, "batchno", // strResultSetName lStart, lCount, "keycount", this.Lang, out searchresults, out strError); if (lRet == -1) { strError = "GetSearchResult() error: " + strError; goto ERROR1; } if (lRet == 0) { // MessageBox.Show(this, "未命中"); return; } // 处理浏览结果 for (int i = 0; i < searchresults.Length; i++) { if (searchresults[i].Cols == null) { strError = "请更新应用服务器和数据库内核到最新版本"; goto ERROR1; } KeyCount keycount = new KeyCount(); keycount.Key = searchresults[i].Path; keycount.Count = Convert.ToInt32(searchresults[i].Cols[0]); e.KeyCounts.Add(keycount); } lStart += searchresults.Length; lCount -= searchresults.Length; stop.SetMessage("共命中 " + lHitCount.ToString() + " 条,已装入 " + lStart.ToString() + " 条"); if (lStart >= lHitCount || lCount <= 0) break; } } finally { stop.EndLoop(); stop.OnStop -= new StopEventHandler(this.DoStop); stop.Initial(""); EnableControls(true); } return; ERROR1: MessageBox.Show(this, strError); #endif }