我的代码
我的代码 sqlCheck.Append($@" select M.FNUMBER,'[',S.FNAME,']','超出可用',isnull(qOnLock.qtyLock,0)+isnull(qOut.qtyDocOut,0)-isnull(qDocLock.qty,0)-isnull(qOnhand.qty,0), '。库',isnull(qOnhand.qty,0) ,'锁',isnull(qOnLock.qtyLock,0),'. '--换行用.\r\n没用,char(13)带有xml属性 无法处理 from #itemSum qOut left join M on qOut.msterID = M.FMATERIALID left join S on qOut.StockID = S.FSTOCKID and S.FLOCALEID='2052' left join qOnhand on qOut.msterID=qOnhand.FMATERIALID and qOut.StockID=qOnhand.FSTOCKID left join qOnLock on qOut.msterID=qOnLock.MaterialFId and qOut.StockID = qOnLock.NowSupplyWarehid left join #itemGpLock qDocLock on qOut.msterID=qDocLock.msterID and qOut.StockID = qDocLock.StockID where isnull(qOnhand.qty,0)-isnull(qOnLock.qtyLock,0)-isnull(qOut.qtyDocOut,0)+isnull(qDocLock.qty,0) < 0 --FOR XML PATH('') -- select * from V_DWK_InventoryLock4MS -- if (@outStr<>'') -- select @outStr --else -- select drop table #item drop table #itemSum drop table #itemGpLock "); DataSet dsT = DBUtils.ExecuteDataSet(this.Context, sqlCheck.ToString()); System.IO.StringWriter sw = new System.IO.StringWriter(); System.Xml.XmlTextWriter xw = new System.Xml.XmlTextWriter(sw); dsT.WriteXml(xw); string s = sw.ToString(); //表达式 String matchpattern = @"<([^>]*)>(.*?)<\/\1>"; //String matchpattern = @"<(\w+)([^>]*)>(.*?)<\/\1>"; //$2=(.*?) 进行替换 String replacementpattern = @"$2"; //循环判断 是否还有正确的XML标签 string s2 = s; while (Regex.IsMatch(s2, matchpattern)) { s2 = Regex.Replace(s2, matchpattern, replacementpattern, RegexOptions.Singleline); } if (s2 != s) s = s2; //s = s.Replace("\\r\\n", "\\R\\N"); if (s != "") e.CancelOperation = true; throw new KDBusinessException("校验不通过", s + ",操作失败!"); }