// 检查各个字段内容是否正确 // return: // -1 有错 // 0 正确 public int VerifyFields(out string strError) { strError = ""; int nRet = 0; string strRange = this.Range; string strOrderTime = this.OrderTime; if (string.IsNullOrEmpty(strRange) == false) { // 检查出版时间范围字符串是否合法 // 如果使用单个出版时间来调用本函数,也是可以的 // return: // -1 出错 // 0 正确 nRet = LibraryServerUtil.CheckPublishTimeRange(strRange, true, // TODO: 期刊要用 false out strError); if (nRet == -1) { return(-1); } } if (string.IsNullOrEmpty(strOrderTime) == false) { try { DateTime time = DateTimeUtil.FromRfc1123DateTimeString(strOrderTime); if (time.Year == 1753) { strError = "订购时间字符串 '" + strOrderTime + "' 这是一个不太可能的时间"; return(-1); } } catch (Exception ex) { strError = "订购时间字符串 '" + strOrderTime + "' 格式错误: " + ex.Message; return(-1); } } // 验证馆藏分配字符串 string strDistribute = this.Distribute; if (string.IsNullOrEmpty(strDistribute) == false) { LocationCollection locations = new LocationCollection(); nRet = locations.Build(strDistribute, out strError); if (nRet == -1) { strError = "馆藏分配字符串 '" + strDistribute + "' 格式错误: " + strError; return(-1); } } return(0); }
/// <summary> /// 结束前的校验 /// </summary> /// <param name="strError">返回错误信息</param> /// <returns>-1: 出错; 0: 没有错误</returns> internal override int FinishVerify(out string strError) { #if NO strError = ""; int nRet = 0; string strRange = this.orderEditControl_editing.Range; string strOrderTime = this.orderEditControl_editing.OrderTime; if (string.IsNullOrEmpty(strRange) == false) { // 检查出版时间范围字符串是否合法 // 如果使用单个出版时间来调用本函数,也是可以的 // return: // -1 出错 // 0 正确 nRet = LibraryServerUtil.CheckPublishTimeRange(strRange, out strError); if (nRet == -1) { goto ERROR1; } } if (string.IsNullOrEmpty(strOrderTime) == false) { try { DateTime time = DateTimeUtil.FromRfc1123DateTimeString(strOrderTime); if (time.Year == 1753) { strError = "订购时间字符串 '" + strOrderTime + "' 这是一个不太可能的时间"; goto ERROR1; } } catch (Exception ex) { strError = "订购时间字符串 '" + strOrderTime + "' 格式错误: " + ex.Message; goto ERROR1; } } // TODO: 验证馆藏分配字符串 return(0); ERROR1: return(-1); #endif // 检查各个字段内容是否正确 // return: // -1 有错 // 0 正确 return(this.orderEditControl_editing.VerifyFields(out strError)); }
// 检查各个字段内容是否正确 // return: // -1 有错 // 0 正确 public int VerifyFields(out string strError) { strError = ""; int nRet = 0; string strRange = this.Range; string strOrderTime = this.OrderTime; if (string.IsNullOrEmpty(strRange) == false) { // 检查出版时间范围字符串是否合法 // 如果使用单个出版时间来调用本函数,也是可以的 // return: // -1 出错 // 0 正确 nRet = LibraryServerUtil.CheckPublishTimeRange(strRange, true, // TODO: 期刊要用 false out strError); if (nRet == -1) { return(-1); } } if (string.IsNullOrEmpty(strOrderTime) == false) { try { DateTime time = DateTimeUtil.FromRfc1123DateTimeString(strOrderTime); if (time.Year == 1753) { strError = "订购时间字符串 '" + strOrderTime + "' 这是一个不太可能的时间"; return(-1); } } catch (Exception ex) { strError = "订购时间字符串 '" + strOrderTime + "' 格式错误: " + ex.Message; return(-1); } } // 验证馆藏分配字符串 string strDistribute = this.Distribute; if (string.IsNullOrEmpty(strDistribute) == false) { LocationCollection locations = new LocationCollection(); nRet = locations.Build(strDistribute, out strError); if (nRet == -1) { strError = "馆藏分配字符串 '" + strDistribute + "' 格式错误: " + strError; return(-1); } } if (this.FixedPrice.StartsWith("@") == false && this.Price.StartsWith("@") == false && string.IsNullOrEmpty(this.FixedPrice) == false && string.IsNullOrEmpty(this.Price) == false) { // 检查码洋、折扣和单价之间的关系 // return: // -2 码洋和订购价货币单位不同,无法进行校验。 // -1 校验过程出错 // 0 校验发现三者关系不正确 // 1 校验三者关系正确 nRet = OrderDesignControl.VerifyOrderPriceByFixedPricePair( this.FixedPrice, this.Discount, this.Price, "both", out strError); if (nRet != 1 && nRet != -2) { strError = "校验码洋、折扣和单价三者之间关系时出现错误: " + strError; return(-1); } } return(0); }
/// <summary> /// 结束前的校验 /// </summary> /// <param name="strError">返回错误信息</param> /// <returns>-1: 出错; 0: 没有错误</returns> internal override int FinishVerify(out string strError) { strError = ""; int nRet = 0; // TODO: 将来这里要允许使用整个 location 字符串,而不仅仅是馆代码,来发起条码号校验 string strLocation = this.entityEditControl_editing.LocationString; string strLibraryCode = Global.GetLibraryCode(StringUtil.GetPureLocation(strLocation)); string strBarcode = this.entityEditControl_editing.Barcode; // 检查册条码号形式是否合法 if (String.IsNullOrEmpty(strBarcode) == false && // 2009/2/23 this.EntityControl != null && this.EntityControl.NeedVerifyItemBarcode == true) { // 形式校验条码号 // return: // -2 服务器没有配置校验方法,无法校验 // -1 error // 0 不是合法的条码号 // 1 是合法的读者证条码号 // 2 是合法的册条码号 nRet = this.EntityControl.DoVerifyBarcode( string.IsNullOrEmpty(Program.MainForm.BarcodeValidation) ? strLibraryCode : strLocation, // 2019/7/12 strBarcode, out strError); if (nRet == -1) { goto ERROR1; } // 输入的条码格式不合法 if (nRet == 0) { strError = "您输入的条码 " + strBarcode + " 格式不正确(" + strError + ")。请重新输入。"; goto ERROR1; } // 实际输入的是读者证条码号 if (nRet == 1) { strError = "您输入的条码号 " + strBarcode + " 是读者证条码号。请输入册条码号。"; goto ERROR1; } // 对于服务器没有配置校验功能,但是前端发出了校验要求的情况,警告一下 if (nRet == -2) { MessageBox.Show(this, "警告:前端册管理窗开启了校验条码功能,但是服务器端缺乏相应的脚本函数,无法校验条码。\r\n\r\n若要避免出现此警告对话框,请关闭前端册管理窗校验功能"); } } // 馆藏地点字符串里面不能有星号 // string strLocation = this.entityEditControl_editing.LocationString; if (strLocation.IndexOf("*") != -1) { strError = "馆藏地点字符串中不允许出现字符 '*'"; goto ERROR1; } // 价格字符串中不允许出现 @ string strPrice = this.entityEditControl_editing.Price; if (strPrice.IndexOf("@") != -1) { strError = "价格字符串中不允许出现字符 '@'"; goto ERROR1; } if (string.IsNullOrEmpty(strPrice) == false) { CurrencyItem item = null; // 解析单个金额字符串。例如 CNY10.00 或 -CNY100.00/7 nRet = PriceUtil.ParseSinglePrice(strPrice, out item, out strError); if (nRet == -1) { strError = "价格字符串格式不合法: " + strError; goto ERROR1; } } string strIssueDbName = ""; if (string.IsNullOrEmpty(this.BiblioDbName) == false) { strIssueDbName = Program.MainForm.GetIssueDbName(this.BiblioDbName); } if (string.IsNullOrEmpty(strIssueDbName) == false) { // 2014/10/23 if (string.IsNullOrEmpty(this.entityEditControl_editing.PublishTime) == false) { // 检查出版时间范围字符串是否合法 // 如果使用单个出版时间来调用本函数,也是可以的 // return: // -1 出错 // 0 正确 nRet = LibraryServerUtil.CheckPublishTimeRange(this.entityEditControl_editing.PublishTime, out strError); if (nRet == -1) { goto ERROR1; } } // 2014/10/23 if (string.IsNullOrEmpty(this.entityEditControl_editing.Volume) == false) { List <VolumeInfo> infos = null; nRet = VolumeInfo.BuildVolumeInfos(this.entityEditControl_editing.Volume, out infos, out strError); if (nRet == -1) { strError = "卷期字符串 '" + this.entityEditControl_editing.Volume + "' 格式错误: " + strError; goto ERROR1; } } } return(0); ERROR1: return(-1); }