unit u_ch_invoice_shen; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, bsSkinCtrls, dxExEdtr, dxCntner, dxTL, dxDBCtrl, dxDBGrid, DB, ADODB, dxDBTLCl, dxGrClms, StdCtrls, DBCtrls, Mask, wwdblook, ComCtrls, bsSkinTabs, bsdbctrls, RxLookup, u_ch_add_do, u_ch_delete_do, wwdbdatetimepicker, Menus, XPMenu, wwdbedit, Wwdotdot, Wwdbcomb, kbmMemTable; type Tfrm_ch_invoice_shen = class(TForm) bsSkinPanel2: TbsSkinPanel; bsSkinButton1: TbsSkinButton; bsSkinButton2: TbsSkinButton; bsSkinButton4: TbsSkinButton; bsSkinButton3: TbsSkinButton; bsSkinButton5: TbsSkinButton; bsSkinButton8: TbsSkinButton; bsSkinButton9: TbsSkinButton; bsSkinButton10: TbsSkinButton; bsSkinButton11: TbsSkinButton; bsSkinNotebook1: TbsSkinNotebook; dxDBGrid1: TdxDBGrid; bsSkinButton6: TbsSkinButton; t_ch_invoice_shen: TADOQuery; t_ch_invoice_shen1: TDataSource; dxDBGrid1Column1: TdxDBGridMaskColumn; dxDBGrid1Column2: TdxDBGridMaskColumn; dxDBGrid1Column3: TdxDBGridMaskColumn; dxDBGrid1Column4: TdxDBGridMaskColumn; dxDBGrid1Column5: TdxDBGridMaskColumn; dxDBGrid1Column6: TdxDBGridMaskColumn; dxDBGrid1Column7: TdxDBGridMaskColumn; dxDBGrid1Column8: TdxDBGridDateColumn; dxDBGrid1Column9: TdxDBGridMaskColumn; dxDBGrid1Column10: TdxDBGridMaskColumn; dxDBGrid1Column11: TdxDBGridMaskColumn; dxDBGrid1Column12: TdxDBGridMaskColumn; dxDBGrid1Column13: TdxDBGridMaskColumn; dxDBGrid1Column18: TdxDBGridMaskColumn; dxDBGrid1Column19: TdxDBGridMaskColumn; dxDBGrid1Column20: TdxDBGridDateColumn; dxDBGrid1Column21: TdxDBGridMaskColumn; dxDBGrid1Column22: TdxDBGridDateColumn; dxDBGrid1Column23: TdxDBGridMaskColumn; dxDBGrid1Column24: TdxDBGridDateColumn; dxDBGrid1Column14: TdxDBGridColumn; dxDBGrid1Column15: TdxDBGridColumn; dxDBGrid1Column16: TdxDBGridColumn; dxDBGrid1Column17: TdxDBGridColumn; bsSkinPanel1: TbsSkinPanel; bsSkinPanel3: TbsSkinPanel; Label25: TLabel; DBEdit14: TDBEdit; Label17: TLabel; DBEdit1: TDBEdit; Label18: TLabel; DBEdit5: TDBEdit; bsSkinPageControl2: TbsSkinPageControl; Label1: TLabel; Label4: TLabel; DBEdit4: TDBEdit; Label7: TLabel; wwDBLookupCombo1: TwwDBLookupCombo; Label13: TLabel; DBMemo1: TDBMemo; Label2: TLabel; DBEdit2: TDBEdit; Label5: TLabel; wwDBLookupCombo3: TwwDBLookupCombo; Label8: TLabel; Label14: TLabel; DBMemo2: TDBMemo; Label9: TLabel; DBEdit9: TDBEdit; Label3: TLabel; Label6: TLabel; wwDBLookupCombo2: TwwDBLookupCombo; Label10: TLabel; DBEdit10: TDBEdit; Label11: TLabel; DBEdit11: TDBEdit; Label16: TLabel; DBMemo3: TDBMemo; bsSkinTabSheet11: TbsSkinTabSheet; bsSkinTabSheet22: TbsSkinTabSheet; bsSkinDBCheckRadioBox1: TbsSkinDBCheckRadioBox; RxDBLookupCombo1: TRxDBLookupCombo; Label12: TLabel; Label15: TLabel; DBEdit6: TDBEdit; wwDBLookupCombo4: TwwDBLookupCombo; t_ch_fee_do: TADOQuery; fra_ch_delete_do1: Tfra_ch_delete_do; fra_ch_add_do1: Tfra_ch_add_do; wwDBDateTimePicker1: TwwDBDateTimePicker; XPMenu1: TXPMenu; PopupMenu2: TPopupMenu; N10: TMenuItem; N11: TMenuItem; N14: TMenuItem; N13: TMenuItem; N12: TMenuItem; N15: TMenuItem; N16: TMenuItem; bsSkinButton7: TbsSkinButton; PopupMenu3: TPopupMenu; N17: TMenuItem; N18: TMenuItem; N34: TMenuItem; N35: TMenuItem; N36: TMenuItem; N1: TMenuItem; N6: TMenuItem; N4: TMenuItem; N5: TMenuItem; wwDBComboBox1: TwwDBComboBox; Label20: TLabel; Label19: TLabel; DBEdit7: TDBEdit; RxDBLookupCombo2: TRxDBLookupCombo; Label21: TLabel; Label22: TLabel; DBEdit3: TDBEdit; dxDBGrid1Column25: TdxDBGridColumn; dxDBGrid1Column26: TdxDBGridColumn; bsSkinButton12: TbsSkinButton; t_ch_invoice_head: TADOQuery; t_ch_invoice_head1: TDataSource; wwDBLookupCombo5: TwwDBLookupCombo; bsSkinButton38: TbsSkinButton; DBEdit8: TDBEdit; Label23: TLabel; DBEdit12: TDBEdit; memtblprint: TkbmMemTable; memtblprint1: TDataSource; dxDBGrid1Column27: TdxDBGridColumn; Label24: TLabel; DBEdit13: TDBEdit; Label26: TLabel; DBEdit15: TDBEdit; bsSkinButton15: TbsSkinButton; dxDBGrid1Column28: TdxDBGridColumn; dxDBGrid1Column29: TdxDBGridColumn; bsSkinButton13: TbsSkinButton; bsSkinButton14: TbsSkinButton; Label72: TLabel; DBEdit35: TDBEdit; bsSkinButton37: TbsSkinButton; t_ch_invoice_expitem: TADOQuery; procedure bsSkinButton5Click(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure FormShow(Sender: TObject); procedure bsSkinButton11Click(Sender: TObject); procedure t_ch_invoice_shenAfterInsert(DataSet: TDataSet); procedure bsSkinButton1Click(Sender: TObject); procedure bsSkinButton2Click(Sender: TObject); procedure bsSkinButton4Click(Sender: TObject); procedure bsSkinButton3Click(Sender: TObject); procedure t_ch_invoice_shenBeforePost(DataSet: TDataSet); procedure DBEdit9Enter(Sender: TObject); procedure t_ch_invoice_shenBeforeEdit(DataSet: TDataSet); procedure bsSkinButton6Click(Sender: TObject); procedure t_ch_invoice_shenAfterPost(DataSet: TDataSet); procedure RxDBLookupCombo1Enter(Sender: TObject); procedure dxDBGrid1Column2CustomDraw(Sender: TObject; ACanvas: TCanvas; ARect: TRect; ANode: TdxTreeListNode; AColumn: TdxDBTreeListColumn; const AText: String; AFont: TFont; var AColor: TColor; ASelected, AFocused: Boolean; var ADone: Boolean); procedure DBEdit1Change(Sender: TObject); procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); procedure bsSkinButton9Click(Sender: TObject); procedure bsSkinButton8Click(Sender: TObject); procedure bsSkinButton10Click(Sender: TObject); procedure t_ch_invoice_shenAfterDelete(DataSet: TDataSet); procedure DBEdit14KeyPress(Sender: TObject; var Key: Char); procedure DBEdit1KeyPress(Sender: TObject; var Key: Char); procedure RxDBLookupCombo1KeyPress(Sender: TObject; var Key: Char); procedure bsSkinDBCheckRadioBox1KeyPress(Sender: TObject; var Key: Char); procedure DBEdit2KeyPress(Sender: TObject; var Key: Char); procedure DBEdit4KeyPress(Sender: TObject; var Key: Char); procedure wwDBLookupCombo3KeyPress(Sender: TObject; var Key: Char); procedure wwDBLookupCombo2KeyPress(Sender: TObject; var Key: Char); procedure wwDBLookupCombo1KeyPress(Sender: TObject; var Key: Char); procedure wwDBLookupCombo4KeyPress(Sender: TObject; var Key: Char); procedure DBEdit9KeyPress(Sender: TObject; var Key: Char); procedure DBEdit10KeyPress(Sender: TObject; var Key: Char); procedure DBEdit11KeyPress(Sender: TObject; var Key: Char); procedure RxDBLookupCombo1Change(Sender: TObject); procedure wwDBDateTimePicker1KeyPress(Sender: TObject; var Key: Char); procedure N10Click(Sender: TObject); procedure N14Click(Sender: TObject); procedure N12Click(Sender: TObject); procedure N16Click(Sender: TObject); procedure dxDBGrid1ColumnSorting(Sender: TObject; Column: TdxDBTreeListColumn; var Allow: Boolean); procedure bsSkinPanel2Resize(Sender: TObject); procedure bsSkinButton7Click(Sender: TObject); procedure N17Click(Sender: TObject); procedure N34Click(Sender: TObject); procedure N36Click(Sender: TObject); procedure N6Click(Sender: TObject); procedure N4Click(Sender: TObject); procedure DBEdit7KeyPress(Sender: TObject; var Key: Char); procedure RxDBLookupCombo2KeyPress(Sender: TObject; var Key: Char); procedure DBEdit5KeyPress(Sender: TObject; var Key: Char); procedure wwDBComboBox1KeyPress(Sender: TObject; var Key: Char); procedure DBEdit3KeyPress(Sender: TObject; var Key: Char); procedure bsSkinButton12Click(Sender: TObject); procedure wwDBLookupCombo5KeyPress(Sender: TObject; var Key: Char); procedure bsSkinButton38Click(Sender: TObject); procedure DBEdit8Change(Sender: TObject); procedure bsSkinPageControl2Change(Sender: TObject); procedure fra_ch_add_do1bsSkinButton8Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure fra_ch_add_do1N1Click(Sender: TObject); procedure fra_ch_add_do1bsSkinButton11Click(Sender: TObject); procedure fra_ch_add_do1MenuItem1Click(Sender: TObject); procedure bsSkinButton15Click(Sender: TObject); procedure bsSkinButton13Click(Sender: TObject); procedure bsSkinButton14Click(Sender: TObject); procedure bsSkinButton37Click(Sender: TObject); private procedure t_ch_invoice_shenFieldChange(Sender: TField); procedure t_ch_invoice_shenKHFieldChange(Sender: TField); { Private declarations } public { Public declarations } MblNo:string; end; var ch_invoice_shen_open:boolean; frm_ch_invoice_shen: Tfrm_ch_invoice_shen; implementation uses u_main, my_sys_function, u_ch_shen_query, u_data_share, u_ch_invoice_expitems; {$R *.dfm} procedure Tfrm_ch_invoice_shen.bsSkinButton5Click(Sender: TObject); begin close; end; procedure Tfrm_ch_invoice_shen.FormClose(Sender: TObject; var Action: TCloseAction); begin ch_invoice_shen_open:=false; savereggrid(dxdbgrid1,caption); frm_ch_invoice_shen.Hide; frm_ch_invoice_shen.ManualFloat(frm_ch_invoice_shen.BoundsRect); frm_main.freeTabs('frm_ch_invoice_shen'); action:=cafree; frm_ch_invoice_shen:=nil; end; procedure Tfrm_ch_invoice_shen.FormShow(Sender: TObject); begin if MBLNO<>'' then fra_ch_add_do1.Edit34.text:=MBLNO; // bsSkinNotebook1.PageIndex:=0; { ch_invoice_shen_open:=true; t_ch_invoice_shen.Close; t_ch_invoice_shen.SQL.clear; t_ch_invoice_shen.SQL.Add('select * from t_ch_invoice_shen where 申请状态 not in ('+''''+'批准开票'+'''' +','+''''+'开出发票'+''''+') and ' +open_data('1001','申请人','no','no','no','no') +'order by 申请编号 desc'); t_ch_invoice_shen.open; // t_ch_fee_do.open; t_ch_invoice_head.open; //多业务合并处理 if StrToBool(get_parameters_value(85,'false')) then begin fra_ch_add_do1.bsSkinTabSheet1.TabVisible:=False; fra_ch_add_do1.bsSkinTabSheet2.TabVisible:=False; fra_ch_add_do1.bsSkinTabSheet3.TabVisible:=False; fra_ch_add_do1.bsSkinTabSheet4.TabVisible:=False; fra_ch_add_do1.bsSkinTabSheet5.TabVisible:=True; fra_ch_add_do1.bsSkinPageControl1.TabIndex:=0; fra_ch_delete_do1.bsSkinTabSheet1.TabVisible:=false; fra_ch_delete_do1.bsSkinTabSheet2.TabVisible:=false; fra_ch_delete_do1.bsSkinTabSheet3.TabVisible:=false; fra_ch_delete_do1.bsSkinTabSheet4.TabVisible:=false; fra_ch_delete_do1.bsSkinTabSheet5.TabVisible:=True; fra_ch_delete_do1.bsSkinPageControl1.ActivePage:=fra_ch_delete_do1.bsSkinTabSheet5; end else begin fra_ch_add_do1.bsSkinTabSheet1.TabVisible:=True; fra_ch_add_do1.bsSkinTabSheet2.TabVisible:=True; fra_ch_add_do1.bsSkinTabSheet3.TabVisible:=True; fra_ch_add_do1.bsSkinTabSheet4.TabVisible:=True; fra_ch_add_do1.bsSkinPageControl1.ActivePage:=fra_ch_add_do1.bsSkinTabSheet1; fra_ch_add_do1.bsSkinTabSheet5.TabVisible:=False; fra_ch_delete_do1.bsSkinTabSheet1.TabVisible:=True; fra_ch_delete_do1.bsSkinTabSheet2.TabVisible:=True; fra_ch_delete_do1.bsSkinTabSheet3.TabVisible:=True; fra_ch_delete_do1.bsSkinTabSheet4.TabVisible:=True; fra_ch_delete_do1.bsSkinTabSheet5.TabVisible:=false; fra_ch_delete_do1.bsSkinPageControl1.ActivePage:=fra_ch_delete_do1.bsSkinTabSheet1; end; fra_ch_add_do1.do_ban1.DataSet:=t_ch_invoice_shen; fra_ch_add_do1.bs_text.text:='7'; fra_ch_add_do1.wwDBComboBox31.text:='收'; fra_ch_add_do1.t_ch_fee_do.open; fra_ch_add_do1.bsSkinCheckRadioBox4.Checked:=False; fra_ch_add_do1.bsSkinPanel9.Visible:=true; //多业务合数据集处理 if StrToBool(get_parameters_value(85,'false')) then begin fra_ch_delete_do1.v_fee_do_bscard.SQL.clear; fra_ch_delete_do1.v_fee_do_bscard.sql.add('select * from v_fee_do_bscard ' +'where 工作编号=:申请编号 order by 编号,费用名称'); fra_ch_delete_do1.v_fee_do_bscard.DataSource:=t_ch_invoice_shen1; fra_ch_delete_do1.v_fee_do_bscard.Open; fra_ch_delete_do1.v_fee_do_bscard_sum.SQL.clear; fra_ch_delete_do1.v_fee_do_bscard_sum.sql.add('select SUBSTRING(CONVERT(char(15),开船日期,111),1,7) AS 月份,揽货人,原始币别,sum(原始金额) as 原始金额,sum(金额) as 金额 from v_fee_do_bscard ' +'where 工作编号=:申请编号 group by SUBSTRING(CONVERT(char(15),开船日期,111),1,7),揽货人,原始币别 ' +'order by 揽货人,SUBSTRING(CONVERT(char(15),开船日期,111),1,7),原始币别'); fra_ch_delete_do1.v_fee_do_bscard_sum.DataSource:=t_ch_invoice_shen1; fra_ch_delete_do1.v_fee_do_bscard_sum.Open; end else begin fra_ch_delete_do1.v_fee_do_seae.SQL.clear; fra_ch_delete_do1.v_fee_do_seae.sql.add('select * from v_fee_do_seae ' +'where 工作编号=:申请编号 order by 编号,费用名称'); fra_ch_delete_do1.v_fee_do_seae.DataSource:=t_ch_invoice_shen1; fra_ch_delete_do1.v_fee_do_seae.Open; fra_ch_delete_do1.v_fee_do_seai.SQL.clear; fra_ch_delete_do1.v_fee_do_seai.sql.add('select * from v_fee_do_seai ' +'where 工作编号=:申请编号 order by 编号,费用名称'); fra_ch_delete_do1.v_fee_do_seai.DataSource:=t_ch_invoice_shen1; fra_ch_delete_do1.v_fee_do_seai.Open; fra_ch_delete_do1.v_fee_do_aire.SQL.clear; fra_ch_delete_do1.v_fee_do_aire.sql.add('select * from v_fee_do_aire ' +'where 工作编号=:申请编号 order by 编号,费用名称'); fra_ch_delete_do1.v_fee_do_aire.DataSource:=t_ch_invoice_shen1; fra_ch_delete_do1.v_fee_do_aire.Open; fra_ch_delete_do1.v_fee_do_airi.SQL.clear; fra_ch_delete_do1.v_fee_do_airi.sql.add('select * from v_fee_do_airi ' +'where 工作编号=:申请编号 order by 编号,费用名称'); fra_ch_delete_do1.v_fee_do_airi.DataSource:=t_ch_invoice_shen1; fra_ch_delete_do1.v_fee_do_airi.Open; fra_ch_delete_do1.v_fee_do_seae_sum.SQL.clear; fra_ch_delete_do1.v_fee_do_seae_sum.sql.add('select SUBSTRING(CONVERT(char(15),开船日期,111),1,7) AS 月份,揽货人,原始币别,sum(原始金额) as 原始金额,sum(金额) as 金额 from v_fee_do_seae ' +'where 工作编号=:申请编号 group by SUBSTRING(CONVERT(char(15),开船日期,111),1,7),揽货人,原始币别 ' +'order by 揽货人,SUBSTRING(CONVERT(char(15),开船日期,111),1,7),原始币别'); fra_ch_delete_do1.v_fee_do_seae_sum.DataSource:=t_ch_invoice_shen1; fra_ch_delete_do1.v_fee_do_seae_sum.Open; fra_ch_delete_do1.v_fee_do_seai_sum.SQL.clear; fra_ch_delete_do1.v_fee_do_seai_sum.sql.add('select SUBSTRING(CONVERT(char(15),进口日期,111),1,7) AS 月份,揽货人,原始币别,sum(原始金额) as 原始金额,sum(金额) as 金额 from v_fee_do_seai ' +'where 工作编号=:申请编号 group by SUBSTRING(CONVERT(char(15),进口日期,111),1,7),揽货人,原始币别 ' +'order by 揽货人,SUBSTRING(CONVERT(char(15),进口日期,111),1,7),原始币别'); fra_ch_delete_do1.v_fee_do_seai_sum.DataSource:=t_ch_invoice_shen1; fra_ch_delete_do1.v_fee_do_seai_sum.Open; fra_ch_delete_do1.v_fee_do_aire_sum.SQL.clear; fra_ch_delete_do1.v_fee_do_aire_sum.sql.add('select SUBSTRING(CONVERT(char(15),开航日期,111),1,7) AS 月份,揽货人,原始币别,sum(原始金额) as 原始金额,sum(金额) as 金额 from v_fee_do_aire ' +'where 工作编号=:申请编号 group by SUBSTRING(CONVERT(char(15),开航日期,111),1,7),揽货人,原始币别 ' +'order by 揽货人,SUBSTRING(CONVERT(char(15),开航日期,111),1,7),原始币别'); fra_ch_delete_do1.v_fee_do_aire_sum.DataSource:=t_ch_invoice_shen1; fra_ch_delete_do1.v_fee_do_aire_sum.Open; fra_ch_delete_do1.v_fee_do_airi_sum.SQL.clear; fra_ch_delete_do1.v_fee_do_airi_sum.sql.add('select SUBSTRING(CONVERT(char(15),进口日期,111),1,7) AS 月份,揽货人,原始币别,sum(原始金额) as 原始金额,sum(金额) as 金额 from v_fee_do_airi ' +'where 工作编号=:申请编号 group by SUBSTRING(CONVERT(char(15),进口日期,111),1,7),揽货人,原始币别 ' +'order by 揽货人,SUBSTRING(CONVERT(char(15),进口日期,111),1,7),原始币别'); fra_ch_delete_do1.v_fee_do_airi_sum.DataSource:=t_ch_invoice_shen1; fra_ch_delete_do1.v_fee_do_airi_sum.Open; end; fra_ch_delete_do1.bs_text.Text:='7'; fra_ch_delete_do1.do_ban1.DataSet:=t_ch_invoice_shen; t_ch_invoice_shen.FieldByName('申请金额').OnChange:=t_ch_invoice_shenFieldChange; t_ch_invoice_shen.FieldByName('客户名称').OnChange:=t_ch_invoice_shenKHFieldChange; loadreggrid(dxdbgrid1,false,caption); frm_data_share.t_crm_client_all.requery; frm_data_share.t_code_currency.requery; } end; procedure Tfrm_ch_invoice_shen.bsSkinButton11Click(Sender: TObject); var answer:TModalResult; begin if bsSkinButton11.Caption='编辑修改' then begin if t_ch_invoice_shen.IsEmpty then exit; bsSkinNotebook1.PageIndex:=1; bsSkinButton11.Caption:='返回列表'; end else begin if (t_ch_invoice_shen.State=dsinsert)or(t_ch_invoice_shen.State=dsedit) then BEGIN answer:=messagedlg( '数据已经修改,是否保存?',mtWarning,mbYesNoCancel,0); if answer=mrYes then begin t_ch_invoice_shen.post; end; if answer=mrNo then begin t_ch_invoice_shen.cancel; end; if answer=mrCancel then begin exit; end; END; bsSkinNotebook1.PageIndex:=0; bsSkinButton11.Caption:='编辑修改'; end; end; procedure Tfrm_ch_invoice_shen.t_ch_invoice_shenAfterInsert( DataSet: TDataSet); begin t_ch_invoice_shen['申请状态']:='申请开票'; t_ch_invoice_shen['申请人']:=employee; t_ch_invoice_shen['申请日期']:=now; t_ch_invoice_shen['自动']:=1; t_ch_invoice_shen['申请金额']:=0; t_ch_invoice_shen['实际金额']:=0; t_ch_invoice_shen['虚开金额']:=0; t_ch_invoice_shen['扣税金额']:=0; t_ch_invoice_shen['申请类别']:='实际开票'; // t_ch_invoice_shen['申请编号']:=get_no(date,'IA'); end; procedure Tfrm_ch_invoice_shen.bsSkinButton1Click(Sender: TObject); begin t_ch_invoice_shen.insert; bsSkinNotebook1.PageIndex:=1; bsSkinPageControl2.ActivePage:=bsSkinTabSheet11; bsSkinButton11.Caption:='返回列表'; end; procedure Tfrm_ch_invoice_shen.bsSkinButton2Click(Sender: TObject); begin table_post(t_ch_invoice_shen); end; procedure Tfrm_ch_invoice_shen.bsSkinButton4Click(Sender: TObject); begin if t_ch_invoice_shen.IsEmpty then exit; if (t_ch_invoice_shen.FieldByName('申请状态').asstring='批准开票')or (t_ch_invoice_shen.FieldByName('申请状态').asstring='禁止修改')or (t_ch_invoice_shen.FieldByName('申请状态').asstring='开出发票')or (t_ch_invoice_shen.FieldByName('申请状态').asstring='提交申请')or (t_ch_invoice_shen.FieldByName('申请状态').asstring='申请修改')then begin showmessage('当前业务操作的状态不允许删除!!'); exit; end; if application.MessageBox('您确定要删除数据吗?','警告:',MB_OKCANCEL)=IDOK then begin t_ch_fee_do.open; while not t_ch_fee_do.eof do t_ch_fee_do.delete; t_ch_fee_do.close; if bsSkinPageControl2.ActivePage<>bsSkinTabSheet11 then bsSkinPageControl2.ActivePage:=bsSkinTabSheet11; t_ch_invoice_shen.Delete; end; end; procedure Tfrm_ch_invoice_shen.bsSkinButton3Click(Sender: TObject); begin table_cancel(t_ch_invoice_shen); end; procedure Tfrm_ch_invoice_shen.t_ch_invoice_shenBeforePost( DataSet: TDataSet); var aAdoQuery:TAdoQuery; USDAMT,RMBAMT:Double; begin table_before_post(t_ch_invoice_shen,'客户名称'); // table_before_post(t_ch_invoice_shen,'币别'); table_before_post(t_ch_invoice_shen,'申请类别'); if (t_ch_invoice_shen.FieldByName('申请类别').asstring<>'实际开票') and(t_ch_invoice_shen.FieldByName('申请类别').asstring<>'代开发票') and(t_ch_invoice_shen.FieldByName('申请类别').asstring<>'冲销发票')then begin showmessage('申请类别只能为:实际开票、代开发票、冲销发票!!'); abort; end; if (t_ch_invoice_shen.FieldByName('申请类别').asstring='代开发票')then begin if (t_ch_invoice_shen.FieldByName('代开客户').asstring='') then begin showmessage('发票为代开发票,代开客户不能为空!!'); abort; end; end; t_ch_invoice_shen['申请金额']:=s_w(strtoint(apointnum),t_ch_invoice_shen['申请金额']); t_ch_invoice_shen['实际金额']:=s_w(strtoint(apointnum),t_ch_invoice_shen['实际金额']); t_ch_invoice_shen['虚开金额']:=s_w(strtoint(apointnum),t_ch_invoice_shen['虚开金额']); if (t_ch_invoice_shen.state=dsinsert) and (trim(t_ch_invoice_shen.FieldByName('申请编号').AsString)='') then begin t_ch_invoice_shen['申请编号']:=get_no(date,'IA'); end; if t_ch_invoice_shen.FieldByName('自动').asboolean then begin t_ch_invoice_shen['申请金额']:=t_ch_invoice_shen['实际金额']; end; t_ch_invoice_shen['申请状态']:=t_ch_invoice_shen['申请状态']; t_ch_invoice_shen['虚开金额']:=t_ch_invoice_shen['申请金额']-t_ch_invoice_shen['实际金额']; add_zero(DBMemo2); t_ch_invoice_shen['金额列表']:=DBMemo2.text; USDAMT:=0; RMBAMT:=0; aAdoQuery:=CreateAdoQuery; with aAdoQuery do try Close;SQL.Clear; sql.Add('select '); sql.Add('sum(case when 币别=''RMB'' then 原始金额 else 0 end) as RMBAMT'); sql.Add(',sum(case when 币别<>''RMB'' then 原始金额 else 0 end) as USDAMT'); sql.Add('From t_ch_fee_do'); sql.Add('where 工作编号=:bsno'); Parameters.ParamByName('bsno').Value:=t_ch_invoice_shen.FieldByName('申请编号').Value; open;First; if not IsEmpty then begin USDAMT:=FieldByName('USDAMT').AsFloat; RMBAMT:=FieldByName('RMBAMT').AsFloat; end; t_ch_invoice_shen.FieldByName('人民币金额').AsFloat:=RMBAMT; t_ch_invoice_shen.FieldByName('美元金额').AsFloat:=USDAMT; finally Free; end; { if total_num(DBMemo2)<>t_ch_invoice_shen['申请金额'] then begin if MessageDlg('发票金额列表的合计金额与申请金额不一致,确认要保存吗?',mtWarning,[mbyes,mbno],0)=mrno then abort; end; } end; procedure Tfrm_ch_invoice_shen.DBEdit9Enter(Sender: TObject); begin if bsSkinDBCheckRadioBox1.Checked then DBEdit9.ReadOnly:=true else DBEdit9.ReadOnly:=false; end; procedure Tfrm_ch_invoice_shen.t_ch_invoice_shenBeforeEdit( DataSet: TDataSet); begin if not modify_all then begin if (t_ch_invoice_shen.FieldByName('申请状态').asstring='批准开票')or (t_ch_invoice_shen.FieldByName('申请状态').asstring='禁止修改')or (t_ch_invoice_shen.FieldByName('申请状态').asstring='开出发票')or (t_ch_invoice_shen.FieldByName('申请状态').asstring='提交申请')or (t_ch_invoice_shen.FieldByName('申请状态').asstring='申请修改')then begin showmessage('当前业务操作的状态不允许更改'); abort; end; end; end; procedure Tfrm_ch_invoice_shen.bsSkinButton6Click(Sender: TObject); var aAdoQueryCheck:TADOQuery; s_error:string; USDAMT,RMBAMT:Double; begin if t_ch_invoice_shen.IsEmpty then exit; if (t_ch_invoice_shen.FieldByName('人民币金额').AsFloat<>0) and (t_ch_invoice_shen.FieldByName('美元金额').AsFloat<>0) then begin ShowMessage('本票人民币金额和美元金额都存在,不能提交,需要拆分申请后在提交'); Exit; end; if bsSkinButton6.Caption='提交审核' then begin s_error:=''; aAdoQueryCheck:=CreateAdoQuery; with aAdoQueryCheck do try USDAMT:=0; RMBAMT:=0; s_error:=''; Close;sql.Clear; sql.Add('select '); sql.Add('sum(case when 币别=''RMB'' then 金额 else 0 end) as RMBAMT'); sql.Add(',sum(case when 币别<>''RMB'' then 金额 else 0 end) as USDAMT'); sql.Add('From t_ch_fee_do'); sql.Add('where 工作编号=:bsno'); Parameters.ParamByName('bsno').Value:=t_ch_invoice_shen.FieldByName('申请编号').Value; open;First; if not IsEmpty then begin USDAMT:=FieldByName('USDAMT').AsFloat; RMBAMT:=FieldByName('RMBAMT').AsFloat; end; Close;sql.Clear; sql.Add('select '); sql.Add('sum(case when 币别=''RMB'' then 金额 else 0 end) as RMBAMT'); sql.Add(',sum(case when 币别<>''RMB'' then 金额 else 0 end) as USDAMT'); sql.Add('From t_ch_fee_do'); sql.Add('where 工作编号=:bsno and 类型=5'); Parameters.ParamByName('bsno').Value:=t_ch_invoice_shen.FieldByName('申请编号').Value; open;First; if not IsEmpty then begin USDAMT:=USDAMT-FieldByName('USDAMT').AsFloat; RMBAMT:=RMBAMT-FieldByName('RMBAMT').AsFloat; end; if not t_ch_invoice_shen.IsEmpty then begin if StrToBool(get_parameters_value(83,'false')) then begin if (t_ch_invoice_shen.FieldByName('人民币金额').Value<> RMBAMT) or (t_ch_invoice_shen.FieldByName('美元金额').Value<> USDAMT) then begin s_error:=t_ch_invoice_shen.FieldByName('申请编号').Value+':USD'+FormatFloat('0.00;-0.00;0',FieldByName('USDAMT').AsFloat)+' RMB:'+FormatFloat('0.00;-0.00;0',FieldByName('RMBAMT').AsFloat); end; end else begin if (t_ch_invoice_shen.FieldByName('申请金额').AsFloat)<>(RMBAMT+USDAMT) then begin s_error:=t_ch_invoice_shen.FieldByName('申请编号').Value+':USD'+FormatFloat('0.00;-0.00;0',FieldByName('USDAMT').AsFloat)+' RMB:'+FormatFloat('0.00;-0.00;0',FieldByName('RMBAMT').AsFloat); end; end; if Trim(s_error)<>'' then begin ShowMessage(s_error+#13#10+'帐单总数不等于帐单明细请核对帐单'); Exit; end; end; finally free; end; end; aAdoQueryCheck:=CreateAdoQuery; with aAdoQueryCheck do try Close;sql.Clear; sql.Add('select count(*) c'); sql.Add('From t_ch_fee_do'); sql.Add('where 工作编号=:bsno'); Parameters.ParamByName('bsno').Value:=t_ch_invoice_shen.FieldByName('申请编号').Value; open;First; if FieldByName('c').AsInteger<=0 then begin ShowMessage('不存在费用明细,不用提交'); Exit; end; finally free; end; if t_ch_invoice_shen.FieldByName('申请状态').AsString='提交申请' then begin modify_all:=true; try t_ch_invoice_shen.Edit; t_ch_invoice_shen['申请状态']:='申请开票'; t_ch_invoice_shen.post; t_ch_invoice_shen.Refresh; finally modify_all:=false; end; end else begin shen_update(t_ch_invoice_shen); end; end; procedure Tfrm_ch_invoice_shen.t_ch_invoice_shenAfterPost( DataSet: TDataSet); begin case delete_do_type_num of 1: begin if fra_ch_delete_do1.v_fee_do_seae.active then begin fra_ch_delete_do1.v_fee_do_seae.Requery; fra_ch_delete_do1.v_fee_do_seae_sum.Requery; end; end; 2: begin if fra_ch_delete_do1.v_fee_do_seai.active then begin fra_ch_delete_do1.v_fee_do_seai.Requery; fra_ch_delete_do1.v_fee_do_seai_sum.Requery; end; end; 3: begin if fra_ch_delete_do1.v_fee_do_aire.active then begin fra_ch_delete_do1.v_fee_do_aire.Requery; fra_ch_delete_do1.v_fee_do_aire_sum.Requery; end; end; 4: begin if fra_ch_delete_do1.v_fee_do_airi.active then begin fra_ch_delete_do1.v_fee_do_airi.Requery; fra_ch_delete_do1.v_fee_do_airi_sum.Requery; end; end; 5: begin if fra_ch_delete_do1.v_fee_do_bscard.active then begin fra_ch_delete_do1.v_fee_do_bscard.Requery; fra_ch_delete_do1.v_fee_do_bscard_sum.Requery; end; end; end; end; procedure Tfrm_ch_invoice_shen.RxDBLookupCombo1Enter(Sender: TObject); begin if fra_ch_delete_do1.v_fee_do_seae.IsEmpty and fra_ch_delete_do1.v_fee_do_seai.IsEmpty and fra_ch_delete_do1.v_fee_do_aire.IsEmpty and fra_ch_delete_do1.v_fee_do_airi.IsEmpty then begin RxDBLookupCombo1.ReadOnly:=false; wwDBLookupCombo4.ReadOnly:=false; end else begin RxDBLookupCombo1.ReadOnly:=true; wwDBLookupCombo4.ReadOnly:=true; end; end; procedure Tfrm_ch_invoice_shen.dxDBGrid1Column2CustomDraw(Sender: TObject; ACanvas: TCanvas; ARect: TRect; ANode: TdxTreeListNode; AColumn: TdxDBTreeListColumn; const AText: String; AFont: TFont; var AColor: TColor; ASelected, AFocused: Boolean; var ADone: Boolean); begin if (ANode.strings[dxDBGrid1Column2.Index]='申请开票')or (ANode.strings[dxDBGrid1Column2.Index]='批准修改') then AColor :=clwhite else if (ANode.strings[dxDBGrid1Column2.Index]='提交申请')or (ANode.strings[dxDBGrid1Column2.Index]='申请修改') then AColor :=clyellow else if (ANode.strings[dxDBGrid1Column2.Index]='禁止修改')or (ANode.strings[dxDBGrid1Column2.Index]='驳回申请')then AColor :=clred else if (ANode.strings[dxDBGrid1Column2.Index]='批准开票')or (ANode.strings[dxDBGrid1Column2.Index]='开出发票') then AColor :=$00DDF21C; AFont.Color:=clblack; end; procedure Tfrm_ch_invoice_shen.DBEdit1Change(Sender: TObject); begin if (DBEdit1.Text='') or (DBEdit1.Text='申请开票') or (DBEdit1.Text='批准修改')then DBEdit1.Color:=clwhite else if (DBEdit1.Text='提交申请') or (DBEdit1.Text='申请修改') then DBEdit1.Color:=clyellow else if (DBEdit1.Text='禁止修改') or (DBEdit1.Text='驳回申请') then DBEdit1.Color:=clred else if (DBEdit1.Text='批准开票') or (DBEdit1.Text='开出发票') then DBEdit1.Color:=$00DDF21C; end; procedure Tfrm_ch_invoice_shen.FormCloseQuery(Sender: TObject; var CanClose: Boolean); begin CanClose:=frm_close_query(t_ch_invoice_shen); end; procedure Tfrm_ch_invoice_shen.bsSkinButton9Click(Sender: TObject); var aQuery:TAdoQuery; strbs,strwt,strmb:WideString; begin if t_ch_invoice_shen.IsEmpty then exit; table_post(t_ch_invoice_shen); //打印次数 try modify_all:=true; t_ch_invoice_shen.Edit; t_ch_invoice_shen.FieldByName('打印次数').AsInteger:=t_ch_invoice_shen.FieldByName('打印次数').AsInteger+1; t_ch_invoice_shen.post; finally modify_all:=false; end; //委托编号、业务编号、主提单号字符生成 memtblprint.close; memtblprint.Open; aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.Clear; sql.Add('select distinct 委托编号,业务编号,主提单号 from v_op_bscard where 编号 in (select 业务编号 from t_ch_fee_do where 工作编号='''+t_ch_invoice_shen['申请编号']+''')'); Open; first; while not eof do begin if strwt='' then strwt:=fieldbyname('委托编号').AsString else strwt:=strwt+'/'+fieldbyname('委托编号').AsString; if strbs='' then strbs:=fieldbyname('业务编号').AsString else strbs:=strbs+'/'+fieldbyname('业务编号').AsString; if strmb='' then strmb:=fieldbyname('主提单号').AsString else strmb:=strmb+'/'+fieldbyname('主提单号').AsString; Next; end; memtblprint.Edit; memtblprint.fieldbyname('bsno').AsString:=strbs; memtblprint.fieldbyname('wtno').AsString:=strwt; memtblprint.fieldbyname('mblno').AsString:=strmb; memtblprint.post; end; finally FreeAndNil(aQuery); end; if StrToBool(get_parameters_value(85,'false')) then begin sys_print('业务发票申请',2,t_ch_invoice_shen1,memtblprint1,nil,nil,fra_ch_delete_do1.v_fee_do_bscard1,nil,nil,nil,fra_ch_delete_do1.v_fee_do_bscard1,t_ch_invoice_shen1,nil); end else begin sys_print('业务发票申请',2,t_ch_invoice_shen1,memtblprint1,nil,nil,fra_ch_delete_do1.v_fee_do_seae1,fra_ch_delete_do1.v_fee_do_seai1,fra_ch_delete_do1.v_fee_do_aire1,fra_ch_delete_do1.v_fee_do_airi1,nil,t_ch_invoice_shen1,nil); end; end; procedure Tfrm_ch_invoice_shen.bsSkinButton8Click(Sender: TObject); var str:string; begin if t_ch_invoice_shen.IsEmpty then exit; if (t_ch_invoice_shen.FieldByName('申请类别').asstring='实际开票')then begin shen_modify(t_ch_invoice_shen); end else begin if (t_ch_invoice_shen.FieldByName('申请状态').asstring='批准开票')or (t_ch_invoice_shen.FieldByName('申请状态').asstring='禁止修改')or (t_ch_invoice_shen.FieldByName('申请状态').asstring='提交申请')or (t_ch_invoice_shen.FieldByName('申请状态').asstring='开出发票')then begin str:=trim(InputBox('请输入申请原因', '申请原因:', '')); if str=''then begin showmessage('申请原因不能为空,申请失败!!'); exit; end; try modify_all:=true; t_ch_invoice_shen.Edit; t_ch_invoice_shen['申请状态']:='申请修改'; t_ch_invoice_shen['申请原因']:=str; t_ch_invoice_shen.post; t_ch_invoice_shen.Refresh; { if strtobool(get_parameters_value(1,'false'))then Send_invocie_check_shen('申请修改发票,申请编号:'+t_ch_invoice_shen.fieldbyname('申请编号').asstring +',客户:'+t_ch_invoice_shen.fieldbyname('客户名称').asstring,'029','16',t_ch_invoice_shen.fieldbyname('申请编号').asstring) else Send_invocie_check_shen('申请修改发票,申请编号:'+t_ch_invoice_shen.fieldbyname('申请编号').asstring +',客户:'+t_ch_invoice_shen.fieldbyname('客户名称').asstring,'030','16',t_ch_invoice_shen.fieldbyname('申请编号').asstring); } finally modify_all:=false; end; end else begin showmessage('当前业务状态不能申请修改!!'); end; end; end; procedure Tfrm_ch_invoice_shen.bsSkinButton10Click(Sender: TObject); begin try frm_ch_shen_query:=tfrm_ch_shen_query.Create (self); shen_query_type:=1; shen_query_limited:='1001'; shen_query_op_limited:='1002'; frm_ch_shen_query.ShowModal; finally frm_ch_shen_query.Free; end; end; procedure Tfrm_ch_invoice_shen.t_ch_invoice_shenAfterDelete( DataSet: TDataSet); begin if fra_ch_add_do1.t_op_seae.Active then fra_ch_add_do1.t_op_seae.Requery(); if fra_ch_add_do1.t_op_seai.Active then fra_ch_add_do1.t_op_seai.Requery(); if fra_ch_add_do1.t_op_aire.Active then fra_ch_add_do1.t_op_aire.Requery(); if fra_ch_add_do1.t_op_airi.Active then fra_ch_add_do1.t_op_airi.Requery(); end; procedure Tfrm_ch_invoice_shen.DBEdit14KeyPress(Sender: TObject; var Key: Char); begin key_DBEdit(Key,DBEdit1); end; procedure Tfrm_ch_invoice_shen.DBEdit1KeyPress(Sender: TObject; var Key: Char); begin key_DBEdit(Key,DBEdit5); end; procedure Tfrm_ch_invoice_shen.RxDBLookupCombo1KeyPress(Sender: TObject; var Key: Char); begin key_RxDBLookupCombo(Key,RxDBLookupCombo2); end; procedure Tfrm_ch_invoice_shen.bsSkinDBCheckRadioBox1KeyPress( Sender: TObject; var Key: Char); begin key_DBEdit(Key,DBEdit3); end; procedure Tfrm_ch_invoice_shen.DBEdit2KeyPress(Sender: TObject; var Key: Char); begin key_wwDBDateTimePicker(Key,wwDBDateTimePicker1); end; procedure Tfrm_ch_invoice_shen.DBEdit4KeyPress(Sender: TObject; var Key: Char); begin key_wwDBLookupCombo(Key,wwDBLookupCombo3); end; procedure Tfrm_ch_invoice_shen.wwDBLookupCombo3KeyPress(Sender: TObject; var Key: Char); begin key_wwDBLookupCombo(Key,wwDBLookupCombo2); end; procedure Tfrm_ch_invoice_shen.wwDBLookupCombo2KeyPress(Sender: TObject; var Key: Char); begin key_wwDBLookupCombo(Key,wwDBLookupCombo1); end; procedure Tfrm_ch_invoice_shen.wwDBLookupCombo1KeyPress(Sender: TObject; var Key: Char); begin key_wwDBLookupCombo(Key,wwDBLookupCombo4); end; procedure Tfrm_ch_invoice_shen.wwDBLookupCombo4KeyPress(Sender: TObject; var Key: Char); begin key_DBEdit(Key,DBEdit9); end; procedure Tfrm_ch_invoice_shen.DBEdit9KeyPress(Sender: TObject; var Key: Char); begin key_DBEdit(Key,DBEdit10); end; procedure Tfrm_ch_invoice_shen.DBEdit10KeyPress(Sender: TObject; var Key: Char); begin key_DBEdit(Key,DBEdit11); end; procedure Tfrm_ch_invoice_shen.DBEdit11KeyPress(Sender: TObject; var Key: Char); begin key_DBMemo(Key,DBMemo1); end; procedure Tfrm_ch_invoice_shen.RxDBLookupCombo1Change(Sender: TObject); begin if (t_ch_invoice_shen.state=dsinsert)or(t_ch_invoice_shen.state=dsedit)then begin if frm_data_share.t_crm_client_all.locate('客户简称',RxDBLookupCombo1.DisplayValues[1],[]) then begin if frm_data_share.t_crm_client_all.fieldbyname('发票抬头').asstring<>'' then t_ch_invoice_shen['发票抬头']:=frm_data_share.t_crm_client_all.fieldbyname('发票抬头').asstring else t_ch_invoice_shen['发票抬头']:=frm_data_share.t_crm_client_all.fieldbyname('客户全称').asstring; end; end; end; procedure Tfrm_ch_invoice_shen.wwDBDateTimePicker1KeyPress(Sender: TObject; var Key: Char); begin key_DBEdit(Key,DBEdit4); end; procedure Tfrm_ch_invoice_shen.N10Click(Sender: TObject); begin update_grid_view_no(dxdbgrid1); end; procedure Tfrm_ch_invoice_shen.N14Click(Sender: TObject); begin update_grid_view_all(dxdbgrid1); end; procedure Tfrm_ch_invoice_shen.N12Click(Sender: TObject); begin update_grid(dxdbgrid1,10); end; procedure Tfrm_ch_invoice_shen.N16Click(Sender: TObject); begin grid_save_xls(dxdbgrid1); end; procedure Tfrm_ch_invoice_shen.dxDBGrid1ColumnSorting(Sender: TObject; Column: TdxDBTreeListColumn; var Allow: Boolean); begin Column_sort(Column,t_ch_invoice_shen,'申请编号'); end; procedure Tfrm_ch_invoice_shen.bsSkinPanel2Resize(Sender: TObject); var i:integer; begin i:=round(bsSkinPanel2.Width/14); bsSkinButton10.Width:=i; bsSkinButton9.Width:=i; bsSkinButton2.Width:=i; bsSkinButton3.Width:=i; bsSkinButton4.Width:=i; bsSkinButton1.Width:=i; bsSkinButton11.Width:=i; bsSkinButton6.Width:=i; bsSkinButton8.Width:=i; bsSkinButton12.Width:=i; bsSkinButton38.Width:=i; bsSkinButton13.Width:=i; bsSkinButton14.Width:=i; bsSkinButton7.Left:=bsSkinPanel2.Width-bsSkinButton7.Width-20; end; procedure Tfrm_ch_invoice_shen.bsSkinButton7Click(Sender: TObject); var Pnt:Tpoint; begin Pnt:=bsSkinButton7.ClientToScreen(Point(0,bsSkinButton7.Height)); PopupMenu3.Popup(Pnt.x,Pnt.y); end; procedure Tfrm_ch_invoice_shen.N17Click(Sender: TObject); begin t_ch_invoice_shen.Close; t_ch_invoice_shen.SQL.clear; t_ch_invoice_shen.SQL.Add('select * from t_ch_invoice_shen where 申请状态 in ('+''''+'申请开票'+'''' +') and ' +open_data('1001','申请人','no','no','no','no') +'order by 申请编号 desc'); t_ch_invoice_shen.open; end; procedure Tfrm_ch_invoice_shen.N34Click(Sender: TObject); begin t_ch_invoice_shen.Close; t_ch_invoice_shen.SQL.clear; t_ch_invoice_shen.SQL.Add('select * from t_ch_invoice_shen where 申请状态 in ('+''''+'驳回申请'+'''' +','+''''+'禁止修改'+''''+') and ' +open_data('1001','申请人','no','no','no','no') +'order by 申请编号 desc'); t_ch_invoice_shen.open; end; procedure Tfrm_ch_invoice_shen.N36Click(Sender: TObject); begin t_ch_invoice_shen.Close; t_ch_invoice_shen.SQL.clear; t_ch_invoice_shen.SQL.Add('select * from t_ch_invoice_shen where 申请状态 in ('+''''+'提交申请'+'''' +','+''''+'申请修改'+''''+') and ' +open_data('1001','申请人','no','no','no','no') +'order by 申请编号 desc'); t_ch_invoice_shen.open; end; procedure Tfrm_ch_invoice_shen.N6Click(Sender: TObject); begin t_ch_invoice_shen.Close; t_ch_invoice_shen.SQL.clear; t_ch_invoice_shen.SQL.Add('select * from t_ch_invoice_shen where 申请状态 in ('+''''+'批准开票'+'''' +','+''''+'禁止修改'+''''+') and ' +open_data('1001','申请人','no','no','no','no') +'order by 申请编号 desc'); t_ch_invoice_shen.open; end; procedure Tfrm_ch_invoice_shen.N4Click(Sender: TObject); begin t_ch_invoice_shen.Close; t_ch_invoice_shen.SQL.clear; t_ch_invoice_shen.SQL.Add('select * from t_ch_invoice_shen where 申请状态 in ('+''''+'开出发票'+''''+') and ' +open_data('1001','申请人','no','no','no','no') +'order by 申请编号 desc'); t_ch_invoice_shen.open; end; procedure Tfrm_ch_invoice_shen.DBEdit7KeyPress(Sender: TObject; var Key: Char); begin key_RxDBLookupCombo(Key,RxDBLookupCombo1); end; procedure Tfrm_ch_invoice_shen.RxDBLookupCombo2KeyPress(Sender: TObject; var Key: Char); begin key_bsSkinDBCheckRadioBox(Key,bsSkinDBCheckRadioBox1); end; procedure Tfrm_ch_invoice_shen.DBEdit5KeyPress(Sender: TObject; var Key: Char); begin key_wwDBComboBox(Key,wwDBComboBox1); end; procedure Tfrm_ch_invoice_shen.wwDBComboBox1KeyPress(Sender: TObject; var Key: Char); begin key_DBEdit(Key,DBEdit7); end; procedure Tfrm_ch_invoice_shen.DBEdit3KeyPress(Sender: TObject; var Key: Char); begin key_wwDBLookupCombo(Key,wwDBLookupCombo5); end; procedure Tfrm_ch_invoice_shen.bsSkinButton12Click(Sender: TObject); var afield : variant; i: Integer; begin if t_ch_invoice_shen.IsEmpty then exit; try afield := vararraycreate([0,t_ch_invoice_shen.fieldcount-1],varvariant); for i := 0 to (t_ch_invoice_shen.fieldcount-1) do begin afield[i] :=t_ch_invoice_shen.fields[i].value ; end; t_ch_invoice_shen.insert; for i := 0 to (t_ch_invoice_shen.fieldcount-1) do begin if t_ch_invoice_shen.fields[i].FieldName<>'申请编号'then t_ch_invoice_shen.fields[i].value := afield[i] ; end; t_ch_invoice_shen['发票号码']:=''; t_ch_invoice_shen['申请状态']:='申请开票'; t_ch_invoice_shen['费用列表']:=''; t_ch_invoice_shen['金额列表']:=''; t_ch_invoice_shen['申请金额']:=0; t_ch_invoice_shen['实际金额']:=0; t_ch_invoice_shen['虚开金额']:=0; t_ch_invoice_shen['扣税金额']:=0; t_ch_invoice_shen['申请人']:=employee; t_ch_invoice_shen['申请日期']:=now; t_ch_invoice_shen['自动']:=1; t_ch_invoice_shen['审核人']:=''; t_ch_invoice_shen['审核日期']:=null; t_ch_invoice_shen['开出人']:=''; t_ch_invoice_shen['开出日期']:=null; t_ch_invoice_shen['申请原因']:=''; bsSkinNotebook1.PageIndex:=1; bsSkinPageControl2.ActivePage:=bsSkinTabSheet11; bsSkinButton11.Caption:='返回列表'; except if t_ch_invoice_shen.state=dsinsert then t_ch_invoice_shen.cancel; showmessage('复制添加失败!!'); end; end; procedure Tfrm_ch_invoice_shen.wwDBLookupCombo5KeyPress(Sender: TObject; var Key: Char); begin key_DBEdit(Key,DBEdit2); end; procedure Tfrm_ch_invoice_shen.t_ch_invoice_shenFieldChange( Sender: TField); begin if t_ch_invoice_shen.state in [dsedit,dsinsert] then t_ch_invoice_shen['虚开金额']:=t_ch_invoice_shen['申请金额']-t_ch_invoice_shen['实际金额']; end; procedure Tfrm_ch_invoice_shen.bsSkinButton38Click(Sender: TObject); var book1:Tbookmark; begin book1:=t_ch_invoice_shen.GetBookmark; t_ch_invoice_shen.Requery; t_ch_invoice_shen.GotoBookmark(book1); end; procedure Tfrm_ch_invoice_shen.t_ch_invoice_shenKHFieldChange( Sender: TField); begin if not frm_data_share.t_crm_client_all.IsEmpty then if frm_data_share.t_crm_client_all.locate('客户简称',t_ch_invoice_shen['客户名称'],[]) then begin if frm_data_share.t_crm_client_all.fieldbyname('发票抬头').asstring<>'' then t_ch_invoice_shen['发票抬头']:=frm_data_share.t_crm_client_all.fieldbyname('发票抬头').asstring else t_ch_invoice_shen['发票抬头']:=frm_data_share.t_crm_client_all.fieldbyname('客户全称').asstring; end; end; procedure Tfrm_ch_invoice_shen.DBEdit8Change(Sender: TObject); begin bsSkinButton6.Caption:='提交审核'; if t_ch_invoice_shen.State in [dsinsert] then exit; if t_ch_invoice_shen.IsEmpty then exit; if t_ch_invoice_shen.FieldByName('申请状态').AsString='提交申请' then begin bsSkinButton6.Caption:='撤销申请'; end else begin bsSkinButton6.Caption:='提交审核'; end; end; procedure Tfrm_ch_invoice_shen.bsSkinPageControl2Change(Sender: TObject); begin if not ch_invoice_shen_open then exit; if bsSkinPageControl2.ActivePage<>bsSkinTabSheet22 then exit; { if StrToBool(get_parameters_value(85,'false')) then begin fra_ch_delete_do1.v_fee_do_bscard.close; fra_ch_delete_do1.v_fee_do_bscard.SQL.clear; fra_ch_delete_do1.v_fee_do_bscard.sql.add('select * from v_fee_do_bscard ' +'where 工作编号='''+t_ch_invoice_shen.fieldbyname('申请编号').AsString+''' order by 类型,编号,费用名称'); fra_ch_delete_do1.v_fee_do_bscard.Open; fra_ch_delete_do1.v_fee_do_bscard_sum.close; fra_ch_delete_do1.v_fee_do_bscard_sum.SQL.clear; fra_ch_delete_do1.v_fee_do_bscard_sum.sql.add('select 类型,SUBSTRING(CONVERT(char(15),开船日期,111),1,7) AS 月份,揽货人,原始币别,sum(原始金额) as 原始金额,sum(金额) as 金额 from v_fee_do_bscard ' +'where 工作编号='''+t_ch_invoice_shen.fieldbyname('申请编号').AsString+''' group by 类型,SUBSTRING(CONVERT(char(15),开船日期,111),1,7),揽货人,原始币别 ' +'order by 类型,揽货人,SUBSTRING(CONVERT(char(15),开船日期,111),1,7),原始币别'); fra_ch_delete_do1.v_fee_do_bscard_sum.Open; end else begin fra_ch_delete_do1.v_fee_do_seae.close; fra_ch_delete_do1.v_fee_do_seae.SQL.clear; fra_ch_delete_do1.v_fee_do_seae.sql.add('select * from v_fee_do_seae ' +'where 工作编号='''+t_ch_invoice_shen.fieldbyname('申请编号').AsString+''' order by 类型,编号,费用名称'); fra_ch_delete_do1.v_fee_do_seae.Open; fra_ch_delete_do1.v_fee_do_seai.close; fra_ch_delete_do1.v_fee_do_seai.SQL.clear; fra_ch_delete_do1.v_fee_do_seai.sql.add('select * from v_fee_do_seai ' +'where 工作编号='''+t_ch_invoice_shen.fieldbyname('申请编号').AsString+''' order by 类型,编号,费用名称'); fra_ch_delete_do1.v_fee_do_seai.Open; fra_ch_delete_do1.v_fee_do_aire.close; fra_ch_delete_do1.v_fee_do_aire.SQL.clear; fra_ch_delete_do1.v_fee_do_aire.sql.add('select * from v_fee_do_aire ' +'where 工作编号='''+t_ch_invoice_shen.fieldbyname('申请编号').AsString+''' order by 类型,编号,费用名称'); fra_ch_delete_do1.v_fee_do_aire.Open; fra_ch_delete_do1.v_fee_do_airi.close; fra_ch_delete_do1.v_fee_do_airi.SQL.clear; fra_ch_delete_do1.v_fee_do_airi.sql.add('select * from v_fee_do_airi ' +'where 工作编号='''+t_ch_invoice_shen.fieldbyname('申请编号').AsString+''' order by 类型,编号,费用名称'); fra_ch_delete_do1.v_fee_do_airi.Open; fra_ch_delete_do1.v_fee_do_seae_sum.close; fra_ch_delete_do1.v_fee_do_seae_sum.SQL.clear; fra_ch_delete_do1.v_fee_do_seae_sum.sql.add('select 类型,SUBSTRING(CONVERT(char(15),开船日期,111),1,7) AS 月份,揽货人,原始币别,sum(原始金额) as 原始金额,sum(金额) as 金额 from v_fee_do_seae ' +'where 工作编号='''+t_ch_invoice_shen.fieldbyname('申请编号').AsString+''' group by 类型,SUBSTRING(CONVERT(char(15),开船日期,111),1,7),揽货人,原始币别 ' +'order by 类型,揽货人,SUBSTRING(CONVERT(char(15),开船日期,111),1,7),原始币别'); fra_ch_delete_do1.v_fee_do_seae_sum.Open; fra_ch_delete_do1.v_fee_do_seai_sum.close; fra_ch_delete_do1.v_fee_do_seai_sum.SQL.clear; fra_ch_delete_do1.v_fee_do_seai_sum.sql.add('select 类型,SUBSTRING(CONVERT(char(15),进口日期,111),1,7) AS 月份,揽货人,原始币别,sum(原始金额) as 原始金额,sum(金额) as 金额 from v_fee_do_seai ' +'where 工作编号='''+t_ch_invoice_shen.fieldbyname('申请编号').AsString+''' group by 类型,SUBSTRING(CONVERT(char(15),进口日期,111),1,7),揽货人,原始币别 ' +'order by 类型,揽货人,SUBSTRING(CONVERT(char(15),进口日期,111),1,7),原始币别'); fra_ch_delete_do1.v_fee_do_seai_sum.Open; fra_ch_delete_do1.v_fee_do_aire_sum.close; fra_ch_delete_do1.v_fee_do_aire_sum.SQL.clear; fra_ch_delete_do1.v_fee_do_aire_sum.sql.add('select 类型,SUBSTRING(CONVERT(char(15),开航日期,111),1,7) AS 月份,揽货人,原始币别,sum(原始金额) as 原始金额,sum(金额) as 金额 from v_fee_do_aire ' +'where 工作编号='''+t_ch_invoice_shen.fieldbyname('申请编号').AsString+''' group by 类型,SUBSTRING(CONVERT(char(15),开航日期,111),1,7),揽货人,原始币别 ' +'order by 类型,揽货人,SUBSTRING(CONVERT(char(15),开航日期,111),1,7),原始币别'); fra_ch_delete_do1.v_fee_do_aire_sum.Open; fra_ch_delete_do1.v_fee_do_aire_sum.close; fra_ch_delete_do1.v_fee_do_airi_sum.SQL.clear; fra_ch_delete_do1.v_fee_do_airi_sum.sql.add('select 类型,SUBSTRING(CONVERT(char(15),进口日期,111),1,7) AS 月份,揽货人,原始币别,sum(原始金额) as 原始金额,sum(金额) as 金额 from v_fee_do_airi ' +'where 工作编号='''+t_ch_invoice_shen.fieldbyname('申请编号').AsString+''' group by 类型,SUBSTRING(CONVERT(char(15),进口日期,111),1,7),揽货人,原始币别 ' +'order by 类型,揽货人,SUBSTRING(CONVERT(char(15),进口日期,111),1,7),原始币别'); fra_ch_delete_do1.v_fee_do_aire_sum.Open; end; } end; procedure Tfrm_ch_invoice_shen.fra_ch_add_do1bsSkinButton8Click( Sender: TObject); begin fra_ch_add_do1.bsSkinButton8Click(Sender); end; procedure Tfrm_ch_invoice_shen.FormCreate(Sender: TObject); begin bsSkinNotebook1.PageIndex:=0; ch_invoice_shen_open:=true; t_ch_invoice_shen.Close; t_ch_invoice_shen.SQL.clear; t_ch_invoice_shen.SQL.Add('select * from t_ch_invoice_shen where 申请状态 not in ('+''''+'批准开票'+'''' +','+''''+'开出发票'+''''+') and ' +open_data('1001','申请人','no','no','no','no') +'order by 申请编号 desc'); t_ch_invoice_shen.open; // t_ch_fee_do.open; t_ch_invoice_head.open; //多业务合并处理 if StrToBool(get_parameters_value(85,'false')) then begin fra_ch_add_do1.bsSkinTabSheet1.TabVisible:=False; fra_ch_add_do1.bsSkinTabSheet2.TabVisible:=False; fra_ch_add_do1.bsSkinTabSheet3.TabVisible:=False; fra_ch_add_do1.bsSkinTabSheet4.TabVisible:=False; fra_ch_add_do1.bsSkinTabSheet5.TabVisible:=True; fra_ch_add_do1.bsSkinPageControl1.TabIndex:=0; // fra_ch_add_do1.bsSkinButton11.Caption:='发票申请'; fra_ch_delete_do1.bsSkinTabSheet1.TabVisible:=false; fra_ch_delete_do1.bsSkinTabSheet2.TabVisible:=false; fra_ch_delete_do1.bsSkinTabSheet3.TabVisible:=false; fra_ch_delete_do1.bsSkinTabSheet4.TabVisible:=false; fra_ch_delete_do1.bsSkinTabSheet5.TabVisible:=True; fra_ch_delete_do1.bsSkinPageControl1.ActivePage:=fra_ch_delete_do1.bsSkinTabSheet5; end else begin fra_ch_add_do1.bsSkinTabSheet1.TabVisible:=True; fra_ch_add_do1.bsSkinTabSheet2.TabVisible:=True; fra_ch_add_do1.bsSkinTabSheet3.TabVisible:=True; fra_ch_add_do1.bsSkinTabSheet4.TabVisible:=True; fra_ch_add_do1.bsSkinPageControl1.ActivePage:=fra_ch_add_do1.bsSkinTabSheet1; fra_ch_add_do1.bsSkinTabSheet5.TabVisible:=False; fra_ch_delete_do1.bsSkinTabSheet1.TabVisible:=True; fra_ch_delete_do1.bsSkinTabSheet2.TabVisible:=True; fra_ch_delete_do1.bsSkinTabSheet3.TabVisible:=True; fra_ch_delete_do1.bsSkinTabSheet4.TabVisible:=True; fra_ch_delete_do1.bsSkinTabSheet5.TabVisible:=false; fra_ch_delete_do1.bsSkinPageControl1.ActivePage:=fra_ch_delete_do1.bsSkinTabSheet1; end; fra_ch_add_do1.do_ban1.DataSet:=t_ch_invoice_shen; fra_ch_add_do1.bs_text.text:='7'; fra_ch_add_do1.wwDBComboBox31.text:='收'; fra_ch_add_do1.t_ch_fee_do.open; fra_ch_add_do1.bsSkinCheckRadioBox4.Checked:=False; fra_ch_add_do1.bsSkinPanel9.Visible:=true; //多业务合数据集处理 if StrToBool(get_parameters_value(85,'false')) then begin fra_ch_delete_do1.v_fee_do_bscard.SQL.clear; fra_ch_delete_do1.v_fee_do_bscard.sql.add('select * from v_fee_do_bscard ' +'where 工作编号=:申请编号 order by 编号,费用名称'); fra_ch_delete_do1.v_fee_do_bscard.DataSource:=t_ch_invoice_shen1; fra_ch_delete_do1.v_fee_do_bscard.Open; fra_ch_delete_do1.v_fee_do_bscard_sum.SQL.clear; fra_ch_delete_do1.v_fee_do_bscard_sum.sql.add('select SUBSTRING(CONVERT(char(15),开船日期,111),1,7) AS 月份,揽货人,原始币别,sum(原始金额) as 原始金额,sum(金额) as 金额 from v_fee_do_bscard ' +'where 工作编号=:申请编号 group by SUBSTRING(CONVERT(char(15),开船日期,111),1,7),揽货人,原始币别 ' +'order by 揽货人,SUBSTRING(CONVERT(char(15),开船日期,111),1,7),原始币别'); fra_ch_delete_do1.v_fee_do_bscard_sum.DataSource:=t_ch_invoice_shen1; fra_ch_delete_do1.v_fee_do_bscard_sum.Open; end else begin fra_ch_delete_do1.v_fee_do_seae.SQL.clear; fra_ch_delete_do1.v_fee_do_seae.sql.add('select * from v_fee_do_seae ' +'where 工作编号=:申请编号 order by 编号,费用名称'); fra_ch_delete_do1.v_fee_do_seae.DataSource:=t_ch_invoice_shen1; fra_ch_delete_do1.v_fee_do_seae.Open; fra_ch_delete_do1.v_fee_do_seai.SQL.clear; fra_ch_delete_do1.v_fee_do_seai.sql.add('select * from v_fee_do_seai ' +'where 工作编号=:申请编号 order by 编号,费用名称'); fra_ch_delete_do1.v_fee_do_seai.DataSource:=t_ch_invoice_shen1; fra_ch_delete_do1.v_fee_do_seai.Open; fra_ch_delete_do1.v_fee_do_aire.SQL.clear; fra_ch_delete_do1.v_fee_do_aire.sql.add('select * from v_fee_do_aire ' +'where 工作编号=:申请编号 order by 编号,费用名称'); fra_ch_delete_do1.v_fee_do_aire.DataSource:=t_ch_invoice_shen1; fra_ch_delete_do1.v_fee_do_aire.Open; fra_ch_delete_do1.v_fee_do_airi.SQL.clear; fra_ch_delete_do1.v_fee_do_airi.sql.add('select * from v_fee_do_airi ' +'where 工作编号=:申请编号 order by 编号,费用名称'); fra_ch_delete_do1.v_fee_do_airi.DataSource:=t_ch_invoice_shen1; fra_ch_delete_do1.v_fee_do_airi.Open; fra_ch_delete_do1.v_fee_do_seae_sum.SQL.clear; fra_ch_delete_do1.v_fee_do_seae_sum.sql.add('select SUBSTRING(CONVERT(char(15),开船日期,111),1,7) AS 月份,揽货人,原始币别,sum(原始金额) as 原始金额,sum(金额) as 金额 from v_fee_do_seae ' +'where 工作编号=:申请编号 group by SUBSTRING(CONVERT(char(15),开船日期,111),1,7),揽货人,原始币别 ' +'order by 揽货人,SUBSTRING(CONVERT(char(15),开船日期,111),1,7),原始币别'); fra_ch_delete_do1.v_fee_do_seae_sum.DataSource:=t_ch_invoice_shen1; fra_ch_delete_do1.v_fee_do_seae_sum.Open; fra_ch_delete_do1.v_fee_do_seai_sum.SQL.clear; fra_ch_delete_do1.v_fee_do_seai_sum.sql.add('select SUBSTRING(CONVERT(char(15),进口日期,111),1,7) AS 月份,揽货人,原始币别,sum(原始金额) as 原始金额,sum(金额) as 金额 from v_fee_do_seai ' +'where 工作编号=:申请编号 group by SUBSTRING(CONVERT(char(15),进口日期,111),1,7),揽货人,原始币别 ' +'order by 揽货人,SUBSTRING(CONVERT(char(15),进口日期,111),1,7),原始币别'); fra_ch_delete_do1.v_fee_do_seai_sum.DataSource:=t_ch_invoice_shen1; fra_ch_delete_do1.v_fee_do_seai_sum.Open; fra_ch_delete_do1.v_fee_do_aire_sum.SQL.clear; fra_ch_delete_do1.v_fee_do_aire_sum.sql.add('select SUBSTRING(CONVERT(char(15),开航日期,111),1,7) AS 月份,揽货人,原始币别,sum(原始金额) as 原始金额,sum(金额) as 金额 from v_fee_do_aire ' +'where 工作编号=:申请编号 group by SUBSTRING(CONVERT(char(15),开航日期,111),1,7),揽货人,原始币别 ' +'order by 揽货人,SUBSTRING(CONVERT(char(15),开航日期,111),1,7),原始币别'); fra_ch_delete_do1.v_fee_do_aire_sum.DataSource:=t_ch_invoice_shen1; fra_ch_delete_do1.v_fee_do_aire_sum.Open; fra_ch_delete_do1.v_fee_do_airi_sum.SQL.clear; fra_ch_delete_do1.v_fee_do_airi_sum.sql.add('select SUBSTRING(CONVERT(char(15),进口日期,111),1,7) AS 月份,揽货人,原始币别,sum(原始金额) as 原始金额,sum(金额) as 金额 from v_fee_do_airi ' +'where 工作编号=:申请编号 group by SUBSTRING(CONVERT(char(15),进口日期,111),1,7),揽货人,原始币别 ' +'order by 揽货人,SUBSTRING(CONVERT(char(15),进口日期,111),1,7),原始币别'); fra_ch_delete_do1.v_fee_do_airi_sum.DataSource:=t_ch_invoice_shen1; fra_ch_delete_do1.v_fee_do_airi_sum.Open; end; fra_ch_delete_do1.bs_text.Text:='7'; fra_ch_delete_do1.do_ban1.DataSet:=t_ch_invoice_shen; t_ch_invoice_shen.FieldByName('申请金额').OnChange:=t_ch_invoice_shenFieldChange; t_ch_invoice_shen.FieldByName('客户名称').OnChange:=t_ch_invoice_shenKHFieldChange; loadreggrid(dxdbgrid1,false,caption); frm_data_share.t_crm_client_all.requery; frm_data_share.t_code_currency.requery; end; procedure Tfrm_ch_invoice_shen.fra_ch_add_do1N1Click(Sender: TObject); begin fra_ch_add_do1.N1Click(Sender); end; procedure Tfrm_ch_invoice_shen.fra_ch_add_do1bsSkinButton11Click( Sender: TObject); begin fra_ch_add_do1.bsSkinButton11Click(Sender); end; procedure Tfrm_ch_invoice_shen.fra_ch_add_do1MenuItem1Click( Sender: TObject); begin fra_ch_add_do1.MenuItem1Click(Sender); end; procedure Tfrm_ch_invoice_shen.bsSkinButton15Click(Sender: TObject); var aAdoQuery:TAdoQuery; afield : variant; i: Integer; bsno:string; AmtRmb,UsdRmb:double; begin aAdoQuery:=CreateAdoQuery; with aAdoQuery do try Close;sql.Clear; sql.Add('select count(*) c'); sql.Add('From t_ch_fee_do'); sql.Add('where 工作编号=:bsno'); Parameters.ParamByName('bsno').Value:=t_ch_invoice_shen.FieldByName('申请编号').Value; open;First; if FieldByName('c').AsInteger<=0 then begin ShowMessage('不存在费用明细,不用拆分'); Exit; end; finally free; end; bsno:=t_ch_invoice_shen.FieldByName('申请编号').Value; AmtRmb:=t_ch_invoice_shen.FieldByName('人民币金额').AsFloat; UsdRmb:=t_ch_invoice_shen.FieldByName('美元金额').AsFloat; if (t_ch_invoice_shen.FieldByName('人民币金额').AsFloat<>0) and (t_ch_invoice_shen.FieldByName('美元金额').AsFloat<>0) then begin end else begin ShowMessage('本票不需要拆分申请'); Exit; end; try afield := vararraycreate([0,t_ch_invoice_shen.fieldcount-1],varvariant); for i := 0 to (t_ch_invoice_shen.fieldcount-1) do begin afield[i] :=t_ch_invoice_shen.fields[i].value ; end; t_ch_invoice_shen.insert; for i := 0 to (t_ch_invoice_shen.fieldcount-1) do begin if t_ch_invoice_shen.fields[i].FieldName<>'申请编号'then t_ch_invoice_shen.fields[i].value := afield[i] ; end; t_ch_invoice_shen['发票号码']:=''; t_ch_invoice_shen['申请状态']:='申请开票'; t_ch_invoice_shen['费用列表']:='代理海运费'; t_ch_invoice_shen['金额列表']:=t_ch_invoice_shen.FieldByName('美元金额').AsFloat; t_ch_invoice_shen['申请金额']:=t_ch_invoice_shen.FieldByName('美元金额').AsFloat; t_ch_invoice_shen['实际金额']:=t_ch_invoice_shen.FieldByName('美元金额').AsFloat; t_ch_invoice_shen['虚开金额']:=0; t_ch_invoice_shen['扣税金额']:=0; t_ch_invoice_shen['申请人']:=employee; t_ch_invoice_shen['申请日期']:=now; t_ch_invoice_shen['自动']:=1; t_ch_invoice_shen['审核人']:=''; t_ch_invoice_shen['审核日期']:=null; t_ch_invoice_shen['开出人']:=''; t_ch_invoice_shen['开出日期']:=null; t_ch_invoice_shen['申请原因']:=''; t_ch_invoice_shen['币别']:='USD'; t_ch_invoice_shen['人民币金额']:=0; // t_ch_invoice_shen['美元金额']:=0; t_ch_invoice_shen.Post; 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:=bsno; Parameters.ParamByName('bsno1').Value:=t_ch_invoice_shen.FieldByName('申请编号').Value; ExecSQL; finally free; end; t_ch_invoice_shen.Edit; t_ch_invoice_shen.Post; aAdoQuery:=CreateAdoQuery; with aAdoQuery do try Close;sql.Clear; sql.Add('Update t_ch_invoice_shen'); sql.Add('set 币别=''RMB'',费用列表=''代理海运费'',金额列表=:金额列表,申请金额=:申请金额,实际金额=:实际金额,人民币金额=:人民币金额,美元金额=0'); sql.Add('where 申请编号=:bsno'); Parameters.ParamByName('bsno').Value:=bsno; Parameters.ParamByName('金额列表').Value:=AmtRmb; Parameters.ParamByName('申请金额').Value:=AmtRmb; Parameters.ParamByName('实际金额').Value:=AmtRmb; Parameters.ParamByName('人民币金额').Value:=AmtRmb; ExecSQL; finally free; end; bsSkinNotebook1.PageIndex:=1; bsSkinPageControl2.ActivePage:=bsSkinTabSheet11; bsSkinButton11.Caption:='返回列表'; except if t_ch_invoice_shen.state=dsinsert then t_ch_invoice_shen.cancel; showmessage('复制添加失败!!'); end; end; procedure Tfrm_ch_invoice_shen.bsSkinButton13Click(Sender: TObject); begin if t_ch_invoice_shen1.DataSet=nil then exit; if not t_ch_invoice_shen1.DataSet.Bof then t_ch_invoice_shen1.DataSet.Prior; end; procedure Tfrm_ch_invoice_shen.bsSkinButton14Click(Sender: TObject); begin if t_ch_invoice_shen1.DataSet=nil then exit; if not t_ch_invoice_shen1.DataSet.eof then t_ch_invoice_shen1.DataSet.next; end; procedure Tfrm_ch_invoice_shen.bsSkinButton37Click(Sender: TObject); begin if t_ch_invoice_shen.IsEmpty then exit; if t_ch_invoice_shen.FieldByName('对帐编号').AsString='' then exit; t_ch_invoice_expitem.Close; t_ch_invoice_expitem.Open; if t_ch_invoice_expitem.RecordCount=0 then begin application.MessageBox('不存在发票单开明细!','警告:',MB_OKCANCEL); t_ch_invoice_expitem.Close; exit; end; t_ch_invoice_expitem.Close; try frm_ch_invoice_expitems:=tfrm_ch_invoice_expitems.Create (application); invduino:=t_ch_invoice_shen.fieldbyname('对帐编号').asstring; frm_ch_invoice_expitems.ShowModal; finally frm_ch_invoice_expitems.Free; end; end; end.