📄 sal_enter_passshiporder.pas
字号:
+' and WhPositionCode='+quotedstr(WhPositionCode)
+' and Batchno='+quotedstr(Batchno);
try
Executesql(AdoQry,sqltext,0);
if AdoQry.RecordCount>0 then
if AdoQry.fieldbyname('InvQty').asfloat>=qty then
Result:=True;
finally
AdoQry.Free;
end;
end;
procedure TFrm_Sal_Enter_PassShipOrder.updateslolineqty(slono:string;slolineno:integer;qty:real;Addorreduce:integer);
var AdoQry:TAdoQuery;
sqltext:string;
begin
AdoQry:=TAdoQuery.Create(self);
AdoQry.Connection:=dbconnect;
sqltext:='update sa_SaleOrderline'
+' set Shipqty=Shipqty'+iifValue(Addorreduce=0,'+','-')+floattostr(qty)+','
+' PrepareShipqty=PrepareShipqty'+iifValue(Addorreduce=0,'-','+')+floattostr(qty)
+' where slono='+quotedstr(slono)
+' and slolineno='+inttostr(slolineno);
try
Executesql(AdoQry,sqltext,1);
finally
AdoQry.Free;
end;
end;
procedure TFrm_Sal_Enter_PassShipOrder.reduceItemqty(ItemCode:string;qty:real;Addorreduce:integer);
var AdoQry:TAdoQuery;
sqltext:string;
begin
AdoQry:=TAdoQuery.Create(self);
AdoQry.Connection:=dbconnect;
sqltext:='update Item'
+' set CurrentonhandInv=CurrentonhandInv'+iifValue(Addorreduce=0,'+','-')+floattostr(qty)
+' where ItemCode='+quotedstr(ItemCode);
try
Executesql(AdoQry,sqltext,1);
finally
AdoQry.Free;
end;
end;
procedure TFrm_Sal_Enter_PassShipOrder.reduceCurrentInv(whCode,WhPositionCode,ItemCode:string;qty:real;Addorreduce:integer);
var AdoQry:TAdoQuery;
sqltext:string;
begin
AdoQry:=TAdoQuery.Create(self);
AdoQry.Connection:=dbconnect;
sqltext:='update CurrentInv '
+' set onhandInv=onhandInv'+iifValue(Addorreduce=0,'+','-')+floattostr(qty)
+' where whCode='+quotedstr(whCode)
+' and WhPositionCode='+quotedstr(WhPositionCode)
+' and ItemCode='+quotedstr(ItemCode);
try
Executesql(AdoQry,sqltext,1);
finally
AdoQry.Free;
end;
end;
procedure TFrm_Sal_Enter_PassShipOrder.reduceBatchInv(Batchno,whCode,WhPositionCode:string;qty:real;Addorreduce:integer);
var AdoQry:TAdoQuery;
sqltext:string;
begin
AdoQry:=TAdoQuery.Create(self);
AdoQry.Connection:=dbconnect;
sqltext:='update BatchCurrentInv '
+' set InvQty=InvQty'+iifValue(Addorreduce=0,'+','-')+floattostr(qty)
+' where Batchno='+quotedstr(Batchno)
+' and whCode='+quotedstr(whCode)
+' and WhPositionCode='+quotedstr(WhPositionCode);
try
Executesql(AdoQry,sqltext,1);
finally
AdoQry.Free;
end;
end;
procedure TFrm_Sal_Enter_PassShipOrder.updateqty(Addorreduce:integer);
var enoughBatch:boolean;
enoughCurrent:boolean;
Book:string;
begin
Book:=AdoQry_Body.BookmArk;
AdoQry_Body.First;
while not AdoQry_Body.Eof do
begin
enoughBatch:=enoughBatchInv(AdoQry_Body.fieldbyname('Batchno').asstring,AdoQry_Body.fieldbyname('whCode').asstring,AdoQry_Body.fieldbyname('WhPositionCode').asstring,AdoQry_Body.fieldbyname('Shipqty').asfloat);
enoughCurrent:=enoughCurrentInv(AdoQry_Body.fieldbyname('whCode').asstring,AdoQry_Body.fieldbyname('WhPositionCode').asstring,AdoQry_Body.fieldbyname('ItemCode').asstring,AdoQry_Body.fieldbyname('Shipqty').asfloat);
if AdoQry_Body.fieldbyname('Batchno').asstring<>'' then
if (Addorreduce=0) and (not enoughBatch) then
begin
DispInfo('第'+inttostr(AdoQry_Body.recno)+'行'+quotedstr(AdoQry_Body.fieldbyname('ItemCode').asstring)+'物料'+AdoQry_Body.fieldbyname('whName').asstring+AdoQry_Body.fieldbyname('WhPositionName').asstring+'批次库存不够!',1);
abort;
end;
if (Addorreduce=0 ) and (not enoughCurrent) then
begin
DispInfo('第'+inttostr(AdoQry_Body.recno)+'行'+quotedstr(AdoQry_Body.fieldbyname('ItemCode').asstring)+'物料'+AdoQry_Body.fieldbyname('whName').asstring+AdoQry_Body.fieldbyname('WhPositionName').asstring+'库存不够!',1);
abort;
end;
if AdoQry_Body.fieldbyname('Batchno').asstring<>'' then
reduceBatchInv(AdoQry_Body.fieldbyname('Batchno').asstring,AdoQry_Body.fieldbyname('whCode').asstring,AdoQry_Body.fieldbyname('WhPositionCode').asstring,AdoQry_Body.fieldbyname('Shipqty').asfloat,1);
reduceCurrentInv(AdoQry_Body.fieldbyname('whCode').asstring,AdoQry_Body.fieldbyname('WhPositionCode').asstring,AdoQry_Body.fieldbyname('ItemCode').asstring,AdoQry_Body.fieldbyname('Shipqty').asfloat,1);
reduceItemqty(AdoQry_Body.fieldbyname('ItemCode').asstring,AdoQry_Body.fieldbyname('Shipqty').asfloat,1);
saveSaleOrderLineHistory(dbconnect,AdoQry_Body.fieldbyname('slono').asstring,AdoQry_Body.fieldbyname('slolineno').asinteger,userCode,1);
updateslolineqty(AdoQry_Body.fieldbyname('slono').asstring,AdoQry_Body.fieldbyname('slolineno').asinteger,AdoQry_Body.fieldbyname('Shipqty').asfloat,0);
AdoQry_Body.Next;
end;
AdoQry_Body.BookmArk:=Book;
end;
procedure TFrm_Sal_Enter_PassShipOrder.FormActivate(Sender: TObject);
begin
inherited;
Act_Check.Enabled:=True;
end;
procedure TFrm_Sal_Enter_PassShipOrder.Act_PreviewExecute(Sender: TObject);
begin
inherited;
Frm_Sal_Enter_ShipOrder_P:=TFrm_Sal_Enter_ShipOrder_P.Create(Application);
Frm_Sal_Enter_ShipOrder_P.SetDBConnect(DbConnect);
Frm_Sal_Enter_ShipOrder_P.SetSysParam(UserCode,ModuleCode,MenuId,DateTimeToStr(Now));
Frm_Sal_Enter_ShipOrder_P.GetHeadData(AdoQry_Body,Trim(Edt_ShipNo.Text),'Preview');
Frm_Sal_Enter_ShipOrder_P:=Nil;
end;
procedure TFrm_Sal_Enter_PassShipOrder.Act_PrintExecute(Sender: TObject);
begin
inherited;
Frm_Sal_Enter_ShipOrder_P:=TFrm_Sal_Enter_ShipOrder_P.Create(Application);
Frm_Sal_Enter_ShipOrder_P.SetDBConnect(DbConnect);
Frm_Sal_Enter_ShipOrder_P.SetSysParam(UserCode,ModuleCode,MenuId,DateTimeToStr(Now));
Frm_Sal_Enter_ShipOrder_P.GetHeadData(AdoQry_Body,Trim(Edt_ShipNo.Text),'Print');
Frm_Sal_Enter_ShipOrder_P:=Nil;
end;
procedure TFrm_Sal_Enter_PassShipOrder.AdoQry_BodyAfterPost(
DataSet: TDataSet);
var
TotalNoTaxAmount,TotalTaxAmount:double;
BookMArk:String;
begin
inherited;
TotalNoTaxAmount:=0;
TotalTaxAmount:=0;
if AdoQry_Body.RecordCount >0 then
BookMArk:=AdoQry_Body.BookMArk;
AdoQry_Body.First;
while not AdoQry_Body.Eof do
begin
TotalTaxAmount:= TotalTaxAmount +AdoQry_Body.fieldbyname('InvBillQty').asfloat*AdoQry_Body.fieldbyname('InvBillPrice').AsFloat;
TotalNoTaxAmount:= TotalNoTaxAmount +AdoQry_Body.fieldbyname('InvBillQty').asfloat*AdoQry_Body.fieldbyname('InvBillNoTaxPrice').AsFloat;
AdoQry_Body.Next;
end;
if AdoQry_Body.RecordCount >0 then
AdoQry_Body.BookMArk:=BookMArk;
Edt_TotalNoTaxAmount.Text:= floattostr(TotalNoTaxAmount);
Edt_TotalTaxAmount.Text:= floattostr(TotalTaxAmount);
end;
procedure TFrm_Sal_Enter_PassShipOrder.AdoQry_BodyBeforeInsert(
DataSet: TDataSet);
begin
inherited;
abort;
end;
function TFrm_Sal_Enter_PassShipOrder.CreateOutBill(
ShipNo: String): Integer;//ShipNo : 发货单号
var AdoQry : TAdoQuery;
SqlText : String;
OutBillNo : String; //出库单号
InvBillId : Integer; //出库单id号
begin
Result := 0;
{产生一张仓库出库单,内容和销售发货单一样}
AdoQry := TAdoQuery.Create(self);
AdoQry.Connection := Dbconnect;
AdoQry.EnableBCD := False;
Try
// OutBillNo := GetAllTypeOrderNo(DbConnect,9);//自动产生出库单号
OutBillNo:=getno(dbConnect,Edt_WhCode.Text+'C'+copy(medt_Createdate.text,3,2)+copy(medt_Createdate.text,6,2)
,'InvBill' );
SqlText:='Insert InvOutBill '
+' (InvBillNo,InvBillDate,InvBillMonth,InvBillCreateTime,Sal_EmployeeCode,SaleEmployeeCode,DeptCode, '
+' CustomerCode,WhCode,WhPositionCode,ShipAddresSCode,ShipModeCode,SaleType,BillTypeCode,CurrencyCode,'
+' PayTermCode,InvBillTaxRate,ExchRate,TotalInvBillNoTaxAmount,TotalInvBillAmount, TotalInvBillNoTaxAmountC, '
+' TotalInvBillAmountC,InvBillWhChCk,RemArk1,SourceNo)'
+' select '+QuotedStr(OutBillNo)+','
+' InvBillDate, '
+' InvBillMonth ,'
+' InvBillCreateTime,Sal_EmployeeCode,SaleEmployeeCode,DeptCode, '
+' CustomerCode,WhCode,WhPositionCode,ShipAddresSCode, '
+' ShipModeCode,SaleType,case BillTypeCode when ''0205'' then ''0203'' '
+' when ''0206'' then ''0204'' '
+' end, '
+' CurrencyCode, '
+' PayTermCode,InvBillTaxRate,ExchRate,TotalInvBillNoTaxAmount,TotalInvBillAmount,TotalInvBillNoTaxAmountC, '
+' TotalInvBillAmountC,InvBillWhChCk,RemArk1,InvBillNo '
+' from InvOutBill '
+' Where InvBillNo = '+QuotedStr(ShipNo);
ExecuteSql(AdoQry,SqlText,1);
ExecuteSql(AdoQry,'Select * from InvOutBill '
+' where InvBillNo='+QuotedStr(OutBillNo),0) ;
InvBillId := AdoQry.fieldbyname('InvBillId').AsInteger;
SqlText:='Insert InvOutBillLine '
+' (InvBillId,InvBillLineNo,SloNo,SloLineNo,ItemCode,InvBillQty,InvBillNoTaxPrice,InvBillNoTaxPriceC,'
+' InvBillNoTaxAmount,InvBillNoTaxAmountC,InvBillPrice, InvBillPriceC,'
+' InvBillAmount, InvBillAmountC,DiSCountRate,DiSCountAmount,BillLineRemArk,BatchNo)'
+' select '+IntToStr(InvBillId)+','
+' InvBillLineNo,SloNo,SloLineNo,ItemCode,InvBillQty,InvBillNoTaxPrice,InvBillNoTaxPriceC,'
+' InvBillNoTaxAmount,InvBillNoTaxAmountC,InvBillPrice,InvBillPriceC,'
+' InvBillAmount,InvBillAmountC,InvOutBillLine.DiSCountRate,InvOutBillLine.DiSCountAmount,BillLineRemArk,BatchNo '
+' from InvOutBillLine '
+' Join InvOutBill On InvOutBillLIne.InvBillId=InvOutBill.InvBillId and InvOutBill.InvBillNo = '+QuotedStr(ShipNo);
ExecuteSql(AdoQry,SqlText,1);
Result := InvBillId;
Finally
If Assigned(AdoQry) then AdoQry.Free;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -