// select isnull((b.YLTR-aaa.TL),0) as YLTR,b.PCLRK from(
// select
//cast( isnull( sum( case when c.BusinessCode='13' and SUBSTRING(b.InvCode, 1, 2) IN ('01','04','05') then isnull(c.Quantity,0) else 0 end ),0)/1000 as decimal(18,2)) as YLTR ,
//cast(isnull( sum( case when c.BusinessCode='50' and b.EATTRIBUTE1='1' and SUBSTRING(b.InvCode, 1, 2) IN ('05') then isnull(c.Quantity,0) else 0 end) ,0)/1000 as decimal(18,2)) as PCLRK
// from dbo.ICSMO a
// left join dbo.ICSMOPick b on a.MODetailID=b.MODetailID and a.WorkPoint=b.WorkPoint
// inner join dbo.ICSWareHouseLotInfoLog c on a.MOCode=c.TransCode and a.Sequence+'~'+b.Sequence=c.TransSequence and c.EATTRIBUTE1<>'1'
// inner join dbo.ICSDepartment d on a.DepCode=d.DepCode
//where 1=1 and isnull(a.EATTRIBUTE7,'')<>'1' {0})b
// left join
// (select
//isnull(sum(isnull(c.Quantity,0)),0)/1000 as TL
// from dbo.ICSMO a
// left join dbo.ICSMOPick b on a.MODetailID=b.MODetailID and a.WorkPoint=b.WorkPoint
// inner join dbo.ICSWareHouseLotInfoLog c on a.MOCode=c.TransCode and a.Sequence+'~'+b.Sequence=c.TransSequence and c.EATTRIBUTE1<>'1' and c.BusinessCode='16-1'
// inner join dbo.ICSDepartment d on a.DepCode=d.DepCode
// where SUBSTRING(b.InvCode, 1, 2) IN ('01','04','05') and isnull(a.EATTRIBUTE7,'')<>'1' {0}) aaa on 1=1";
stringsql=@"select isnull((b.YLTR-aaa.TL),0) as YLTR from(
whereisnull(a.EATTRIBUTE7,'')<>'1'andb.BusinessCode='17'andb.EATTRIBUTE1<>'1'andLEFT(c.MUSERName,2)='" + Type + "'andc.MUSERName='" + Type + Group + "'";
if(!string.IsNullOrWhiteSpace(TimeFrom))
{
sql+="and left(b.MTIME,7)>='"+TimeFrom+"'";
@ -112,17 +127,28 @@ isnull(sum(isnull(c.Quantity,0)),0)/1000 as TL
whereisnull(a.EATTRIBUTE7,'')<>'1'andc.MUSERName='" + Type + Group + "'{0})eona.MOCode=e.MOCodeanda.Sequence=e.Sequenceanda.WorkPoint=e.WorkPointwhered.DepName='" + Type + "'";
// inner join ( select a.MOCode,a.Sequence,a.WorkPoint, e.EATTRIBUTE5,e.EATTRIBUTE1,case when e.EATTRIBUTE3='平方' then isnull(b.Quantity,0) /isnull(e.EATTRIBUTE1,1)*e.EATTRIBUTE5/1000 else isnull( isnull(b.Quantity,0),0)/1000 end as RowCC from dbo.ICSMO a
//inner join dbo.ICSWareHouseLotInfoLog b on a.MOCode=b.TransCode and a.Sequence=b.TransSequence and b.BusinessCode='17'
// inner join dbo.ICSInventory e on a.InvCode=e.InvCode and a.WorkPoint=e.WorkPoint
// inner join dbo.ICSInventoryLot c on b.LotNo=c.LotNo and a.WorkPoint=c.WorkPoint
// where isnull(a.EATTRIBUTE7,'')<>'1' and c.MUSERName= '" + Type + Group + "' {0} )e on a.MOCode = e.MOCode and a.Sequence = e.Sequence and a.WorkPoint = e.WorkPoint where d.DepName = '" + Type + "' ";
sql+=string.Format(@"update ICSWareHouseLotInfo set Quantity=Quantity+'{0}',MUSER='{1}',MUSERName='{2}' where LotNo='{3}' and WorkPoint='{4}'",jo["Quantity"].ToString(),MUSER,MUSERNAME,jo["LotNo"].ToString(),WorkPoint);
sql+=string.Format(@" update ICSTransferApplication set TransferQuantity =TransferQuantity-'{0}' , MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where SDNCode='{3}' and Sequence='{4}' and WorkPoint='{5}'",jo["Quantity"].ToString(),MUSER,MUSERNAME,jo["TransCode"].ToString(),jo["TransSequence"].ToString(),WorkPoint);
sql+=string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' where ID='{0}' and WorkPoint='{1}'",MUSER,MUSERNAME,jo["ID"].ToString(),WorkPoint);
sql+=string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}'",jo["LotNo"].ToString(),WorkPoint);
sql+=string.Format(@" update ICSOApplyNegDetail set IssueNegQuantity =IssueNegQuantity-'{0}' , MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where SDNCode='{3}' and Sequence='{4}' and WorkPoint='{5}'",jo["Quantity"].ToString(),MUSER,MUSERNAME,jo["TransCode"].ToString(),jo["TransSequence"].ToString(),WorkPoint);
sql+=string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' where ID='{0}' and WorkPoint='{1}'",jo["ID"].ToString(),WorkPoint);
sql+=string.Format(@" UPDATE e SET IssueQuantity=ISNULL(IssueQuantity,0)+'{2}'
sql+=string.Format(@"update ICSWareHouseLotInfo set Quantity=Quantity-'{0}',MUSER='{1}',MUSERName='{2}' where LotNo='{3}' and WorkPoint='{4}'",jo["Quantity"].ToString(),MUSER,MUSERNAME,jo["LotNo"].ToString(),WorkPoint);
// sql += string.Format(@" update ICSMOApplyNegDetail set IssueNegQuantity =IssueNegQuantity-'{0}' , MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where SDNCode='{3}' and Sequence='{4}' and WorkPoint='{5}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
sql+=string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' where ID='{0}' and WorkPoint='{1}'",jo["ID"].ToString(),WorkPoint);
sql+=string.Format(@"UPDATE c SET IssueQuantity=ISNULL(IssueQuantity,0)+'{2}'
sql+=string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}'",jo["LotNo"].ToString(),WorkPoint);
sql+=string.Format(@" update ICSOApplyNegDetail set IssueNegQuantity =IssueNegQuantity-'{0}' , MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where SDNCode='{3}' and Sequence='{4}' and WorkPoint='{5}'",jo["Quantity"].ToString(),MUSER,MUSERNAME,jo["TransCode"].ToString(),jo["TransSequence"].ToString(),WorkPoint);
sql+=string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' where ID='{0}' and WorkPoint='{1}'",MUSER,MUSERNAME,jo["ID"].ToString(),WorkPoint);
sql+=string.Format(@" UPDATE e SET IssueQuantity=ISNULL(IssueQuantity,0)+'{2}'
sql+=string.Format(@"update ICSWareHouseLotInfo set Quantity=Quantity-'{0}',MUSER='{1}',MUSERName='{2}' where LotNo='{3}' and WorkPoint='{4}'",jo["Quantity"].ToString(),MUSER,MUSERNAME,jo["LotNo"].ToString(),WorkPoint);
// sql += string.Format(@" update ICSMOApplyNegDetail set IssueNegQuantity =IssueNegQuantity-'{0}' , MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where SDNCode='{3}' and Sequence='{4}' and WorkPoint='{5}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
sql+=string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' where ID='{0}' and WorkPoint='{1}'",MUSER,MUSERNAME,jo["ID"].ToString(),WorkPoint);
sql+=string.Format(@"UPDATE c SET IssueQuantity=ISNULL(IssueQuantity,0)+'{2}'
sql+=string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}'",jo["LotNo"].ToString(),WorkPoint);
sql+=string.Format(@" update ICSMOApplyNegDetail set IssueNegQuantity =IssueNegQuantity-'{0}' , MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where SDNCode='{3}' and Sequence='{4}' and WorkPoint='{5}'",jo["Quantity"].ToString(),MUSER,MUSERNAME,jo["TransCode"].ToString(),jo["TransSequence"].ToString(),WorkPoint);
sql+=string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' where ID='{0}' and WorkPoint='{1}'",MUSER,MUSERNAME,jo["ID"].ToString(),WorkPoint);
sql+=string.Format(@" UPDATE e SET IssueQuantity=ISNULL(IssueQuantity,0)+'{2}'
sql+=string.Format(@"update ICSWareHouseLotInfo set Quantity=Quantity-'{0}',MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where LotNo='{3}' and WorkPoint='{4}'",jo["Quantity"].ToString(),MUSER,MUSERNAME,jo["LotNo"].ToString(),WorkPoint);
// sql += string.Format(@" update ICSMOApplyNegDetail set IssueNegQuantity =IssueNegQuantity-'{0}' , MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where SDNCode='{3}' and Sequence='{4}' and WorkPoint='{5}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
sql+=string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' where ID='{0}' and WorkPoint='{1}'",MUSER,MUSERNAME,jo["ID"].ToString(),WorkPoint);
sql+=string.Format(@"UPDATE c SET IssueQuantity=ISNULL(IssueQuantity,0)+'{2}'