private IList<TmpTableInfo> PO2VO(IList<IMES.DataModel.COAReceivingDef> dataLst) { IList<TmpTableInfo> tmpDataLst = new List<TmpTableInfo>(); foreach (COAReceivingDef tmp in dataLst) { TmpTableInfo info = new TmpTableInfo(); info.po = tmp.po; info.shipDate = Convert.ToDateTime(tmp.shippingDate); info.custPN = tmp.custPN; info.iecpn = tmp.iecPN; info.descr = tmp.description; info.begSN = tmp.begNO; info.endSN = tmp.endNO; info.qty = Convert.ToInt32(tmp.qty); info.editor = tmp.editor; info.cdt = DateTime.Now; info.cust = tmp.customerName; info.udt = DateTime.Now; info.pc = tmp.pc; //check BeginNO EndNo... // EndNO BeginNo format must be same // EndNO must be > BeginNO //xp,w7..,需要字符为13位,并且后10位是数字,并且数字部分BeginNo<EndNo... //if (info.begSN.Trim().StartsWith(COANOFORMATXP) && info.endSN.Trim().StartsWith(COANOFORMATXP) // ||(info.begSN.Trim().StartsWith(COANOFORMATW7) && info.endSN.Trim().StartsWith(COANOFORMATW7)) // ||(info.begSN.Trim().StartsWith(COANOFORMATUL) && info.endSN.Trim().StartsWith(COANOFORMATUL))) //{ // if(info.begSN.Trim().Length==13&&info.endSN.Trim().Length==13) //{ //截取后面的数字部分,并验证是否为数字,BegNo<EndNo,qty 必须为(endNO-beginNo)+1 CheckBegNoAndEndNoLength(info); CheckBegNoAndEndNoStartString(info,SLICEINDEX); CheckBegNoAndEndNo(info,SLICEINDEX); //} //else //{ // //throw Exception // //位数不对 // ThrowBizException("DMT107"); //} //} //V-,共需要字符为11位,并且后就为是数字,数字部分BeginNo<EndNo,qty 必须为(endNO-beginNo)+1 //else if(info.begSN.Trim().StartsWith(COANOFORMATV) && info.endSN.Trim().StartsWith(COANOFORMATV)) //{ //if(info.begSN.Trim().Length==11&&info.endSN.Trim().Length==11) //{ //截取后面的数字部分,并验证是否为数字,BegNo<EndNo.. //CheckBegNoAndEndNo(info,2); //} //else //{ // //throw Exception // //位数不对 // ThrowBizException("DMT107"); //} //} //可能全是数字 符合要求,可能是不符合要求的窜.. //else //{ //if (info.begSN.Trim().Length == 14) //{ //CheckBegNoAndEndNo(info); //} //else //{ // //throw Exception.. // //begVal,endVal不符合要求... // ThrowBizException("DMT108"); //} //} tmpDataLst.Add(info); } return tmpDataLst; }
private static void CheckBegNoAndEndNo(TmpTableInfo info) { long beginNo, endNo; try { beginNo = Convert.ToInt64(info.begSN.Trim()); endNo = Convert.ToInt64(info.endSN.Trim()); if (endNo < beginNo)//(endNo <= beginNo) { //throw Excepiton ThrowBizException("DMT110"); } else { if (info.qty != (endNo - beginNo) + 1) { //throw qty invali.... ThrowBizException("DMT111"); } } } catch (FormatException) { ThrowBizException("DMT109"); //throw Exception... } }
private static void CheckBegNoAndEndNoStartString(TmpTableInfo info,int startIndex) { string startBeg = info.begSN.Trim().Substring(0,info.begSN.Trim().Length-startIndex); string startEnd = info.endSN.Trim().Substring(0,info.endSN.Trim().Length-startIndex); if(string.Compare(startBeg,startEnd,true)!=0) { ThrowBizException("DMT130"); } }
private static void CheckBegNoAndEndNo(TmpTableInfo info,int startIndex) { long beginNo, endNo; try { //slice begno&endno last 7 char and compare... beginNo = Convert.ToInt64(info.begSN.Trim().Substring(info.begSN.Trim().Length - startIndex, startIndex)); endNo = Convert.ToInt64(info.endSN.Trim().Substring(info.endSN.Trim().Length - startIndex, startIndex)); if (endNo < beginNo)//(endNo <= beginNo) { //throw Excepiton ThrowBizException("DMT110"); } else { if(info.qty!=(endNo-beginNo)+1) { //throw qty invali.... ThrowBizException("DMT111"); } } } catch (FormatException) { ThrowBizException("DMT109"); //throw Exception... } }
private static void CheckBegNoAndEndNoLength(TmpTableInfo info) { if (info.begSN.Trim().Length<=8||info.endSN.Trim().Length<=8) { ThrowBizException("DMT129"); } //compare begno&endno length if (info.begSN.Trim().Length != info.endSN.Trim().Length) { ThrowBizException("DMT128"); } }