📄 sal_enter_shiporder_c1.pas
字号:
+' else OnHandInv-isnull(Tmp1.DisedShipQty,0) '
+' end, '
+' isnull(Tmp1.DisedShipQty,0) as disedShipQty from ( Select '
+' case when Sa_SaleOrderLine.SloQty-(Sa_SaleOrderLine.ShipQty)-(Sa_SaleOrderLine.PrepareShipQty)>0 then '
+' Sa_SaleOrderLine.SloQty-(Sa_SaleOrderLine.ShipQty)-(Sa_SaleOrderLine.PrepareShipQty) else 0 '
+' end as NoShipQty, '
{ +' case when (Sa_SaleOrderLine.SloQty-(Sa_SaleOrderLine.ShipQty)-(Sa_SaleOrderLine.PrepareShipQty))<=OnHandInv '
+' and (Sa_SaleOrderLine.SloQty-(Sa_SaleOrderLine.ShipQty)-(Sa_SaleOrderLine.PrepareShipQty))>0 '
+' then Sa_SaleOrderLine.SloQty-(Sa_SaleOrderLine.ShipQty)-(Sa_SaleOrderLine.PrepareShipQty) '
+' when (Sa_SaleOrderLine.SloQty-(Sa_SaleOrderLine.ShipQty)-(Sa_SaleOrderLine.PrepareShipQty))>OnHandInv '
+' then OnHandInv '
+' Else 0 '
+' end AbleShipQty, '
} +' Sa_SaleOrder.CustomerCode,Sa_SaleOrder.PayTermCode,PayTerm.PayTermName,Sa_SaleOrder.CurrencyCode,Sa_SaleOrder.TaxRate_Percent, '
+' Sa_SaleOrderLine.*,Item.ItemName, '
+' Sa_SaleOrderLine.ItemCode+'' ''+Item.ItemName As ItemFalg, '
+' UomName,Item.BatchCtrl, '
+' CurrentInv.WhCode,Warehouse.WhName ,CurrentInv.WhPositionCode, '//CurrentInv
+' WhPosition.WhPositionName, OnHandInv ,BatchNo='''' '
+' From Sa_SaleOrderLine '
+' Join Sa_SaleOrder '
+' On Sa_SaleOrderLine.SloNo=Sa_SaleOrder.SloNo '
+' Left Join PayTerm On Sa_SaleOrder.PayTermCode=PayTerm.PayTermCode '
+' left Join Item '
+' On Sa_SaleOrderLine.ItemCode=Item.ItemCode '
+' left Join Uom '
+' On Item.UomCode=Uom.UomCode '
+' Left Join CurrentInv '
+' On CurrentInv.ItemCode= Sa_SaleOrderLine.ItemCode '
+' left Join Warehouse '
+' On CurrentInv.WhCode=Warehouse.WhCode '//CurrentInv
+' left Join WhPosition '
+' On ( CurrentInv.WhPositionCode =WhPosition.WhPositionCode) '
+' and (CurrentInv.WhCode=WhPosition.WhCode) and WhPosition.WhPositionType=0 '
+' Where Item.BatchCtrl=0 '
+' and Sa_SaleOrderLine.SloLineStatus=6 '
+' And CustomerCode= '''+CustomerCode +''''
+' And (Sa_SaleOrderLine.SloNo between '''+SloNoStArt+''' and '''+SloNoend+''')'
+' And (CreateDate Between '''+CreateDateStArt+''' And '''+CreateDateend+''') '
+IIFValue(TmpFlag, '' ,' and Sa_SaleOrderLine.SloQty-(Sa_SaleOrderLine.ShipQty)-(Sa_SaleOrderLine.PrepareShipQty)>0 ')
+' union'
+' Select '
+' case when TMpsa_SaleOrderLine.SloQty-(TMpsa_SaleOrderLine.ShipQty)-(TMpsa_SaleOrderLine.PrepareShipQty)>0 then '
+' TMpsa_SaleOrderLine.SloQty-(TMpsa_SaleOrderLine.ShipQty)-(TMpsa_SaleOrderLine.PrepareShipQty) '
+' else 0 '
+' end as NoShipQty,'
+' TMpsa_SaleOrderLine.* ,BatchCurrentInv.WhCode,Warehouse.WhName ,'
+' BatchCurrentInv.WhPositionCode,'
+' WhPosition.WhPositionName,InvQty as OnHandInv,BatchCurrentInv.BatchNo'
+' from '
+' (Select Sa_SaleOrder.CustomerCode, Sa_SaleOrder.PayTermCode,PayTerm.PayTermName,Sa_SaleOrder.CurrencyCode, '
+' Sa_SaleOrder.TaxRate_Percent,Sa_SaleOrderLine.*,Item.ItemName,'
+' Sa_SaleOrderLine.ItemCode+'' ''+Item.ItemName As ItemFalg,'
+' UomName,Item.BatchCtrl '
+' From Sa_SaleOrderLine '
+' Join Sa_SaleOrder '
+' On Sa_SaleOrderLine.SloNo=Sa_SaleOrder.SloNo'
+' Left Join PayTerm On Sa_SaleOrder.PayTermCode=PayTerm.PayTermCode '
+' Left Join Item '
+' On Sa_SaleOrderLine.ItemCode=Item.ItemCode '
+' Left Join Uom '
+' On Item.UomCode=Uom.UomCode'
+' Where Item.BatchCtrl=1 '
+' and Sa_SaleOrderLine.SloLineStatus=6 '
+' And CustomerCode= '''+CustomerCode +''''
+' And (Sa_SaleOrderLine.SloNo between '''+SloNoStArt+''' and '''+SloNoend+''')'
+' And (CreateDate Between '''+CreateDateStArt+''' And '''+CreateDateend+''') )TMpsa_SaleOrderLine'
+' Left join (Select ItemCode,BatchNo '
+' From BatchLine '
+' Join Batch On Batch.BatchId=BatchLine.BatchId'
+' Where BatchStatus=0 And (BatchLine.UsefulCtrl=0 Or (DateDiff(dd,FirstInDate,GetDate())<=UsefulDate ) ) ) TmpBatchLine '
+' on TMpsa_SaleOrderLine.ItemCode =TmpBatchLine.ItemCode'
+' Left Join BatchCurrentInv '
+' On BatchCurrentInv.BatchNo=TmpBatchLine.BatchNo'
+' left Join Warehouse '
+' On Warehouse.WhCode=BatchCurrentInv.WhCode'
+' left Join WhPosition '
+' On (BatchCurrentInv.WhPositionCode =WhPosition.WhPositionCode) and (WhPosition.WhPositionType=0) and (BatchCurrentInv.WhCode=WhPosition.WhCode) '
+IIFValue(TmpFlag, '' ,' where TMpsa_SaleOrderLine.SloQty-(TMpsa_SaleOrderLine.ShipQty)-(TMpsa_SaleOrderLine.PrepareShipQty)>0 ')
+' ) as tmp '
+' left join ( select InvOutBill.WhCode, '
+' InvOutBill.WhPositionCode, '
+' InvOutBillLine.ItemCode, '
+' sum(isnull(InvOutBillLine.InvBillQty,0) ) as DisedShipQty '
+' from InvOutBillLine '
+' join InvOutBill on InvOutBill.InvBillId=InvOutBillLine.InvBillid '
+' and InvOutBill.InvBillWhChCk=0 '
+' and InvOutBillLine.InvBillQty>=0 '
+' and InvOutBill.BillTypeCode in (''0205'',''0206'') '
+' group by InvOutBill.WhCode,InvOutBill.WhPositionCode,InvOutBillLine.ItemCode ) as Tmp1 '
+' on Tmp.WhCode=Tmp1.WhCode and Tmp.WhPositionCode=Tmp1.WhPositionCode and Tmp.ItemCode=Tmp1.ItemCode ';
getdata;
Flag:=False;
// DBGridEhTitleClick(DBGridEh.Columns[0] );
end;
procedure TFrm_Sal_Enter_ShipOrder_C1.FormActivate(Sender: TObject);
begin
inherited;
Frm_Sys_Condition:= TFrm_Sal_Enter_ShipOrder_C.Create(self);
act_filter.Execute;
SelectFromSql:=' select Tmp.*, '
+' AbleShipQty=case When OnHandInv-isnull(Tmp1.DisedShipQty,0) <=0 then 0 '
+' When OnHandInv-IsNull(Tmp1.DisedShipQty,0)-NoShipQty>=0 then NoShipQty '
+' else OnHandInv-isnull(Tmp1.DisedShipQty,0) '
+' end, '
+' isnull(Tmp1.DisedShipQty,0) as disedShipQty from ( Select '
+' case when Sa_SaleOrderLine.SloQty-(Sa_SaleOrderLine.ShipQty)-(Sa_SaleOrderLine.PrepareShipQty)>0 then '
+' Sa_SaleOrderLine.SloQty-(Sa_SaleOrderLine.ShipQty)-(Sa_SaleOrderLine.PrepareShipQty) else 0 '
+' end as NoShipQty, '
+' Sa_SaleOrder.CustomerCode,Sa_SaleOrder.PayTermCode,PayTerm.PayTermName,Sa_SaleOrder.CurrencyCode,Sa_SaleOrder.TaxRate_Percent, '
+' Sa_SaleOrderLine.*,Item.ItemName, '
+' Sa_SaleOrderLine.ItemCode+'' ''+Item.ItemName As ItemFalg, '
+' UomName,Item.BatchCtrl, '
+' CurrentInv.WhCode,Warehouse.WhName ,CurrentInv.WhPositionCode, '//CurrentInv
+' WhPosition.WhPositionName, OnHandInv ,BatchNo='''' '
+' From Sa_SaleOrderLine '
+' Join Sa_SaleOrder '
+' On Sa_SaleOrderLine.SloNo=Sa_SaleOrder.SloNo '
+' Left Join PayTerm On Sa_SaleOrder.PayTermCode=PayTerm.PayTermCode '
+' left Join Item '
+' On Sa_SaleOrderLine.ItemCode=Item.ItemCode '
+' left Join Uom '
+' On Item.UomCode=Uom.UomCode '
+' Left Join CurrentInv '
+' On CurrentInv.ItemCode= Sa_SaleOrderLine.ItemCode '
+' left Join Warehouse '
+' On CurrentInv.WhCode=Warehouse.WhCode '//CurrentInv
+' left Join WhPosition '
+' On ( CurrentInv.WhPositionCode =WhPosition.WhPositionCode) '
+' and (CurrentInv.WhCode=WhPosition.WhCode) and WhPosition.WhPositionType=0 '
+' Where Item.BatchCtrl=0 '
+' and Sa_SaleOrderLine.SloLineStatus=6 '
+' And CustomerCode= '''+CustomerCode +''''
+' And (Sa_SaleOrderLine.SloNo between '''+SloNoStArt+''' and '''+SloNoend+''')'
+' And (CreateDate Between '''+CreateDateStArt+''' And '''+CreateDateend+''') '
+IIFValue(TmpFlag, '' ,' and Sa_SaleOrderLine.SloQty-(Sa_SaleOrderLine.ShipQty)-(Sa_SaleOrderLine.PrepareShipQty)>0 ')
+' union'
+' Select '
+' case when TMpsa_SaleOrderLine.SloQty-(TMpsa_SaleOrderLine.ShipQty)-(TMpsa_SaleOrderLine.PrepareShipQty)>0 then '
+' TMpsa_SaleOrderLine.SloQty-(TMpsa_SaleOrderLine.ShipQty)-(TMpsa_SaleOrderLine.PrepareShipQty) '
+' else 0 '
+' end as NoShipQty,'
+' TMpsa_SaleOrderLine.* ,BatchCurrentInv.WhCode,Warehouse.WhName ,'
+' BatchCurrentInv.WhPositionCode,'
+' WhPosition.WhPositionName,InvQty as OnHandInv,BatchCurrentInv.BatchNo'
+' from '
+' (Select Sa_SaleOrder.CustomerCode, Sa_SaleOrder.PayTermCode,PayTerm.PayTermName,Sa_SaleOrder.CurrencyCode, '
+' Sa_SaleOrder.TaxRate_Percent,Sa_SaleOrderLine.*,Item.ItemName,'
+' Sa_SaleOrderLine.ItemCode+'' ''+Item.ItemName As ItemFalg,'
+' UomName,Item.BatchCtrl '
+' From Sa_SaleOrderLine '
+' Join Sa_SaleOrder '
+' On Sa_SaleOrderLine.SloNo=Sa_SaleOrder.SloNo'
+' Left Join PayTerm On Sa_SaleOrder.PayTermCode=PayTerm.PayTermCode '
+' Left Join Item '
+' On Sa_SaleOrderLine.ItemCode=Item.ItemCode '
+' Left Join Uom '
+' On Item.UomCode=Uom.UomCode'
+' Where Item.BatchCtrl=1 '
+' and Sa_SaleOrderLine.SloLineStatus=6 '
+' And CustomerCode= '''+CustomerCode +''''
+' And (Sa_SaleOrderLine.SloNo between '''+SloNoStArt+''' and '''+SloNoend+''')'
+' And (CreateDate Between '''+CreateDateStArt+''' And '''+CreateDateend+''') )TMpsa_SaleOrderLine'
+' Left join (Select ItemCode,BatchNo '
+' From BatchLine '
+' Join Batch On Batch.BatchId=BatchLine.BatchId'
+' Where BatchStatus=0 And (BatchLine.UsefulCtrl=0 Or (DateDiff(dd,FirstInDate,GetDate())<=UsefulDate ) ) ) TmpBatchLine '
+' on TMpsa_SaleOrderLine.ItemCode =TmpBatchLine.ItemCode'
+' Left Join BatchCurrentInv '
+' On BatchCurrentInv.BatchNo=TmpBatchLine.BatchNo'
+' left Join Warehouse '
+' On Warehouse.WhCode=BatchCurrentInv.WhCode'
+' left Join WhPosition '
+' On (BatchCurrentInv.WhPositionCode =WhPosition.WhPositionCode) and (WhPosition.WhPositionType=0) and (BatchCurrentInv.WhCode=WhPosition.WhCode) '
+IIFValue(TmpFlag, '' ,' where TMpsa_SaleOrderLine.SloQty-(TMpsa_SaleOrderLine.ShipQty)-(TMpsa_SaleOrderLine.PrepareShipQty)>0 ')
+' ) as tmp '
+' left join ( select InvOutBill.WhCode, '
+' InvOutBill.WhPositionCode, '
+' InvOutBillLine.ItemCode, '
+' sum(isnull(InvOutBillLine.InvBillQty,0) ) as DisedShipQty '
+' from InvOutBillLine '
+' join InvOutBill on InvOutBill.InvBillId=InvOutBillLine.InvBillid '
+' and InvOutBill.InvBillWhChCk=0 '
+' and InvOutBillLine.InvBillQty>=0 '
+' and InvOutBill.BillTypeCode in (''0205'',''0206'') '
+' group by InvOutBill.WhCode,InvOutBill.WhPositionCode,InvOutBillLine.ItemCode ) as Tmp1 '
+' on Tmp.WhCode=Tmp1.WhCode and Tmp.WhPositionCode=Tmp1.WhPositionCode and Tmp.ItemCode=Tmp1.ItemCode ';
getdata;
Flag:=False;
dbgrideh.SetFocus;
// DBGridEhTitleClick(DBGridEh.Columns[0] );
end;
procedure TFrm_Sal_Enter_ShipOrder_C1.AdoQry_MainBeforeEdit(
DataSet: TDataSet);
begin
inherited;
If AdoQry_Main.fieldbyname('WhCode').AsString='' then
begin
DispInfo('不能选择没有仓库的记录!',3);
abort;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -