- 保险支付查询delphi
unit Unit_V_Payment; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Unit_Child_Template_Modal, DBGridEhGrouping, GridsEh, DBGridEh, StdCtrls, ComCtrls,DB,ADODB; type TForm_V_Payment = class(TForm_Child_Template_Modal) Label1: TLabel; Label2: TLabel; dtp_SDate: TDateTimePicker; dtp_EDate: TDateTimePicker; cbb_Dept_No: TComboBox; cbb_Dept_Name: TComboBox; btn_Query: TButton; dbgrdh_Payment_Info: TDBGridEh; btn_Close: TButton; procedure FormCreate(Sender: TObject); procedure cbb_Dept_NoChange(Sender: TObject); procedure cbb_Dept_NameChange(Sender: TObject); procedure btn_CloseClick(Sender: TObject); procedure btn_QueryClick(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form_V_Payment: TForm_V_Payment; qry_V_Payment: TADOQuery; ds_V_Payment: TDataSource; implementation uses Unit_Main,Unit_Public_Funciton,Unit_Public_Variable; {$R *.dfm} procedure TForm_V_Payment.FormCreate(Sender: TObject); begin inherited; dtp_SDate.Date := Now; dtp_EDate.Date := Now; str_Temp := 'select dept_no,dept_name from ' + str_DB_Name + '.dbo.tk_dept_info where dept_no in (' + str_Current_Role_Dept_List + ') order by dept_no'; Form_Main.aTCPAdoClient_Main.Open(str_Temp); while not Form_Main.aTCPAdoClient_Main.Eof do begin cbb_Dept_No.Items.Add(Form_Main.aTCPAdoClient_Main.FieldByName('dept_no').Text); cbb_Dept_Name.Items.Add(Form_Main.aTCPAdoClient_Main.FieldByName('dept_name').Text); Form_Main.aTCPAdoClient_Main.Next; end; cbb_Dept_No.ItemIndex := 0; cbb_Dept_Name.ItemIndex := 0; qry_V_Payment := TADOQuery.Create(Self); ds_V_Payment := TDataSource.Create(Self); ds_V_Payment.DataSet := qry_V_Payment; dbgrdh_Payment_Info.Columns[0].Width := 160; dbgrdh_Payment_Info.Columns[1].Width := 100; dbgrdh_Payment_Info.Columns[2].Width := 140; dbgrdh_Payment_Info.Columns[3].Width := 100; dbgrdh_Payment_Info.Columns[4].Width := 80; dbgrdh_Payment_Info.Columns[5].Width := 80; end; procedure TForm_V_Payment.cbb_Dept_NoChange(Sender: TObject); begin inherited; cbb_Dept_Name.ItemIndex := cbb_Dept_No.ItemIndex; end; procedure TForm_V_Payment.cbb_Dept_NameChange(Sender: TObject); begin inherited; cbb_Dept_No.ItemIndex := cbb_Dept_Name.ItemIndex; end; procedure TForm_V_Payment.btn_CloseClick(Sender: TObject); begin inherited; Close; end; procedure TForm_V_Payment.btn_QueryClick(Sender: TObject); begin inherited; if dtp_SDate.Date > dtp_EDate.Date then begin Msg('支付起始日期不能晚于结束日期!'); Exit; end; str_Temp := 'select b.insu_no,a.BEGIN_TIME,a.END_TIME,b.pay_time,b.pay_money,c.LICENSE from ' + str_DB_Name; str_Temp := str_Temp + '.dbo.TK_BUS_INSURER a INNER JOIN ' + str_DB_Name + '.dbo.TK_INSURER_PAYMENT b'; str_Temp := str_Temp + ' ON a.INSU_NO = b.INSU_NO LEFT OUTER JOIN ' + str_DB_Name + '.dbo.TK_BUS_INFO c '; str_Temp := str_Temp + 'on a.BUS_NO = c.BUS_NO WHERE A.DEPT_NO='+ cbb_Dept_No.Text + ' AND b.PAY_TIME BETWEEN '''; str_Temp := str_Temp + DateTimeToStr(dtp_SDate.DateTime) + ''' AND ''' + DateTimeToStr(dtp_EDate.DateTime) + ''''; Form_Main.aTCPAdoClient_Main.Open(str_Temp); qry_V_Payment.Clone(Form_Main.aTCPAdoClient_Main,ltReadOnly); dbgrdh_Payment_Info.DataSource := ds_V_Payment; end; end.