// 册控件请求校验条码 void entityControl1_VerifyBarcode(object sender, VerifyBarcodeEventArgs e) { string strError = ""; e.Result = this.VerifyBarcode( e.LibraryCode, // this.CurrentLibraryCodeList, e.Barcode, out strError); e.ErrorInfo = strError; }
// 将 textbox 的修改兑现到内存中 int UpdateData(out string strError) { strError = ""; if (this.m_nIndex == -1) return 0; if (this.m_bTextChanged == false) return 0; int index = this.m_nIndex; InputBookItem book_item = this.BookItems[index]; string strCurrentBarcode = book_item.BookItem.Barcode; if (strCurrentBarcode != this.textBox_itemBarcode.Text) { if (string.IsNullOrEmpty(this.textBox_itemBarcode.Text) == false) { // 2015/7/22 // 在 listview 内对册条码号进行查重 ListViewItem dup = ListViewUtil.FindItem(this.listView_barcodes, this.textBox_itemBarcode.Text, 0); if (dup != null) { strError = "册条码号 '" + this.textBox_itemBarcode.Text + "' 在当前列表中已经存在,不允许重复登入"; return -1; } } // 校验barcode合法性 if (this.VerifyBarcode != null && this.textBox_itemBarcode.Text != "") // 2009/1/15 { this.SetFloatMessage("waiting", "正在验证册条码号,请稍候 ..."); Application.DoEvents(); // Thread.Sleep(5000); try { VerifyBarcodeEventArgs e = new VerifyBarcodeEventArgs(); e.Barcode = this.textBox_itemBarcode.Text; e.LibraryCode = Global.GetLibraryCode(StringUtil.GetPureLocation(book_item.BookItem.Location)); // 2016/4/18 this.VerifyBarcode(this, e); // return: // -2 服务器没有配置校验方法,无法校验 // -1 error // 0 不是合法的条码号 // 1 是合法的读者证条码号 // 2 是合法的册条码号 if (e.Result != -2) { if (e.Result != 2) { if (String.IsNullOrEmpty(strError) == false) strError = e.ErrorInfo; else { // 如果从服务器端没有得到出错信息,则补充 // -1 error if (e.Result == -1) strError = "在校验条码号 '" + e.Barcode + "' 时出错"; // 0 不是合法的条码号 else if (e.Result == 0) strError = "'" + e.Barcode + "' 不是合法的条码号"; // 1 是合法的读者证条码号 else if (e.Result == 1) strError = "'" + e.Barcode + "' 是读者证条码号(而不是册条码号)"; } return -1; } } } finally { this.SetFloatMessage("", ""); } } book_item.BookItem.Barcode = this.textBox_itemBarcode.Text; this.Changed = true; ListViewItem item = this.listView_barcodes.Items[index]; item.Font = new Font(item.Font, FontStyle.Bold); // 加粗字体表示内容被改变了 book_item.BookItem.Changed = true; book_item.BookItem.RefreshListView(); // 修改ListViewItem显示 this.listView_barcodes.Items[index].Text = this.textBox_itemBarcode.Text; this.m_bTextChanged = false; return 1; } return 0; }
void _biblio_VerifyBarcode(object sender, VerifyBarcodeEventArgs e) { string strError = ""; e.Result = this.VerifyBarcode( this.Channel.LibraryCodeList, e.Barcode, out strError); e.ErrorInfo = strError; }
// 将 textbox 的修改兑现到内存中 int UpdateData(out string strError) { strError = ""; if (this.m_nIndex == -1) { return(0); } if (this.m_bTextChanged == false) { return(0); } int index = this.m_nIndex; InputBookItem book_item = this.BookItems[index]; string strCurrentBarcode = book_item.BookItem.Barcode; if (strCurrentBarcode != this.textBox_itemBarcode.Text) { if (string.IsNullOrEmpty(this.textBox_itemBarcode.Text) == false) { // 2015/7/22 // 在 listview 内对册条码号进行查重 ListViewItem dup = ListViewUtil.FindItem(this.listView_barcodes, this.textBox_itemBarcode.Text, 0); if (dup != null) { strError = "册条码号 '" + this.textBox_itemBarcode.Text + "' 在当前列表中已经存在,不允许重复登入"; return(-1); } } // 校验barcode合法性 if (this.VerifyBarcode != null && this.textBox_itemBarcode.Text != "") // 2009/1/15 { this.SetFloatMessage("waiting", "正在验证册条码号,请稍候 ..."); Application.DoEvents(); // Thread.Sleep(5000); try { VerifyBarcodeEventArgs e = new VerifyBarcodeEventArgs(); e.Barcode = this.textBox_itemBarcode.Text; e.LibraryCode = Global.GetLibraryCode(StringUtil.GetPureLocation(book_item.BookItem.Location)); // 2016/4/18 this.VerifyBarcode(this, e); // return: // -2 服务器没有配置校验方法,无法校验 // -1 error // 0 不是合法的条码号 // 1 是合法的读者证条码号 // 2 是合法的册条码号 if (e.Result != -2) { if (e.Result != 2) { if (String.IsNullOrEmpty(strError) == false) { strError = e.ErrorInfo; } else { // 如果从服务器端没有得到出错信息,则补充 // -1 error if (e.Result == -1) { strError = "在校验条码号 '" + e.Barcode + "' 时出错"; } // 0 不是合法的条码号 else if (e.Result == 0) { strError = "'" + e.Barcode + "' 不是合法的条码号"; } // 1 是合法的读者证条码号 else if (e.Result == 1) { strError = "'" + e.Barcode + "' 是读者证条码号(而不是册条码号)"; } } return(-1); } } } finally { this.SetFloatMessage("", ""); } } book_item.BookItem.Barcode = this.textBox_itemBarcode.Text; this.Changed = true; ListViewItem item = this.listView_barcodes.Items[index]; item.Font = new Font(item.Font, FontStyle.Bold); // 加粗字体表示内容被改变了 book_item.BookItem.Changed = true; book_item.BookItem.RefreshListView(); // 修改ListViewItem显示 this.listView_barcodes.Items[index].Text = this.textBox_itemBarcode.Text; this.m_bTextChanged = false; return(1); } return(0); }
/// <summary> /// 形式校验条码号 /// </summary> /// <param name="strLibraryCode">馆代码</param> /// <param name="strBarcode">册条码号</param> /// <param name="strError">返回出错信息</param> /// <returns> /// <para> -2 服务器没有配置校验方法,无法校验</para> /// <para> -1 出错</para> /// <para> 0 不是合法的条码号</para> /// <para> 1 是合法的读者证条码号</para> /// <para> 2 是合法的册条码号</para> /// </returns> public int DoVerifyBarcode( string strLibraryCode, string strBarcode, out string strError) { if (this.VerifyBarcode == null) { strError = "尚未挂接 VerifyBarcode事件"; return -1; } VerifyBarcodeEventArgs e = new VerifyBarcodeEventArgs(); e.Barcode = strBarcode; e.LibraryCode = strLibraryCode; this.VerifyBarcode(this, e); strError = e.ErrorInfo; return e.Result; }