unit u_ch_invoice_add_jk; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, BusinessSkinForm, StdCtrls, wwdblook, RxLookup, bsSkinCtrls, DB, ADODB; type Tfrm_ch_invoice_add_jk = class(TForm) bsBusinessSkinForm1: TbsBusinessSkinForm; Label48: TLabel; wwDBLookupCombo6: TwwDBLookupCombo; Label63: TLabel; RxDBLookupCombo3: TRxDBLookupCombo; Label1: TLabel; Edit1: TEdit; bsSkinCheckRadioBox7: TbsSkinCheckRadioBox; bsSkinCheckRadioBox8: TbsSkinCheckRadioBox; bsSkinCheckRadioBox1: TbsSkinCheckRadioBox; bsSkinButton1: TbsSkinButton; bsSkinButton2: TbsSkinButton; p_invoice_no: TADOStoredProc; Edit2: TEdit; Label2: TLabel; RxDBLookupCombo1: TRxDBLookupCombo; bsSkinCheckRadioBox2: TbsSkinCheckRadioBox; bsSkinCheckRadioBox3: TbsSkinCheckRadioBox; edt1: TEdit; procedure bsSkinButton1Click(Sender: TObject); procedure bsSkinButton2Click(Sender: TObject); procedure FormShow(Sender: TObject); procedure Edit1KeyPress(Sender: TObject; var Key: Char); private { Private declarations } public BsNO:String; { Public declarations } end; var frm_ch_invoice_add_jk: Tfrm_ch_invoice_add_jk; implementation uses u_data_share, u_ch_invoice_jk, u_main, my_sys_function; {$R *.dfm} procedure Tfrm_ch_invoice_add_jk.bsSkinButton1Click(Sender: TObject); var afield : variant; i: Integer; aQuery,aAdoQuery:TAdoQuery; str_Bank,str_AccountNo,OldNo:string; AmtRmb,UsdRmb:double; begin if trim(Edit1.Text)='' then begin //showmessage('发票号码不能为空!!'); //exit; end; if bsSkinCheckRadioBox7.Checked or bsSkinCheckRadioBox8.Checked then begin if trim(wwDBLookupCombo6.Text)='' then begin showmessage('发票币别不能为空!!'); exit; end; { if RxDBLookupCombo3.DisplayValue='' then begin showmessage('客户名称不能为空!!'); exit; end; } end; if bsSkinCheckRadioBox7.Checked then begin try modify_all:=true; frm_ch_invoice_jk.t_ch_invoice.Insert; frm_ch_invoice_jk.t_ch_invoice['发票类别']:='自由发票'; frm_ch_invoice_jk.t_ch_invoice['发票号码']:=trim(Edit1.Text); frm_ch_invoice_jk.t_ch_invoice['币别']:=wwDBLookupCombo6.Text; if RxDBLookupCombo1.DisplayValues[0]<>'' then begin frm_ch_invoice_jk.t_ch_invoice['分部名称']:=RxDBLookupCombo1.DisplayValues[0]; if frm_data_share.t_code_subcomp.locate('分部名称',RxDBLookupCombo1.DisplayValues[0],[]) then begin frm_ch_invoice_jk.t_ch_invoice['工商登记号']:=frm_data_share.t_code_subcomp.fieldbyname('工商登记号').AsString; frm_ch_invoice_jk.t_ch_invoice['税务登记号']:=frm_data_share.t_code_subcomp.fieldbyname('税务登记号').AsString; end; if frm_ch_invoice_jk.t_sys_bank.Locate('币别;分部名称',vararrayof([frm_ch_invoice_jk.t_ch_invoice['币别'],subcomp]),[]) then begin frm_ch_invoice_jk.t_ch_invoice['开户银行']:=frm_ch_invoice_jk.t_sys_bank.fieldbyname('银行名称').asstring; frm_ch_invoice_jk.t_ch_invoice['银行账号']:=frm_ch_invoice_jk.t_sys_bank.fieldbyname('银行账号').asstring; end else begin if frm_ch_invoice_jk.t_sys_bank.Locate('币别',frm_ch_invoice_jk.t_ch_invoice['币别'],[]) then begin frm_ch_invoice_jk.t_ch_invoice['开户银行']:=frm_ch_invoice_jk.t_sys_bank.fieldbyname('银行名称').asstring; frm_ch_invoice_jk.t_ch_invoice['银行账号']:=frm_ch_invoice_jk.t_sys_bank.fieldbyname('银行账号').asstring; end; end; end else begin if frm_ch_invoice_jk.t_sys_bank.Locate('币别',frm_ch_invoice_jk.t_ch_invoice['币别'],[]) then begin frm_ch_invoice_jk.t_ch_invoice['开户银行']:=frm_ch_invoice_jk.t_sys_bank.fieldbyname('银行名称').asstring; frm_ch_invoice_jk.t_ch_invoice['银行账号']:=frm_ch_invoice_jk.t_sys_bank.fieldbyname('银行账号').asstring; end; end; if RxDBLookupCombo3.DisplayValues[1]<>'' then frm_ch_invoice_jk.t_ch_invoice['客户名称']:=RxDBLookupCombo3.DisplayValues[1]; if not frm_data_share.t_crm_client_all.IsEmpty then if RxDBLookupCombo3.DisplayValues[1]<>'' then if frm_data_share.t_crm_client_all.locate('客户简称',RxDBLookupCombo3.DisplayValues[1],[]) then begin if trim(frm_data_share.t_crm_client_all.fieldbyname('发票抬头').asstring)<>''then frm_ch_invoice_jk.t_ch_invoice['发票抬头']:=frm_data_share.t_crm_client_all.fieldbyname('发票抬头').asstring; end; frm_ch_invoice_jk.RxDBLookupCombo2.Value:=''; frm_ch_invoice_jk.t_ch_invoice['发票类型']:='增值税普票'; frm_ch_invoice_jk.t_ch_invoice['推送方式']:='0'; frm_ch_invoice_jk.edt_from.text:=edt1.text; if frm_ch_invoice_jk.t_ch_invoice['币别']='USD' then begin frm_ch_invoice_jk.t_ch_invoice['费用列表']:='代理海运费';//get_parameters_value(7,'代理海运费') frm_ch_invoice_jk.wwDBLookupCombo6.Text:='USD'; end else frm_ch_invoice_jk.t_ch_invoice['费用列表']:=get_parameters_value(147,'代理运杂费'); frm_ch_invoice_jk.t_ch_invoice.Post; InsertUpdateInvoice_item(1,1,frm_ch_invoice_jk.t_ch_invoice.fieldbyname('in_id').AsInteger,frm_ch_invoice_jk.t_ch_invoice.fieldbyname('申请编号').asstring,frm_ch_invoice_jk.t_ch_invoice.fieldbyname('费用列表').asstring,frm_ch_invoice_jk.t_ch_invoice.fieldbyname('金额列表').asstring,0); modify_all:=false; except if frm_ch_invoice_jk.t_ch_invoice.State=dsinsert then frm_ch_invoice_jk.t_ch_invoice.cancel; modify_all:=true; showmessage('发票添加失败!!'); exit; end; frm_ch_invoice_jk.bsSkinTabSheet2.show; close; exit; end; if bsSkinCheckRadioBox8.Checked then begin try modify_all:=true; afield := vararraycreate([0,frm_ch_invoice_jk.t_ch_invoice.fieldcount-1],varvariant); for i := 0 to (frm_ch_invoice_jk.t_ch_invoice.fieldcount-1) do begin if frm_ch_invoice_jk.t_ch_invoice.fields[i].FieldName='开户银行' then str_Bank:=frm_ch_invoice_jk.t_ch_invoice.fields[i].value; if frm_ch_invoice_jk.t_ch_invoice.fields[i].FieldName='银行账号' then str_AccountNo:=frm_ch_invoice_jk.t_ch_invoice.fields[i].value; afield[i] :=frm_ch_invoice_jk.t_ch_invoice.fields[i].value; end; frm_ch_invoice_jk.t_ch_invoice.append; for i := 0 to (frm_ch_invoice_jk.t_ch_invoice.fieldcount-1) do begin if (frm_ch_invoice_jk.t_ch_invoice.fields[i].FieldName<>'IN_ID') and (Trim(frm_ch_invoice_jk.t_ch_invoice.fields[i].FieldName)<>'费用选择列表') then frm_ch_invoice_jk.t_ch_invoice.fields[i].value := afield[i] ; end; frm_ch_invoice_jk.t_ch_invoice['发票类别']:='自由发票'; frm_ch_invoice_jk.t_ch_invoice['发票号码']:=trim(Edit1.Text); frm_ch_invoice_jk.t_ch_invoice['申请编号']:=''; frm_ch_invoice_jk.t_ch_invoice['币别']:=wwDBLookupCombo6.Text; frm_ch_invoice_jk.t_ch_invoice['推送方式']:='0'; if frm_ch_invoice_jk.t_sys_bank.fieldbyname('银行账号').asstring='' then begin if frm_ch_invoice_jk.t_sys_bank.Locate('币别',frm_ch_invoice_jk.t_ch_invoice['币别'],[]) then begin frm_ch_invoice_jk.t_ch_invoice['开户银行']:=frm_ch_invoice_jk.t_sys_bank.fieldbyname('银行名称').asstring; frm_ch_invoice_jk.t_ch_invoice['银行账号']:=frm_ch_invoice_jk.t_sys_bank.fieldbyname('银行账号').asstring; end; end else begin end; frm_ch_invoice_jk.t_ch_invoice['是否收费']:=0; if Application.MessageBox('是否复制金额明细?','提示',MB_YESNO+ MB_ICONINFORMATION)=IDYES then begin end else begin frm_ch_invoice_jk.t_ch_invoice['费用列表']:=''; frm_ch_invoice_jk.t_ch_invoice['金额列表']:=''; frm_ch_invoice_jk.t_ch_invoice['备注']:=''; frm_ch_invoice_jk.t_ch_invoice['实际金额']:=0; frm_ch_invoice_jk.t_ch_invoice['合计金额']:=0; frm_ch_invoice_jk.t_ch_invoice['金额大写']:=''; end; if RxDBLookupCombo1.DisplayValues[0]<>'' then begin frm_ch_invoice_jk.t_ch_invoice['分部名称']:=RxDBLookupCombo1.DisplayValues[0]; if frm_data_share.t_code_subcomp.locate('分部名称',RxDBLookupCombo1.DisplayValues[0],[]) then begin frm_ch_invoice_jk.t_ch_invoice['工商登记号']:=frm_data_share.t_code_subcomp.fieldbyname('工商登记号').AsString; frm_ch_invoice_jk.t_ch_invoice['税务登记号']:=frm_data_share.t_code_subcomp.fieldbyname('税务登记号').AsString; end; if frm_ch_invoice_jk.t_sys_bank.Locate('币别;分部名称',vararrayof([frm_ch_invoice_jk.t_ch_invoice['币别'],subcomp]),[]) then begin frm_ch_invoice_jk.t_ch_invoice['开户银行']:=frm_ch_invoice_jk.t_sys_bank.fieldbyname('银行名称').asstring; frm_ch_invoice_jk.t_ch_invoice['银行账号']:=frm_ch_invoice_jk.t_sys_bank.fieldbyname('银行账号').asstring; end else begin if frm_ch_invoice_jk.t_sys_bank.Locate('币别',frm_ch_invoice_jk.t_ch_invoice['币别'],[]) then begin frm_ch_invoice_jk.t_ch_invoice['开户银行']:=frm_ch_invoice_jk.t_sys_bank.fieldbyname('银行名称').asstring; frm_ch_invoice_jk.t_ch_invoice['银行账号']:=frm_ch_invoice_jk.t_sys_bank.fieldbyname('银行账号').asstring; end; end; end; if RxDBLookupCombo3.DisplayValues[1]<>'' then frm_ch_invoice_jk.t_ch_invoice['客户名称']:=RxDBLookupCombo3.DisplayValues[1]; if not frm_data_share.t_crm_client_all.IsEmpty then if RxDBLookupCombo3.DisplayValues[1]<>'' then if frm_data_share.t_crm_client_all.locate('客户简称',RxDBLookupCombo3.DisplayValues[1],[]) then begin if trim(frm_data_share.t_crm_client_all.fieldbyname('发票抬头').asstring)<>''then frm_ch_invoice_jk.t_ch_invoice['发票抬头']:=frm_data_share.t_crm_client_all.fieldbyname('发票抬头').asstring; end; // frm_ch_invoice.t_ch_invoice['开户银行']:=str_Bank; // frm_ch_invoice.t_ch_invoice['银行账号']:=str_AccountNo; frm_ch_invoice_jk.RxDBLookupCombo2.Value:=''; frm_ch_invoice_jk.t_ch_invoice['制单人']:=employee; frm_ch_invoice_jk.t_ch_invoice['开票日期']:=date; frm_ch_invoice_jk.t_ch_invoice['是否打印']:=0; frm_ch_invoice_jk.t_ch_invoice['是否废除']:=0; frm_ch_invoice_jk.t_ch_invoice['废除原因']:=''; frm_ch_invoice_jk.t_ch_invoice['废除人']:=''; frm_ch_invoice_jk.t_ch_invoice['废除日期']:=null; frm_ch_invoice_jk.t_ch_invoice['申请人']:=''; frm_ch_invoice_jk.t_ch_invoice['申请日期']:=null; frm_ch_invoice_jk.t_ch_invoice['费用列表']:='代理运杂费'; frm_ch_invoice_jk.t_ch_invoice.post; InsertUpdateInvoice_item(1,1,frm_ch_invoice_jk.t_ch_invoice.fieldbyname('in_id').AsInteger,frm_ch_invoice_jk.t_ch_invoice.fieldbyname('申请编号').asstring,frm_ch_invoice_jk.t_ch_invoice.fieldbyname('费用列表').asstring,frm_ch_invoice_jk.t_ch_invoice.fieldbyname('金额列表').asstring,0); modify_all:=false; except if frm_ch_invoice_jk.t_ch_invoice.State=dsinsert then frm_ch_invoice_jk.t_ch_invoice.cancel; modify_all:=true; showmessage('发票添加失败!!'); exit; end; frm_ch_invoice_jk.bsSkinTabSheet2.show; close; exit; end; if bsSkinCheckRadioBox3.Checked then begin try modify_all:=true; afield := vararraycreate([0,frm_ch_invoice_jk.t_ch_invoice.fieldcount-1],varvariant); OldNo:=frm_ch_invoice_jk.t_ch_invoice.fieldbyname('申请编号').AsString; AmtRmb:=frm_ch_invoice_jk.t_ch_invoice.FieldByName('人民币金额').AsFloat; UsdRmb:=frm_ch_invoice_jk.t_ch_invoice.FieldByName('美元金额').AsFloat; for i := 0 to (frm_ch_invoice_jk.t_ch_invoice.fieldcount-1) do begin if frm_ch_invoice_jk.t_ch_invoice.fields[i].FieldName='开户银行' then str_Bank:=frm_ch_invoice_jk.t_ch_invoice.fields[i].value; if frm_ch_invoice_jk.t_ch_invoice.fields[i].FieldName='银行账号' then str_AccountNo:=frm_ch_invoice_jk.t_ch_invoice.fields[i].value; afield[i] :=frm_ch_invoice_jk.t_ch_invoice.fields[i].value; end; frm_ch_invoice_jk.t_ch_invoice.append; for i := 0 to (frm_ch_invoice_jk.t_ch_invoice.fieldcount-1) do begin if (frm_ch_invoice_jk.t_ch_invoice.fields[i].FieldName<>'IN_ID') and (Trim(frm_ch_invoice_jk.t_ch_invoice.fields[i].FieldName)<>'费用选择列表') then frm_ch_invoice_jk.t_ch_invoice.fields[i].value := afield[i] ; end; frm_ch_invoice_jk.t_ch_invoice['发票类别']:='自由发票'; frm_ch_invoice_jk.t_ch_invoice['发票号码']:=trim(Edit1.Text); frm_ch_invoice_jk.t_ch_invoice['申请编号']:=''; frm_ch_invoice_jk.t_ch_invoice['币别']:='USD'; frm_ch_invoice_jk.t_ch_invoice['实际币别']:='USD'; frm_ch_invoice_jk.t_ch_invoice['费用列表']:='代理海运费'; frm_ch_invoice_jk.t_ch_invoice['金额列表']:=frm_ch_invoice_jk.t_ch_invoice.FieldByName('美元金额').AsFloat; frm_ch_invoice_jk.t_ch_invoice['合计金额']:=frm_ch_invoice_jk.t_ch_invoice.FieldByName('美元金额').AsFloat; frm_ch_invoice_jk.t_ch_invoice['实际金额']:=frm_ch_invoice_jk.t_ch_invoice.FieldByName('美元金额').AsFloat; frm_ch_invoice_jk.t_ch_invoice['美元金额']:=frm_ch_invoice_jk.t_ch_invoice.FieldByName('美元金额').AsFloat; frm_ch_invoice_jk.t_ch_invoice['是否收费']:=0; frm_ch_invoice_jk.t_ch_invoice['人民币金额']:=0; frm_ch_invoice_jk.edt_from.text:=edt1.Text ; frm_ch_invoice_jk.wwDBLookupCombo6.Text:='USD'; frm_ch_invoice_jk.t_ch_invoice['备注']:='USD'+frm_ch_invoice_jk.t_ch_invoice.FieldByName('美元金额').AsString+'*'+floattostr(GetUsdExrate(frm_ch_invoice_jk.t_ch_invoice.FieldByName('开票日期').AsString))+'此票限付美元'+edt1.Text; frm_ch_invoice_jk.t_ch_invoice['制单人']:=employee; frm_ch_invoice_jk.t_ch_invoice['开票日期']:=date; frm_ch_invoice_jk.t_ch_invoice['是否打印']:=0; frm_ch_invoice_jk.t_ch_invoice['是否废除']:=0; frm_ch_invoice_jk.t_ch_invoice['废除原因']:=''; frm_ch_invoice_jk.t_ch_invoice['废除人']:=''; frm_ch_invoice_jk.t_ch_invoice['废除日期']:=null; frm_ch_invoice_jk.t_ch_invoice['申请人']:=''; frm_ch_invoice_jk.t_ch_invoice['申请日期']:=null; frm_ch_invoice_jk.t_ch_invoice.post; InsertUpdateInvoice_item(1,1,frm_ch_invoice_jk.t_ch_invoice.fieldbyname('in_id').AsInteger,frm_ch_invoice_jk.t_ch_invoice.fieldbyname('申请编号').asstring,frm_ch_invoice_jk.t_ch_invoice.fieldbyname('费用列表').asstring,frm_ch_invoice_jk.t_ch_invoice.fieldbyname('金额列表').asstring,0); aAdoQuery:=CreateAdoQuery; with aAdoQuery do try Close;sql.Clear; sql.Add('Update t_ch_fee_do set 工作编号=:bsno1'); sql.Add('From t_ch_fee_do'); sql.Add('where 工作编号=:bsno and 币别=''USD'''); Parameters.ParamByName('bsno').Value:=OldNo; Parameters.ParamByName('bsno1').Value:=frm_ch_invoice_jk.t_ch_invoice.FieldByName('申请编号').Value; ExecSQL; finally free; end; frm_ch_invoice_jk.t_ch_invoice.Edit; frm_ch_invoice_jk.t_ch_invoice.post; aAdoQuery:=CreateAdoQuery; with aAdoQuery do try Close;sql.Clear; sql.Add('Update t_ch_invoice'); sql.Add('set 币别=''RMB'',费用列表=''代理运杂费'',金额列表=:金额列表,合计金额=:合计金额,实际金额=:实际金额,人民币金额=:人民币金额,美元金额=0'); sql.Add('where 申请编号=:bsno'); Parameters.ParamByName('bsno').Value:=OldNo; Parameters.ParamByName('金额列表').Value:=AmtRmb; Parameters.ParamByName('合计金额').Value:=AmtRmb; Parameters.ParamByName('实际金额').Value:=AmtRmb; Parameters.ParamByName('人民币金额').Value:=AmtRmb; ExecSQL; finally free; end; frm_ch_invoice_jk.t_ch_invoice.Refresh; modify_all:=false; except if frm_ch_invoice_jk.t_ch_invoice.State=dsinsert then frm_ch_invoice_jk.t_ch_invoice.cancel; modify_all:=true; showmessage('发票添加失败!!'); exit; end; frm_ch_invoice_jk.bsSkinTabSheet2.show; close; exit; end; { if bsSkinCheckRadioBox2.Checked then begin try modify_all:=true; frm_ch_invoice.t_ch_invoice.Insert; frm_ch_invoice.t_ch_invoice['发票类别']:='明细发票'; frm_ch_invoice.t_ch_invoice['发票号码']:=trim(Edit1.Text); frm_ch_invoice.t_ch_invoice['币别']:=wwDBLookupCombo6.Text; if frm_ch_invoice.t_sys_bank.Locate('币别',frm_ch_invoice.t_ch_invoice['币别'],[]) then begin frm_ch_invoice.t_ch_invoice['开户银行']:=frm_ch_invoice.t_sys_bank.fieldbyname('银行名称').asstring; frm_ch_invoice.t_ch_invoice['银行账号']:=frm_ch_invoice.t_sys_bank.fieldbyname('银行账号').asstring; end; if RxDBLookupCombo1.DisplayValues[0]<>'' then begin frm_ch_invoice.t_ch_invoice['分部名称']:=RxDBLookupCombo1.DisplayValues[0]; if frm_data_share.t_code_subcomp.locate('分部名称',RxDBLookupCombo1.DisplayValues[0],[]) then begin frm_ch_invoice.t_ch_invoice['工商登记号']:=frm_data_share.t_code_subcomp.fieldbyname('工商登记号').value; frm_ch_invoice.t_ch_invoice['税务登记号']:=frm_data_share.t_code_subcomp.fieldbyname('税务登记号').value; end; end; frm_ch_invoice.t_ch_invoice['客户名称']:=RxDBLookupCombo3.DisplayValues[1]; if not frm_data_share.t_crm_client_all.IsEmpty then if frm_data_share.t_crm_client_all.locate('客户简称',RxDBLookupCombo3.DisplayValues[1],[]) then begin if trim(frm_data_share.t_crm_client_all.fieldbyname('发票抬头').asstring)<>''then frm_ch_invoice.t_ch_invoice['发票抬头']:=frm_data_share.t_crm_client_all.fieldbyname('发票抬头').asstring; end; frm_ch_invoice.t_ch_invoice['申请状态']:='审核通过'; // frm_ch_invoice.t_ch_invoice['申请编号']:=frm_ch_invoice.t_ch_invoice_shen['申请编号']; frm_ch_invoice.t_ch_invoice.post; modify_all:=false; except if frm_ch_invoice.t_ch_invoice.State=dsinsert then frm_ch_invoice.t_ch_invoice.cancel; modify_all:=true; showmessage('开出发票失败!!'); end; frm_ch_invoice.bsSkinTabSheet2.show; Close; exit; end; } if bsSkinCheckRadioBox1.Checked then begin frm_main.db.BeginTrans; try modify_all:=true; frm_ch_invoice_jk.t_ch_invoice.Insert; frm_ch_invoice_jk.t_ch_invoice['发票类别']:='申请发票'; frm_ch_invoice_jk.t_ch_invoice['发票号码']:=trim(Edit1.Text); frm_ch_invoice_jk.t_ch_invoice['币别']:=wwDBLookupCombo6.Text; frm_ch_invoice_jk.t_ch_invoice['客户名称']:=edit2.text; if RxDBLookupCombo1.DisplayValues[0]<>'' then begin frm_ch_invoice_jk.t_ch_invoice['分部名称']:=RxDBLookupCombo1.DisplayValues[0]; if frm_data_share.t_code_subcomp.locate('分部名称',RxDBLookupCombo1.DisplayValues[0],[]) then begin frm_ch_invoice_jk.t_ch_invoice['工商登记号']:=frm_data_share.t_code_subcomp.fieldbyname('工商登记号').AsString; frm_ch_invoice_jk.t_ch_invoice['税务登记号']:=frm_data_share.t_code_subcomp.fieldbyname('税务登记号').AsString; end; if frm_ch_invoice_jk.t_sys_bank.Locate('币别;分部名称',vararrayof([frm_ch_invoice_jk.t_ch_invoice['币别'],subcomp]),[]) then begin frm_ch_invoice_jk.t_ch_invoice['开户银行']:=frm_ch_invoice_jk.t_sys_bank.fieldbyname('银行名称').asstring; frm_ch_invoice_jk.t_ch_invoice['银行账号']:=frm_ch_invoice_jk.t_sys_bank.fieldbyname('银行账号').asstring; end else begin if frm_ch_invoice_jk.t_sys_bank.Locate('币别',frm_ch_invoice_jk.t_ch_invoice['币别'],[]) then begin frm_ch_invoice_jk.t_ch_invoice['开户银行']:=frm_ch_invoice_jk.t_sys_bank.fieldbyname('银行名称').asstring; frm_ch_invoice_jk.t_ch_invoice['银行账号']:=frm_ch_invoice_jk.t_sys_bank.fieldbyname('银行账号').asstring; end; end; end else begin if frm_ch_invoice_jk.t_sys_bank.Locate('币别',frm_ch_invoice_jk.t_ch_invoice['币别'],[]) then begin frm_ch_invoice_jk.t_ch_invoice['开户银行']:=frm_ch_invoice_jk.t_sys_bank.fieldbyname('银行名称').asstring; frm_ch_invoice_jk.t_ch_invoice['银行账号']:=frm_ch_invoice_jk.t_sys_bank.fieldbyname('银行账号').asstring; end; end; frm_ch_invoice_jk.t_ch_invoice['申请编号']:=frm_ch_invoice_jk.t_ch_invoice_shen['申请编号']; frm_ch_invoice_jk.t_ch_invoice['对帐编号']:=frm_ch_invoice_jk.t_ch_invoice_shen['对帐编号']; frm_ch_invoice_jk.t_ch_invoice['发票抬头']:=frm_ch_invoice_jk.t_ch_invoice_shen['发票抬头']; frm_ch_invoice_jk.t_ch_invoice['船名航次']:=frm_ch_invoice_jk.t_ch_invoice_shen['船名航次']; frm_ch_invoice_jk.t_ch_invoice['提单号']:=frm_ch_invoice_jk.t_ch_invoice_shen['提单号']; frm_ch_invoice_jk.t_ch_invoice['委托编号']:=frm_ch_invoice_jk.t_ch_invoice_shen['委托编号']; frm_ch_invoice_jk.t_ch_invoice['开船日期']:=frm_ch_invoice_jk.t_ch_invoice_shen['开船日期']; frm_ch_invoice_jk.t_ch_invoice['启运港']:=frm_ch_invoice_jk.t_ch_invoice_shen['启运港']; frm_ch_invoice_jk.t_ch_invoice['卸货港']:=frm_ch_invoice_jk.t_ch_invoice_shen['卸货港']; frm_ch_invoice_jk.t_ch_invoice['目的港']:=frm_ch_invoice_jk.t_ch_invoice_shen['目的港']; frm_ch_invoice_jk.t_ch_invoice['费用列表']:=frm_ch_invoice_jk.t_ch_invoice_shen['费用列表']; frm_ch_invoice_jk.t_ch_invoice['金额列表']:=frm_ch_invoice_jk.t_ch_invoice_shen['金额列表']; frm_ch_invoice_jk.t_ch_invoice['备注']:=frm_ch_invoice_jk.t_ch_invoice_shen['备注']; frm_ch_invoice_jk.t_ch_invoice['合计金额']:=frm_ch_invoice_jk.t_ch_invoice_shen['申请金额']; frm_ch_invoice_jk.t_ch_invoice['实际金额']:=frm_ch_invoice_jk.t_ch_invoice_shen['实际金额']; frm_ch_invoice_jk.t_ch_invoice['虚开金额']:=frm_ch_invoice_jk.t_ch_invoice_shen['虚开金额']; frm_ch_invoice_jk.t_ch_invoice['币别']:=frm_ch_invoice_jk.t_ch_invoice_shen['币别']; frm_ch_invoice_jk.t_ch_invoice['申请人']:=frm_ch_invoice_jk.t_ch_invoice_shen['申请人']; frm_ch_invoice_jk.t_ch_invoice['申请日期']:=frm_ch_invoice_jk.t_ch_invoice_shen['申请日期']; frm_ch_invoice_jk.t_ch_invoice.post; InsertUpdateInvoice_item(1,1,frm_ch_invoice_jk.t_ch_invoice.fieldbyname('in_id').AsInteger,frm_ch_invoice_jk.t_ch_invoice.fieldbyname('申请编号').asstring,frm_ch_invoice_jk.t_ch_invoice.fieldbyname('费用列表').asstring,frm_ch_invoice_jk.t_ch_invoice.fieldbyname('金额列表').asstring,0); aQuery:=CreateAdoQuery; try with aQuery do begin close;sql.clear; sql.Add('select * from t_ch_fee_do where 工作编号='''+frm_ch_invoice_jk.t_ch_invoice_shen['申请编号']+''''); open; if not IsEmpty then begin first; while not eof do begin edit; fieldbyname('类型').Asstring:='1'; post; next; end; end; end; finally FreeAndNil(aQuery); end; frm_ch_invoice_jk.t_ch_invoice_shen.Edit; frm_ch_invoice_jk.t_ch_invoice_shen['申请状态']:='开出发票'; frm_ch_invoice_jk.t_ch_invoice_shen['开出人']:=employee; frm_ch_invoice_jk.t_ch_invoice_shen['开出日期']:=now; frm_ch_invoice_jk.t_ch_invoice_shen['发票号码']:=trim(Edit1.Text); frm_ch_invoice_jk.t_ch_invoice_shen.post; modify_all:=false; frm_main.db.CommitTrans; finally if frm_main.db.InTransaction then begin if frm_ch_invoice_jk.t_ch_invoice.State=dsinsert then frm_ch_invoice_jk.t_ch_invoice.cancel; modify_all:=true; showmessage('开出发票失败!!'); end; { if modify_all then Send_invocie_check_check('申请发票开出,申请编号:'+frm_ch_invoice.t_ch_invoice_shen.fieldbyname('申请编号').asstring +',客户:'+frm_ch_invoice.t_ch_invoice_shen.fieldbyname('客户名称').asstring,frm_ch_invoice.t_ch_invoice_shen.fieldbyname('申请人').asstring,'25'); } end; frm_ch_invoice_jk.bsSkinTabSheet2.show; if bsSkinCheckRadioBox2.Checked then frm_ch_invoice_jk.bsSkinButton35.OnClick(nil); close; exit; end; end; procedure Tfrm_ch_invoice_add_jk.bsSkinButton2Click(Sender: TObject); begin close; end; procedure Tfrm_ch_invoice_add_jk.FormShow(Sender: TObject); var i:integer; aQuery:TAdoQuery; begin if not if_reg(417) then bsSkinCheckRadioBox2.Visible:=false; aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.Clear; SQL.Add('select 发票号码 from t_ch_invoice where IN_ID=(select max(IN_ID) from t_ch_invoice where 分部名称='''+subComp+''')'); Open; if IsEmpty then begin Close;SQL.Clear; SQL.Add('select 发票号码 from t_ch_invoice where IN_ID=(select max(IN_ID) from t_ch_invoice)'); Open; end; try i:=strtoint(aQuery.fieldbyname('发票号码').AsString); Edit1.Text:=inttostr(i+1); except ; end; end; finally FreeAndNil(aQuery); end; RxDBLookupCombo1.DisplayValue:=subComp; { 'select @inv_no=()' p_invoice_no.ExecProc; try i:=strtoint(p_invoice_no.Parameters[1].value); Edit1.Text:=inttostr(i+1); except ; end; } end; procedure Tfrm_ch_invoice_add_jk.Edit1KeyPress(Sender: TObject; var Key: Char); begin if key=#13 then begin key:=#0; frm_ch_invoice_jk.bsSkinButton1Click(Sender); end; end; end.