📄 sal_enter_shiporder.pas
字号:
DispInfo('付款条款输入错误!',3);
Edt_PayTermCode.SetFocus;
Abort;
end
else
Edt_SaleTermName.Text :=AdoQry_Tmp.fieldbyname('PayTermName').AsString;
end;
end;
procedure TFrm_Sal_Enter_ShipOrder.Edt_ShipModeCodeKeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
begin
inherited;
If key=120 Then
CommOnHint(Sender,AdoQry_Tmp,'ShipModeName','发货方式名称','ShipModeCode',
'发货方式代号',' ShipMode ');
end;
procedure TFrm_Sal_Enter_ShipOrder.Edt_ShipModeCodeExit(Sender: TObject);
begin
inherited;
If Trim(Edt_ShipModeCode.text)='' then
begin
Edt_ShipModeName.Text:='';
end
else
begin
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.clear;
AdoQry_Tmp.SQL.Text:=' Select * From ShipMode '
+' Where ShipModeCode='''+Trim(Edt_ShipModeCode.text)+''' ';
AdoQry_Tmp.Open;
if AdoQry_Tmp.Eof then
begin
DispInfo('发货方式输入错误!',3);
Edt_ShipModeCode.SetFocus;
Abort;
end
else
Edt_ShipModeName.Text:=AdoQry_Tmp.fieldbyname('ShipModeName').AsString ;
end;
end;
procedure TFrm_Sal_Enter_ShipOrder.Edt_ShipAddresSCodeKeyDown(
Sender: TObject; var Key: Word; Shift: TShiftState);
begin
inherited;
If key=120 Then
CommOnHint(Sender,AdoQry_Tmp,'ShipAddressName','发货地址名称','ShipAddresSCode',
'发货地址代号',' CustomerShipAddress ',' CustomerCode= '''+Edt_CustomerCode.Text+'''');
end;
procedure TFrm_Sal_Enter_ShipOrder.Edt_ShipAddresSCodeExit(
Sender: TObject);
begin
inherited;
if Trim(Edt_CustomerCode.Text) <> '' then
begin
If Trim(Edt_ShipAddresSCode.text)='' then
begin
// DispInfo('发货地址不能为空!',3);
// Edt_ShipAddresSCode.SetFocus;
// Abort;
Edt_ShipAddressName.Text:='';
end
else
begin
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.clear;
AdoQry_Tmp.SQL.Text:=' Select * from CustomerShipAddress '
+' where (CustomerCode='''+Trim(Edt_CustomerCode.text)+''') '
+' And (ShipAddresSCode='''+Trim(Edt_ShipAddresSCode.text)+''')' ;
AdoQry_Tmp.Open;
if AdoQry_Tmp.Eof then
begin
DispInfo('发货地址与客户不匹配!',3);
Edt_ShipAddresSCode.SetFocus;
Abort;
end;
Edt_ShipAddressName.Text:=Lab_ShipAddressName.Caption ;
end;
end;
end;
procedure TFrm_Sal_Enter_ShipOrder.Act_SaveExecute(Sender: TObject);
var
SqlText:String;
I:integer;
InvBillId : integer;
begin
if (CurrentFormStatus='Add') and (CheckAllTypeOrderNoSet(DbConnect,3)) then
Edt_InvBillNo.Text := GetAllTypeOrderNo(DbConnect,3);
IF Trim(Edt_InvBillNo.Text)='' Then
begin
DispInfo('销售发货单号不能为空!',3);
Edt_InvBillNo.SetFocus;
Abort;
end;
IF Trim(Edt_CustomerCode.Text)='' Then
begin
DispInfo('销售客户不能为空!',3);
Edt_CustomerCode.SetFocus;
Abort;
end;
IF Trim(MEdt_CreateDate.Text)='' Then
begin
DispInfo('发货日期不能为空!',3);
MEdt_CreateDate.SetFocus;
Abort;
end;
if not WHClsPeriodCheck(AdoQry_Tmp,Trim(Edt_WhCode.Text),Copy(MEdt_CreateDate.Text,1,7)) then
begin
If MEdt_CreateDate.CanFocus then
MEdt_CreateDate.SetFocus;
Abort;
end;
IF Trim(Edt_TaxRate_Percent.Text)='' Then
begin
DispInfo('销售税率不能为空!',3);
Edt_TaxRate_Percent.SetFocus;
Abort;
end;
IF Trim(Edt_CurrencyCode.Text)='' Then
begin
DispInfo('货币不能为空!',3);
Edt_CurrencyCode.SetFocus;
Abort;
end;
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.clear;
AdoQry_Tmp.SQL.Text:=' Select CurrencyCode,CurrencyName,IsMaster from Currency '
+' where CurrencyCode= '''+Edt_CurrencyCode.Text+''' ';
AdoQry_Tmp.Open;
Edt_CurrencyName.Text := AdoQry_Tmp.fieldbyname('CurrencyName').AsString;
If AdoQry_Tmp.fieldbyname('IsMaster').AsInteger=1 then ExchRate:=1{如果是本位币则不用判断是否有外币汇率资料}
else
begin
ExecuteSql(AdoQry_Tmp,' select * from ExchRate '
+ ' where CurrencyCode= '+QuotedStr(Edt_CurrencyCode.Text)
+ ' and ExchMonth= '+QuotedStr(copy(Medt_CreateDate.Text,1,7)),0);
if AdoQry_tmp.RecordCount=0 then
begin
DispInfo('没有该货币'+Copy(Medt_CreateDate.Text,1,7)+'月的外币汇率!',3);
If Edt_CurrencyCode.CanFocus then Edt_CurrencyCode.SetFocus;
Abort;
end;
ExchRate := AdoQry_Tmp.fieldbyname('ExchRate').AsFloat;
end;
if (CurrentFormStatus='Add') then
if (Edt_InvBillNo.Text<>'') then
begin
SqlText:= 'Select InvBillNo From InvOutBill Where InvBillNo='''+Edt_InvBillNo.Text+'''';
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.clear;
AdoQry_Tmp.SQL.Text:=SqlText;
AdoQry_Tmp.Open;
If not AdoQry_Tmp.Eof then
begin
DispInfo('销售发货单号不可重复!',3);
Edt_InvBillNo.SetFocus;
abort;
end;
end
else
begin
DispInfo('销售发货单号不可为空!',3);
Edt_InvBillNo.SetFocus;
abort;
end;
If AdoQry_Body.RecordCount=0 Then
begin
DispInfo('没有行数据,不能保存!',3);
Abort;
end;
I:=1;
AdoQry_Body.First;
While Not AdoQry_Body.Eof Do
begin
If StrToFloat(FormatFloat('##0.##',AdoQry_Body.fieldbyname('InvBillQty').AsFloat))<=0 Then
begin
DispInfo('第'+IntToStr(I)+'行数据的约定交货量小于等于了0,不能保存!',3);
Abort;
end;
AdoQry_Body.Next;
I:=I+1;
end;
// inherited;
Application.ProcessMessages;
DbConnect.beginTrans;
Try
AdoQry_Body.First;
If CurrentFormStatus='Add' Then
begin
if edt_InvBillNo.Text='' then
abort;
Application.ProcessMessages;
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,RemArk)'
+' Values('
+''''+Trim(Edt_InvBillNo.Text)+''','
+''''+Trim(MEdt_CreateDate.Text)+''','
+QuotedStr(Copy(MEdt_CreateDate.Text,1,7))+','
+''''+Trim(MEdt_CreateDate.Text)+''','
+''''+UserCode+''','
+''''+Trim(Edt_SaleEmployeeCode.Text)+''','
+iifstring(Trim(Edt_DeptCode.Text)='','null',QuotedStr(Trim(Edt_DeptCode.Text)))+','
+''''+Trim(Edt_CustomerCode.Text)+''','
+Quotedstr(Edt_WhCode.Text)+','
+QuotedStr(Edt_WhPositionCode.Text)+','
+''''+Trim(Edt_ShipAddresSCode.Text)+''','
+''''+Trim(Edt_ShipModeCode.Text)+''','
+''''+Trim(Edt_SaleTypeCode.Text)+''','
+QuotedStr(IIFValue(Cmb_BillType.ItemIndex=0,'0205','0206'))+','
+''''+Trim(Edt_CurrencyCode.Text)+''','
+iifString(Trim(Edt_PayTermCode.Text)='','null',quotedstr(Trim(Edt_PayTermCode.Text)))+','
+''''+Trim(Edt_TaxRate_Percent.Text)+''','
+FloatToStr(ExchRate)+','
+''''+Trim(Edt_TotalNoTaxAmount.Text)+''','
+''''+Trim(Edt_TotalTaxAmount.Text)+''','
+FloatToStr(StrToFloat(Edt_TotalNoTaxAmount.Text)*ExchRate)+','
+FloatToStr(StrToFloat(Edt_TotalTaxAmount.Text)*ExchRate)+','
+' 0,'
+''''+Trim(Edt_RemArk1.Text)+''','
+''''+Trim(Edt_RemArk.Text)+''')';
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:=SqlText;
AdoQry_Tmp.ExecSQL;
ExecuteSql(AdoQry_Tmp,'select @@identity as dd ',0);
InvBillId := AdoQry_Tmp.fieldbyname('dd').AsInteger;
// saveShipOrderHistory(dbconnect,Trim(edt_InvBillNo.text),userCode,0);
// SaveSa_SaleOrderHistory(dbconnect,Trim(edt_SloNo.text),userCode,0);
AdoQry_Body.First;
While Not AdoQry_Body.Eof Do
begin
SqlText:='Insert InvOutBillLine '
+' (InvBillId,InvBillLineNo,SloNo,SloLineNo,ItemCode,InvBillQty,InvBillNoTaxPrice,InvBillNoTaxPriceC,'
+' InvBillNoTaxAmount,InvBillNoTaxAmountC,InvBillPrice, InvBillPriceC,'
+' InvBillAmount, InvBillAmountC,DiSCountRate,DiSCountAmount,BillLineRemArk,BatchNo)'
+'Values('
+IntToStr(InvBillId)+','
+''''+AdoQry_Body.fieldbyname('InvBillLineNo').AsString+''','
+''''+AdoQry_Body.fieldbyname('SloNo').AsString+''','
+''''+IntToStr(AdoQry_Body.fieldbyname('SloLineNo').AsInteger)+''','
+''''+AdoQry_Body.fieldbyname('ItemCode').AsString+''','
+''''+AdoQry_Body.fieldbyname('InvBillQty').AsString+''','
+''''+AdoQry_Body.fieldbyname('InvBillNoTaxPrice').AsString+''','
+FloatToStr(ExchRate*AdoQry_Body.fieldbyname('InvBillNoTaxPrice').AsFloat)+','
+''''+FormatFloat('#####0.##',AdoQry_Body.fieldbyname('InvBillNoTaxAmount').AsFloat)+''','
+FormatFloat('#####0.##',ExchRate*AdoQry_Body.fieldbyname('InvBillNoTaxAmount').AsFloat)+','
+''''+FloatToStr(AdoQry_Body.fieldbyname('InvBillPrice').AsFloat)+''','
+FloatToStr(ExchRate*AdoQry_Body.fieldbyname('InvBillPrice').AsFloat)+','
+''''+FormatFloat('#####0.##',AdoQry_Body.fieldbyname('InvBillAmount').AsFloat)+''''+','
+FormatFloat('#####0.##',ExchRate*AdoQry_Body.fieldbyname('InvBillAmount').AsFloat)+','
+''''+AdoQry_Body.fieldbyname('DiSCountRate').AsString+''''+','
+''''+FormatFloat('#####0.##',AdoQry_Body.fieldbyname('DiSCountAmount').AsFloat)+''''+','
+''''+AdoQry_Body.fieldbyname('BillLineRemArk').AsString+''''+','
+''''+AdoQry_Body.fieldbyname('BatchNo').AsString+''''
+')';
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:=SqlText;
AdoQry_Tmp.ExecSQL;
// saveShipOrderLineHistory(dbconnect,Trim(edt_InvBillNo.text),AdoQry_Body.fieldbyname('InvBillLineNo').asinteger,userCode,0);
SqlText:=' Update Sa_SaleOrderLine Set PrepareShipQty=IsNull(PrepareShipQty,0)+'+AdoQry_Body.fieldbyname('InvBillQty').AsString+' '
+' Where SloNo='''+AdoQry_Body.fieldbyname('SloNo').AsString+''' '
+' And SloLineNo='''+IntToStr(AdoQry_Body.fieldbyname('SloLineNo').AsInteger)+'''';
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:=SqlText;
AdoQry_Tmp.ExecSQL;
// SaveSa_SaleOrderLineHistory(dbconnect,Trim(edt_SloNo.text),AdoQry_Body.fieldbyname('SloLineNo').asinteger,userCode,0);
AdoQry_Body.Next;
end;
{ AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.clear;
AdoQry_Tmp.SQL.Text := ' Select SalParamValueN from Sa_SalParam Where SalParamCode=''ShiPassess'' ';
AdoQry_Tmp.Open;
if AdoQry_Tmp.fieldbyname('SalParamValueN').AsFloat = 0 then
begin
updateqty(0);
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.clear;
AdoQry_Tmp.SQL.Text := ' Update InvOutBill Set InvBillWhChck=1,'
+' Wh_EmployeeCode='''+UserCode+''' '
+' Where InvBillNo='''+Edt_InvBillNo.Text+'''';
AdoQry_Tmp.ExecSQL;
end;
}
end;
If CurrentFormStatus='PArtEdit' Then
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -