// 检索册信息过程中,处理结果集中每条记录的回调函数 void SearchItems_BrowseRecord(object sender, BrowseRecordEventArgs e) { ResPath respath = new ResPath(e.FullPath); XmlDocument tempdom = null; byte[] baTimeStamp = null; string strError = ""; int nRet = this.SearchPanel.GetRecord( respath.Url, respath.Path, out tempdom, out baTimeStamp, out strError); if (nRet == -1) { goto ERROR1; } BookItem item = new BookItem(respath.Path, tempdom); item.Timestamp = baTimeStamp; this.Items.Add(item); item.AddToListView(this.listView_items); return; ERROR1: MessageBox.Show(this, strError); }
// 保存册信息 // (如何删除册信息还是一个棘手的问题) int SaveItems(out string strError) { strError = ""; if (this.Items == null) { strError = "Items尚未初始化"; return(-1); } for (int i = 0; i < this.Items.Count; i++) { BookItem item = this.Items[i]; // 跳过没有修改过的事项 if (item.Changed == false) { continue; } // 新事项 if (item.RecPath == "") { item.RecPath = this.ItemDbName + "/?"; } if (item.Parent == "") { if (String.IsNullOrEmpty(this.BiblioRecPath) == true) { strError = "因BiblioRecPath成员为空,无法构造册信息。"; return(-1); } item.Parent = ResPath.GetRecordId(this.BiblioRecPath); } string strXml = ""; int nRet = item.BuildRecord( out strXml, out strError); if (nRet == -1) { strError = "第 " + Convert.ToString(i + 1) + " 行构造册记录时出错: " + strError; return(-1); } byte[] baOutputTimestamp = null; nRet = this.SearchPanel.SaveRecord( this.ServerUrl, item.RecPath, strXml, item.Timestamp, true, out baOutputTimestamp, out strError); if (nRet == -1) { strError = "第 " + Convert.ToString(i + 1) + " 行保存册记录时出错: " + strError; return(-1); } item.Timestamp = baOutputTimestamp; item.Changed = false; // 事项颜色会发生变化 item.RefreshItemColor(); } return(0); }
// 册登录 // 根据输入的册条码号新增一册信息,或者定位到已经存在的行 void DoRegisterBarcode() { string strError = ""; int nRet; if (this.textBox_itemBarcode.Text == "") { strError = "尚未输入册条码号"; goto ERROR1; } // 看看输入的条码号是否为ISBN条码号 if (IsISBnBarcode(this.textBox_itemBarcode.Text) == true) { // 保存当前册信息 EnableControls(false); nRet = this.SaveItems(out strError); EnableControls(true); if (nRet == -1) { goto ERROR1; } // 转而触发新种检索操作 this.textBox_queryWord.Text = this.textBox_itemBarcode.Text; this.textBox_itemBarcode.Text = ""; this.button_search_Click(null, null); return; } if (this.Items == null) { this.Items = new BookItemCollection(); } // 种内查重 BookItem item = this.Items.GetItem(this.textBox_itemBarcode.Text); ListViewItem listitem = null; // 如果该册条码号的事项已经存在 if (item != null) { listitem = this.GetListViewItem(this.textBox_itemBarcode.Text, null); if (listitem == null) { strError = "册条码号为 '" + this.textBox_itemBarcode.Text + "'的BookItem内存事项存在,但是没有对应的ListViewItem ..."; goto ERROR1; } UnselectListViewItems(); listitem.Selected = true; listitem.Focused = true; this.listView_items.EnsureVisible(this.listView_items.Items.IndexOf(listitem)); goto END1; } List <DoublePath> paths = null; // 种外全面查重 nRet = GetLinkInfoFromBarcode( this.textBox_itemBarcode.Text, true, out paths, out strError); if (nRet == -1) { strError = "册条码号查重操作出现错误:" + strError; goto ERROR1; } if (nRet > 0) { // MessageBox.Show(this, "册条码号 " + this.textBox_itemBarcode.Text + " 出现重复现象,请及时解决。"); SelectDupItemRecordDlg dlg = new SelectDupItemRecordDlg(); dlg.MessageText = "册条码号 " + this.textBox_itemBarcode.Text + " 已经被登录过了,情况如下。\r\n\r\n如果想详细观察,请选择当前希望观察的一条册记录;否则请按“取消”按钮。"; dlg.Paths = paths; dlg.ShowDialog(this); if (dlg.DialogResult != DialogResult.OK) { return; // 放弃操作 } if (this.BiblioRecPath != dlg.SelectedDoublePath.BiblioRecPath) { MessageBox.Show(this, "请注意软件即将自动装入新种 " + dlg.SelectedDoublePath.BiblioRecPath + " 到窗口中,如稍候您想继续对原种 " + this.BiblioRecPath + " 进行册登录,请切记重新装入原种后再行册登录 ..."); } // 先保存本种 nRet = this.SaveItems(out strError); if (nRet == -1) { goto ERROR1; } this.textBox_queryWord.Text = ""; // qingchu yuanlai de jiansuoci , bimian wuhui DoublePath dpath = dlg.SelectedDoublePath; this.BiblioDbName = ResPath.GetDbName(dpath.BiblioRecPath); this.ItemDbName = ResPath.GetDbName(dpath.ItemRecPath); nRet = LoadBiblioRecord( dpath.BiblioRecPath, out strError); if (nRet == -1) { goto ERROR1; } // 突出显示所命中的册信息行 listitem = this.GetListViewItem( this.textBox_itemBarcode.Text, dpath.ItemRecPath); if (listitem == null) { strError = "册条码号为 '" + this.textBox_itemBarcode.Text + "' 册记录路径为 '" + dpath.ItemRecPath + "' 的ListViewItem居然不存在 ..."; goto ERROR1; } listitem.Selected = true; listitem.Focused = true; this.listView_items.EnsureVisible(this.listView_items.Items.IndexOf(listitem)); this.textBox_itemBarcode.SelectAll(); this.textBox_itemBarcode.Focus(); return; } item = new BookItem(); item.Barcode = this.textBox_itemBarcode.Text; item.Changed = true; // 表示这是新事项 this.Items.Add(item); listitem = item.AddToListView(this.listView_items); // 加上选择标记 UnselectListViewItems(); listitem.Focused = true; this.listView_items.EnsureVisible(this.listView_items.Items.IndexOf(listitem)); END1: this.textBox_itemBarcode.SelectAll(); return; ERROR1: MessageBox.Show(this, strError); }