private static void CreatStatusAllIndex(COAReceive coa, ref long begIndex, ref long endIndex, int sliceIndex) { begIndex = Convert.ToInt64(coa.BegSN.Trim().Substring(coa.BegSN.Trim().Length-sliceIndex,sliceIndex)); endIndex = Convert.ToInt64(coa.EndSN.Trim().Substring(coa.EndSN.Trim().Length-sliceIndex,sliceIndex)); }
private static void CheckBeginNoAndEndNoToDB(COAReceive coa, ref long begIndex, ref long endIndex, COAReceive cr, int sliceIndex) { begIndex = Convert.ToInt64(coa.BegSN.Trim().Substring(coa.BegSN.Trim().Length-sliceIndex,sliceIndex)); endIndex = Convert.ToInt64(coa.EndSN.Trim().Substring(coa.EndSN.Trim().Length-sliceIndex,sliceIndex)); long DBbegIndex = Convert.ToInt64(cr.BegSN.Trim().Substring(cr.BegSN.Trim().Length-sliceIndex,sliceIndex)); long DBendIndex = Convert.ToInt64(cr.EndSN.Trim().Substring(cr.EndSN.Trim().Length-sliceIndex,sliceIndex)); if (begIndex >= DBendIndex && begIndex <= DBendIndex || (endIndex >= DBbegIndex && endIndex <= DBendIndex)) { //throw Exception //记录不能再DB begno endno 之间... ThrowBizException("DMT112"); } }
public bool saveItemIntoCOAReceiveTable(string pc) { try { IUnitOfWork ow = new UnitOfWork(); IList<TmpTableInfo> tmpDataLst=itemRepository.GetTmpTableItem(pc); IList<COAReceive> COADataLst = new List<COAReceive>(); IList<COAReceive> DBCOADateLst = itemRepository.GetAllCOAReceivingItems(); IList<COAStatus> statusLst = new List<COAStatus>(); if (tmpDataLst != null && tmpDataLst.Count > 0) { foreach(TmpTableInfo tmp in tmpDataLst) { COAReceive coa = new COAReceive(); coa.PO = tmp.po; coa.ShipDate =tmp.shipDate; coa.CustPN = tmp.custPN; coa.IECPN = tmp.iecpn; coa.Descr = tmp.descr; coa.BegSN = tmp.begSN; coa.EndSN = tmp.endSN; coa.Qty = tmp.qty; coa.Editor = tmp.editor; coa.Cdt = tmp.cdt; coa.Cust = tmp.cust; coa.Udt = tmp.udt; //当前对象的前缀 string currentprefix = coa.BegSN.Trim().Substring(0, coa.BegSN.Trim().Length - SLICEINDEX); //判断新加入BegNo,EndNo是否包含在在DB中BegNo,EndNo之中.. long begIndex = 0, endIndex = 0; begIndex = Convert.ToInt64(coa.BegSN.Trim().Substring(coa.BegSN.Trim().Length - SLICEINDEX, SLICEINDEX)); endIndex = Convert.ToInt64(coa.EndSN.Trim().Substring(coa.EndSN.Trim().Length - SLICEINDEX, SLICEINDEX)); //DB无数据. if (DBCOADateLst.Count == 0) { //if (coa.BegSN.Trim().StartsWith(COANOFORMATXP) // || (coa.BegSN.Trim().StartsWith(COANOFORMATW7) ) // || (coa.BegSN.Trim().StartsWith(COANOFORMATUL))) { CreatStatusAllIndex(coa, ref begIndex, ref endIndex,SLICEINDEX); } //else if (coa.BegSN.Trim().StartsWith(COANOFORMATV)) //{ // CreatStatusAllIndex(coa, ref begIndex, ref endIndex,2); //} //else //{ // begIndex = Convert.ToInt64(coa.BegSN.Trim()); // endIndex = Convert.ToInt64(coa.EndSN.Trim()); //} } else { //DB中存在数据. foreach (COAReceive cr in DBCOADateLst) { string dbprefix = cr.BegSN.Trim().Substring(0, cr.BegSN.Trim().Length - SLICEINDEX); if (string.Compare(dbprefix, currentprefix, true) == 0) //if (coa.BegSN.Trim().StartsWith(COANOFORMATXP) && cr.BegSN.Trim().StartsWith(COANOFORMATXP) // || (coa.BegSN.Trim().StartsWith(COANOFORMATW7) && cr.BegSN.Trim().StartsWith(COANOFORMATW7)) // || (coa.BegSN.Trim().StartsWith(COANOFORMATUL) && cr.BegSN.Trim().StartsWith(COANOFORMATUL))) { CheckBeginNoAndEndNoToDB(coa, ref begIndex, ref endIndex, cr, SLICEINDEX); } //else if (coa.BegSN.Trim().StartsWith(COANOFORMATV) && cr.BegSN.Trim().StartsWith(COANOFORMATV)) //{ // CheckBeginNoAndEndNoToDB(coa, ref begIndex, ref endIndex, cr, 1); //} //数字... //else //{ // try // { // begIndex = Convert.ToInt64(coa.BegSN.Trim()); // endIndex = Convert.ToInt64(coa.EndSN.Trim()); // long DBbegIndex = Convert.ToInt64(cr.BegSN.Trim()); // long DBendIndex = Convert.ToInt64(cr.EndSN.Trim()); // if (begIndex >= DBendIndex && begIndex <= DBendIndex || (endIndex >= DBbegIndex && endIndex <= DBendIndex)) // { // //throw Exception // //记录不能再DB begno endno 之间... // ThrowBizException("DMT112"); // } // } // catch (FormatException) // { // //忽略.. // } //} } } for (long i = begIndex; i <= endIndex; i++) { COAStatus status = new COAStatus(); //string prefix=String.Empty; //if (coa.BegSN.Trim().StartsWith(COANOFORMATXP)) //{ // prefix=COANOFORMATXP; //} //else if (coa.BegSN.Trim().StartsWith(COANOFORMATW7)) //{ // prefix=COANOFORMATW7; //} //else if (coa.BegSN.Trim().StartsWith(COANOFORMATUL)) //{ // prefix=COANOFORMATUL; //} //else if (coa.BegSN.Trim().StartsWith(COANOFORMATV)) //{ // prefix=COANOFORMATV; //} //if(!String.IsNullOrEmpty(prefix)) //{ // status.COASN = prefix+i; //} //else //{ // status.COASN = i.ToString(); //} //Debug, 不足六位前面补0 //status.COASN = currentprefix + i; status.COASN = currentprefix + string.Format("{0:D6}", i); status.IECPN = coa.CustPN; status.LineID = ""; status.Editor = coa.Editor; status.Status = "A0"; status.Cdt = DateTime.Now; status.Udt = DateTime.Now; statusLst.Add(status); } COADataLst.Add(coa); } itemRepository.SaveItemIntoCOAStatusTableDefered(ow,statusLst); itemRepository.RemoveTmpTableItemDefered(ow, pc); itemRepository.SaveItemIntoCOAReceiveTableDefered(ow, COADataLst); ow.Commit(); return true; } } catch(Exception) { throw; } return false; }