unit u_ch_cust_befbal; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, RxLookup, StdCtrls, bsSkinCtrls, BusinessSkinForm, dxExEdtr, DBCtrls, Grids, Wwdbigrd, Wwdbgrid, bsdbctrls, wwdblook, wwdbdatetimepicker, Mask, wwdbedit, Wwdotdot, Wwdbcomb, dxDBTLCl, dxGrClms, dxDBCtrl, dxDBGrid, dxTL, dxCntner, ComCtrls, bsSkinTabs, ExtCtrls, DB, ADODB, Menus; type Tfrm_ch_cust_befbal = class(TForm) bsBusinessSkinForm1: TbsBusinessSkinForm; Panel2: TPanel; bsSkinButton9: TbsSkinButton; bsSkinButton1: TbsSkinButton; bsSkinButton2: TbsSkinButton; bsSkinButton4: TbsSkinButton; bsSkinButton3: TbsSkinButton; bsSkinButton5: TbsSkinButton; bsSkinButton38: TbsSkinButton; bsSkinPageControl1: TbsSkinPageControl; bsSkinTabSheet1: TbsSkinTabSheet; bsSkinPanel4: TbsSkinPanel; dxDBGrid1: TdxDBGrid; dxDBGrid1Column10: TdxDBGridColumn; dxDBGrid1Column9: TdxDBGridColumn; dxDBGrid1Column1: TdxDBGridMaskColumn; dxDBGrid1Column14: TdxDBGridColumn; dxDBGrid1Column2: TdxDBGridMaskColumn; dxDBGrid1Column114: TdxDBGridColumn; dxDBGrid1Column3: TdxDBGridMaskColumn; dxDBGrid1Column13: TdxDBGridColumn; dxDBGrid1Column32: TdxDBGridColumn; bsSkinPanel3: TbsSkinPanel; Label39: TLabel; Label9: TLabel; Label3: TLabel; Label7: TLabel; wwDBComboBox44: TwwDBComboBox; RxDBLookupCombo2: TRxDBLookupCombo; wwDBDateTimePicker5: TwwDBDateTimePicker; wwDBDateTimePicker6: TwwDBDateTimePicker; bsSkinButton10: TbsSkinButton; bsSkinTabSheet2: TbsSkinTabSheet; t_ch_cust_befbal1: TDataSource; t_ch_cust_befbal: TADOQuery; dxDBGrid1Column11: TdxDBGridColumn; dxDBGrid1Column12: TdxDBGridColumn; dxDBGrid1Column15: TdxDBGridColumn; dxDBGrid1Column16: TdxDBGridColumn; dxDBGrid1Column17: TdxDBGridColumn; Label25: TLabel; DBEdit14: TDBEdit; RxDBLookupCombo1: TRxDBLookupCombo; Label12: TLabel; Label1: TLabel; wwDBComboBox1: TwwDBComboBox; Label2: TLabel; RxDBLookupCombo3: TRxDBLookupCombo; DBEdit4: TDBEdit; Label4: TLabel; Label6: TLabel; RxDBLookupCombo4: TRxDBLookupCombo; RxDBLookupCombo17: TRxDBLookupCombo; DBEdit9: TDBEdit; Label8: TLabel; Label5: TLabel; wwDBDateTimePicker1: TwwDBDateTimePicker; DBMemo1: TDBMemo; Label10: TLabel; Label11: TLabel; DBEdit1: TDBEdit; Label13: TLabel; DBEdit2: TDBEdit; Label14: TLabel; wwDBDateTimePicker2: TwwDBDateTimePicker; bsSkinButton6: TbsSkinButton; bsSkinButton8: TbsSkinButton; Label15: TLabel; DBEdit3: TDBEdit; Label16: TLabel; RxDBLookupCombo5: TRxDBLookupCombo; dxDBGrid1Column18: TdxDBGridColumn; dxDBGrid1Column19: TdxDBGridColumn; Label17: TLabel; wwDBComboBox2: TwwDBComboBox; dxDBGrid1Column20: TdxDBGridColumn; dxDBGrid1Column21: TdxDBGridColumn; PopupMenu2: TPopupMenu; MenuItem4: TMenuItem; MenuItem5: TMenuItem; N21: TMenuItem; N22: TMenuItem; N20: TMenuItem; Label18: TLabel; DBEdit5: TDBEdit; dxDBGrid1Column22: TdxDBGridColumn; procedure bsSkinButton2Click(Sender: TObject); procedure t_ch_cust_befbalAfterInsert(DataSet: TDataSet); procedure t_ch_cust_befbalBeforeEdit(DataSet: TDataSet); procedure bsSkinButton1Click(Sender: TObject); procedure bsSkinButton4Click(Sender: TObject); procedure bsSkinButton3Click(Sender: TObject); procedure bsSkinButton38Click(Sender: TObject); procedure bsSkinButton6Click(Sender: TObject); procedure bsSkinButton8Click(Sender: TObject); procedure RxDBLookupCombo4Change(Sender: TObject); procedure FormShow(Sender: TObject); procedure bsSkinButton10Click(Sender: TObject); procedure bsSkinButton5Click(Sender: TObject); procedure t_ch_cust_befbalBeforePost(DataSet: TDataSet); procedure dxDBGrid1DblClick(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure bsSkinButton9Click(Sender: TObject); procedure N20Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var frm_ch_cust_befbal: Tfrm_ch_cust_befbal; implementation uses u_main, u_data_share, my_sys_function, u_sys_progress; {$R *.dfm} procedure Tfrm_ch_cust_befbal.bsSkinButton2Click(Sender: TObject); begin table_post(t_ch_cust_befbal); end; procedure Tfrm_ch_cust_befbal.t_ch_cust_befbalAfterInsert( DataSet: TDataSet); begin t_ch_cust_befbal['状态']:='录入状态'; t_ch_cust_befbal['方式']:='手动录入'; t_ch_cust_befbal['类型']:='收'; t_ch_cust_befbal['录入人']:=employee; t_ch_cust_befbal['录入日期']:=date; t_ch_cust_befbal['收付单号']:=get_no(date,'BD');; end; procedure Tfrm_ch_cust_befbal.t_ch_cust_befbalBeforeEdit( DataSet: TDataSet); var aQuery:TAdoQuery; begin if not modify_all then begin if t_ch_cust_befbal.FieldByName('方式').AsString<>'手动录入' then begin showmessage('只有手动录入的才能够删除'); abort; end; if t_ch_cust_befbal.FieldByName('状态').AsString<>'录入状态' then begin showmessage('只有录入状态的才能够删除'); abort; end; end; if (t_ch_cust_befbal.FieldByName('方式').AsString='手动录入') and (t_ch_cust_befbal.FieldByName('收付单号').AsString<>'') then begin aQuery:=CreateAdoQuery; try with aQuery do begin close;sql.Clear; sql.Add('select count(*) as ct from t_ch_cust_befbal where BFID<>'+t_ch_cust_befbal.FieldByName('BFID').AsString+' and 收付单号='''+t_ch_cust_befbal.FieldByName('收付单号').AsString+''''); open; if fieldbyname('ct').AsInteger<>0 then begin showmessage('已经用此费用结算不能修改或删除!'); abort; end; end; finally freeandnil(aQuery); end; end; end; procedure Tfrm_ch_cust_befbal.bsSkinButton1Click(Sender: TObject); begin t_ch_cust_befbal.Insert; bsSkinPageControl1.ActivePageIndex:=1; end; procedure Tfrm_ch_cust_befbal.bsSkinButton4Click(Sender: TObject); begin table_delete(t_ch_cust_befbal); end; procedure Tfrm_ch_cust_befbal.bsSkinButton3Click(Sender: TObject); begin table_cancel(t_ch_cust_befbal); end; procedure Tfrm_ch_cust_befbal.bsSkinButton38Click(Sender: TObject); var book1:Tbookmark; begin book1:=t_ch_cust_befbal.GetBookmark; t_ch_cust_befbal.Requery; t_ch_cust_befbal.GotoBookmark(book1); end; procedure Tfrm_ch_cust_befbal.bsSkinButton6Click(Sender: TObject); begin if t_ch_cust_befbal.FieldByName('状态').asstring='审核通过'then begin showmessage('已经审核!!'); end else begin try t_ch_cust_befbal.Refresh; modify_all:=true; t_ch_cust_befbal.edit; t_ch_cust_befbal['状态']:='审核通过'; t_ch_cust_befbal['审核人']:=employee; t_ch_cust_befbal['审核日期']:=date; t_ch_cust_befbal.post; modify_all:=false; except modify_all:=false; showmessage('审核失败!!'); end; t_ch_cust_befbal.Refresh; end; end; procedure Tfrm_ch_cust_befbal.bsSkinButton8Click(Sender: TObject); begin if t_ch_cust_befbal.FieldByName('状态').asstring='录入状态'then begin showmessage('没有必要取消审核!!'); end else begin try modify_all:=true; t_ch_cust_befbal.edit; t_ch_cust_befbal['状态']:='录入状态'; t_ch_cust_befbal['审核人']:=''; t_ch_cust_befbal['审核日期']:=null; t_ch_cust_befbal.post; modify_all:=false; except modify_all:=false; showmessage('审核失败!!'); end; t_ch_cust_befbal.Refresh; end; end; procedure Tfrm_ch_cust_befbal.RxDBLookupCombo4Change(Sender: TObject); begin if not frm_data_share.t_sys_bank.IsEmpty then if frm_data_share.t_sys_bank.Locate('代码',RxDBLookupCombo4.DisplayValues[0],[])then begin t_ch_cust_befbal['银行']:=frm_data_share.t_sys_bank.fieldbyname('银行名称').asstring; end else begin t_ch_cust_befbal['银行']:=''; end; end; procedure Tfrm_ch_cust_befbal.FormShow(Sender: TObject); begin if not ASSIGNED(frm_sys_progress) then frm_sys_progress:=tfrm_sys_progress.Create(self); frm_sys_progress.bsSkinGauge1.ProgressText:='加载数据请等候。。。'; frm_sys_progress.Show; frm_sys_progress.bsSkinGauge1.MaxValue:=1; frm_sys_progress.bsSkinGauge1.MinValue:=0; frm_sys_progress.bsSkinGauge1.Value:=0; frm_sys_progress.Update; t_ch_cust_befbal.Close; t_ch_cust_befbal.SQL.clear; t_ch_cust_befbal.SQL.Add('select * from t_ch_cust_befbal where 状态=''录入状态'' and ' +open_data('1003','录入人','no','no','no','no') +' order by 录入日期'); t_ch_cust_befbal.open; loadreggrid(dxdbgrid1,false,caption); frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; frm_sys_progress.close; frm_sys_progress:=nil; end; procedure Tfrm_ch_cust_befbal.bsSkinButton10Click(Sender: TObject); var str:string; begin str:=' and '+open_data('1003','录入人','no','no','no','no'); if wwDBComboBox44.text<>''then str:=str+' and 状态='+''''+wwDBComboBox44.text+''''; if RxDBLookupCombo2.DisplayValues[1]<>''then str:=str+' and 客户名称='+''''+RxDBLookupCombo2.DisplayValues[1]+''''; if wwDBDateTimePicker5.text<>''then str:=str+' and 录入日期>='+''''+wwDBDateTimePicker5.text+''''; if wwDBDateTimePicker6.text<>''then str:=str+' and 录入日期<='+''''+wwDBDateTimePicker6.text+''''; t_ch_cust_befbal.Close; t_ch_cust_befbal.SQL.clear; t_ch_cust_befbal.SQL.Add('select * from t_ch_cust_befbal where 1=1 ' +str +' order by 客户名称,录入日期'); t_ch_cust_befbal.open; end; procedure Tfrm_ch_cust_befbal.bsSkinButton5Click(Sender: TObject); begin close; end; procedure Tfrm_ch_cust_befbal.t_ch_cust_befbalBeforePost( DataSet: TDataSet); begin table_before_post(t_ch_cust_befbal,'客户名称'); table_before_post(t_ch_cust_befbal,'币别'); table_before_post(t_ch_cust_befbal,'类型'); end; procedure Tfrm_ch_cust_befbal.dxDBGrid1DblClick(Sender: TObject); begin bsSkinPageControl1.ActivePageIndex:=1; end; procedure Tfrm_ch_cust_befbal.FormClose(Sender: TObject; var Action: TCloseAction); begin savereggrid(dxdbgrid1,caption); frm_ch_cust_befbal.Hide; frm_ch_cust_befbal.ManualFloat(frm_ch_cust_befbal.BoundsRect ); frm_main.freeTabs('frm_ch_cust_befbal'); action:=cafree; frm_ch_cust_befbal:=nil; end; procedure Tfrm_ch_cust_befbal.bsSkinButton9Click(Sender: TObject); var Pnt:Tpoint; begin Pnt:=bsSkinButton9.ClientToScreen(Point(0,bsSkinButton9.Height)); PopupMenu2.Popup(Pnt.x,Pnt.y); end; procedure Tfrm_ch_cust_befbal.N20Click(Sender: TObject); begin sys_print('客户预收预付',TMenuItem(Sender).tag,t_ch_cust_befbal1,nil,nil,nil,nil,NIL,NIL,NIL,nil,nil,nil); end; end.