📄 ar_enter_saleinvoice1.pas
字号:
Else If Pos('Edit',CurrentFormStatus)>0 Then
begin
AnswerStatus:='PArtEdit';
EnableControls:=' MEdt_CreateDate,MEdt_InAccountDate,Edt_CustomerBank,Edt_CustomerBankActNo,Edt_RemArk,';
end;
end;
procedure TFrm_Ar_Enter_SaleInvoice1.Act_DeleteLineExecute(Sender: TObject);
begin
inherited;
{ if (not AdoQry_Body.IsEmpty)and
(DispInfo(' 真的删除当前记录吗? ',2)='y') then
AdoQry_Body.Delete;
If AdoQry_Body.RecordCount>0 Then
begin
BookmArk:=AdoQry_Body.BookmArk;
AdoQry_Body.First;
While Not AdoQry_Body.Eof Do
begin
AdoQry_Body.Edit;
AdoQry_Body.fieldbyname('ShipLineNo').AsInteger:=AdoQry_Body.RecNo;
AdoQry_Body.Post;
AdoQry_Body.Next;
end;
AdoQry_Body.BookmArk:=BookMArk;
end;}
end;
procedure TFrm_Ar_Enter_SaleInvoice1.Act_PreviewExecute(Sender: TObject);
begin
// inherited;
{ if Act_Save.Enabled = True then
begin
DispInfo('没有保存数据,不能预览!',1);
Abort;
end;
If AdoQry_Body.RecordCount=0 Then
begin
DispInfo('没有行数据,不能预览!',1);
Abort;
end;
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_Ar_Enter_SaleInvoice1.Act_PrintExecute(Sender: TObject);
begin
// inherited;
{ if Act_Save.Enabled = True then
begin
DispInfo('没有保存数据,不能打印!',1);
Abort;
end;
If AdoQry_Body.RecordCount=0 Then
begin
DispInfo('没有行数据,不能打印!',1);
Abort;
end;
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_Ar_Enter_SaleInvoice1.Act_NewExecute(Sender: TObject);
begin
{ if Frm_Sal_Enter_ShipOrder_C1<>nil then
Frm_Sal_Enter_ShipOrder_C1:=TFrm_Sal_Enter_ShipOrder_C1.Create(Application);
Frm_Sal_Enter_ShipOrder_C1.SetSysParam(UserCode,ModuleCode,MenuId,LoginDate);
Frm_Sal_Enter_ShipOrder_C1.InitForm(DbConnect,False);}
inherited;
end;
procedure TFrm_Ar_Enter_SaleInvoice1.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
inherited;
Frm_Ar_Enter_SaleInvoice1:=nil;
end;
procedure TFrm_Ar_Enter_SaleInvoice1.SaveData;
var
SqlText:String;
I:integer;
begin
If CurrentFormStatus='Add' Then
begin
if Edt_InvoiceNo.Text='' then
begin
DispInfo('请输入发票号!',1);
edt_Invoiceno.SetFocus;
abort;
end;
sqltext:='select Invoiceno from sa_SaleInvoice where Invoiceno='+quotedstr(Trim(edt_Invoiceno.text));
Executesql(AdoQry_tmp,sqltext,0) ;
if AdoQry_tmp.RecordCount>0 then
begin
DispInfo('发票号不能重复!',1);
edt_Invoiceno.SetFocus;
abort;
end;
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('ShipQty').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
Application.ProcessMessages;
SqlText:='Insert Sa_SaleInvoice '
+' (InvoiceNo,InvoiceType,ExportTradeTypeCode,SaleDeptCode,SaleEmployeeCode,SaleTypeCode, '
+' CreateDate,BillDate,InAccountDate,CreateEmployeeCode,CustomerCode,Bank,'
+' BankActNo,CurrencyCode,ExchangeRate,TaxRate,'
+' SaleTermCode,TotalTaxAmount,TotalTaxAmountC,TotalNoTaxAmount, '
+' TotalNoTaxAmountC,TotalTax,TotalTaxC,CancelAmount,CancelAmountC,editdate,edItEmployeeCode,RemArk)'
+' Values('
+''''+Trim(Edt_InvoiceNo.Text)+''','
+IIFString(Param1='0','0','2')+','
+IIFString(Param1='0','null',IIFString(Trim(Edt_ExportTypeCode.Text)='','null',QuotedStr(Trim(Edt_ExportTypeCode.Text))))+','
+IIfString(Trim(edt_DeptCode.text)='','null',quotedstr(Trim(edt_DeptCode.text)))+','
+IIfString(Trim(edt_SaleEmployeeCode.text)='','null',quotedstr(Trim(edt_SaleEmployeeCode.text)))+','
+IIfString(Trim(edt_SaleTypeCode.text)='','null',quotedstr(Trim(edt_SaleTypeCode.text)))+','
+'GetDate(),'
+''''+Trim(MEdt_CreateDate.Text)+''','
+QuotedStr(Medt_InAccountDate.Text)+','
+''''+Trim(Edt_CreateEmployeeCode.Text)+''','
+''''+Trim(Edt_CustomerCode.Text)+''','
+''''+Trim(Edt_CustomerBank.Text)+''','
+''''+Trim(Edt_CustomerBankActNo.Text)+''','
+''''+Trim(Edt_CurrencyCode.Text)+''','
+''''+Trim(Edt_ExchangeRate.Text)+''','
+Edt_TaxRate.Text+','
+IIfString(Trim(edt_SaletermCode.text)='','null',quotedstr(Trim(edt_SaletermCode.text)))+','
+''''+Trim(Edt_TotalTaxAmount.Text)+''','
+FormatFloat('####0.##',(StrToFloat(Edt_ExchangeRate.Text)*StrToFloat(Edt_TotalTaxAmount.Text)))+','
+Edt_TotalNoTaxAmount.Text+','
+FormatFloat('####0.##',(StrToFloat(Edt_ExchangeRate.Text)*StrToFloat(Edt_TotalNoTaxAmount.Text)))+','
+FormatFloat('####0.##',(StrToFloat(Edt_TotalTaxAmount.Text)-StrToFloat(Edt_TotalNoTaxAmount.Text)))+','
+FormatFloat('####0.##',(StrToFloat(Edt_ExchangeRate.TExt)*(StrToFloat(Edt_TotalTaxAmount.Text)-StrToFloat(Edt_TotalNoTaxAmount.Text) ) ))+','
+'0,'
+'0,'
+quotedstr(GetServerDateTime(dbconnect))+','
+quotedstr(userCode)+','
+''''+Trim(Edt_RemArk.Text)+''')';
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:=SqlText;
AdoQry_Tmp.ExecSQL;
saveSalInvoiceHistory(dbconnect,Trim(Edt_InvoiceNo.Text),userCode,0);
// SaveSa_SaleOrderHistory(dbconnect,Trim(edt_SloNo.text),userCode,0);
Sqltext:='Update customer with(Rowlock)'
+' set InvoiceSumTotal=IsNull(InvoiceSumTotal,0)+'+Edt_TotalTaxAmount.text
+' Where CustomerCode='+QuotedStr(Edt_CustomerCode.text);
ExecuteSql(AdoQry_Tmp,sqltext,1) ;
AdoQry_Body.First;
While Not AdoQry_Body.Eof Do
begin
SqlText:='Insert Sa_SaleInvoiceLine '
+' (InvoiceNo,InvBillId,InvBillLineNo,RemArk) '
+' Values('
+''''+Trim(Edt_InvoiceNo.Text)+''','
+AdoQry_Body.fieldbyname('InvBillId').AsString+','
+''''+AdoQry_Body.fieldbyname('ShipLineNo').AsString+''','
+''' '''
+')';
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:=SqlText;
AdoQry_Tmp.ExecSQL;
SqlText:=' Update InvOutBill Set InvoiceNo='''+Trim(Edt_InvoiceNo.Text)+''' '
+' Where InvBillId='+AdoQry_Body.fieldbyname('InvBillId').AsString;
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text := SqlText;
AdoQry_Tmp.ExecSQL;
saveSalInvoiceLineHistory(dbconnect,Trim(Edt_InvoiceNo.Text),AdoQry_Body.fieldbyname('InvBillId').asInteger,AdoQry_Body.fieldbyname('ShipLineNo').asString,userCode,0);
AdoQry_Body.Next;
end;
end;
If CurrentFormStatus='PArtEdit' Then
begin
saveSalInvoiceHistory(dbconnect,Trim(Edt_InvOiceNo.Text),userCode,1);
SqlText:=' Update Sa_SaleInvoice Set '
+' SaleDeptCode='+quotedstr(Trim(edt_DeptCode.text))+','
+' SaleEmployeeCode='+quotedstr(Trim(edt_SaleEmployeeCode.text))+','
+' SaleTypeCode='+quotedstr(Trim(edt_SaleTypeCode.text))+','
+' CreateEmployeeCode= '''+Edt_CreateEmployeeCode.Text+''','
+' InAccountDate = '+QuotedStr(Medt_InAccountDate.Text)+','
+' CustomerCode= '''+Trim(Edt_CustomerCode.Text)+''','
// +IIFString(Param1='0','','ExportTradeTypeCode='+QuotedStr(Trim(Edt_ExportTypeCode.Text))+',')
+' Bank= '''+Trim(Edt_CustomerBank.Text)+''','
+' BankActNo= '''+Trim(Edt_CustomerBankActNo.Text)+''','
+' CurrencyCode= '''+Trim(Edt_CurrencyCode.Text)+''','
+' ExchangeRate= '''+Trim(Edt_ExchangeRate.Text)+''','
+' SaleTermCode= '''+Trim(Edt_SaleTermCode.Text)+''','
+' RemArk='''+Edt_RemArk.Text+''' '
+' Where InvoiceNo='''+Trim(Edt_InvOiceNo.Text)+'''';
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:=SqlText;
AdoQry_Tmp.ExecSQL;
AdoQry_Body.First;
While Not AdoQry_Body.Eof Do
begin
// saveSalInvoiceLineHistory(dbconnect,AdoQry_Body.fieldbyname('Invoiceno').asstring,AdoQry_Body.fieldbyname('Shipno').asstring,AdoQry_Body.fieldbyname('Shiplineno').asinteger,userCode,1);
{ SqlText:=' UpDate Sa_SaleInvoiceLine '
+' Set ShipNo='''+AdoQry_Body.fieldbyname('ShipNo').AsString+''','
+' ShipLineNo='''+IntToStr(AdoQry_Body.fieldbyname('ShipLineNo').AsInteger)+''','
+' ItemCode='''+AdoQry_Body.fieldbyname('ItemCode').AsString+''','
+' ShipQty='''+AdoQry_Body.fieldbyname('ShipQty').AsString+''','
+' TaxPrice='''+FloatToStr(AdoQry_Body.fieldbyname('TaxPrice').AsFloat)+''','
+' TaxAmount='''+FloatToStr(AdoQry_Body.fieldbyname('TaxAmount').AsFloat)+''','
+' NoTaxPrice='''+FloatToStr(AdoQry_Body.fieldbyname('noTaxPrice').AsFloat)+''','
+' NoTaxAmount='''+FloatToStr(AdoQry_Body.fieldbyname('noTaxAmount').AsFloat)+''','
+' DiSCountRate='''+AdoQry_Body.fieldbyname('DiSCountRate').AsString+''','
+' DiSCountAmount='''+AdoQry_Body.fieldbyname('DiSCountAmount').AsString+''''
+' Where InvoiceNo='''+AdoQry_Body.fieldbyname('InvoiceNo').AsString+'''' ;
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:=SqlText;
AdoQry_Tmp.ExecSQL;
} AdoQry_Body.Next;
end;
end;
DbConnect.CommitTrans;
Act_Save.Enabled:=False;
DispInfo('数据保存成功!',3);
Except
on e:exception do
begin
DbConnect.RollBackTrans;
recOrderror(self,AdoQry_tmp,e.message);
// Edt_ShipNo.Text:='';
DispInfo('保存数据失败,请重试!',1);
Abort;
end;
end;
end;
procedure TFrm_Ar_Enter_SaleInvoice1.SaveHeadData;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -