📄 zfsfcx.pas
字号:
unit ZfSfcx;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, Grids, DBGrids, StdCtrls, Buttons, ComCtrls, ExtCtrls;
type
TZfSfcxForm = class(TForm)
DS_Zjgl: TDataSource;
ADQ_Zjgl: TADOQuery;
Panel1: TPanel;
DBGrid1: TDBGrid;
Panel2: TPanel;
Com_first: TComboBox;
Lbl_query_term: TLabel;
Com_term: TComboBox;
DateTP: TDateTimePicker;
Com_result: TComboBox;
BitBtn_find: TBitBtn;
bitbtn_quit: TBitBtn;
BBtn_Ok: TBitBtn;
BBtn_Print: TBitBtn;
fieldname: TComboBox;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure bitbtn_quitClick(Sender: TObject);
procedure BBtn_OkClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure BitBtn_findClick(Sender: TObject);
procedure Com_firstChange(Sender: TObject);
procedure BBtn_PrintClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
ZfSfcxForm: TZfSfcxForm;
implementation
uses ZfSfGjcx, Cbreport, Unit_common_files,DateUtils;
{$R *.dfm}
procedure TZfSfcxForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action :=cafree;
ZfSfcxForm:=nil;
end;
procedure TZfSfcxForm.bitbtn_quitClick(Sender: TObject);
begin
close;
end;
procedure TZfSfcxForm.BBtn_OkClick(Sender: TObject);
var
lop,f_count:integer;
begin
ZfSfGjcxForm:= TZfSfGjcxForm.create(nil);
try
if not ADQ_Zjgl.Active then ADQ_Zjgl.Open;
f_count := DBGrid1.columns.Count;
for lop := 0 to f_count -1 do
begin
fieldname.Items.Add(DBGrid1.columns[lop].FieldName);
ZfSfGjcxForm.Com_jl.Items.Add(DBGrid1.columns[lop].Title.Caption);
end;
ZfSfGjcxForm.fieldname.items.Assign(fieldname.items);
if ZfSfGjcxForm.ShowModal = mryes then
begin
ADQ_Zjgl.Close;
ADQ_Zjgl.SQL.Clear;
ADQ_Zjgl.SQL.Add('SELECT A.id,A.fangno, A.manid, B.manname, A.Jkrq, A.fangya,');
ADQ_Zjgl.SQL.Add('A.fangprice, A.Ljf, A.Yf,A.sf, A.begindate, A.enddate, ');
ADQ_Zjgl.SQL.Add('case A.status when ''1'' then ''已交款'' else ''未交款'' end as status ');
ADQ_Zjgl.SQL.Add('FROM dbo.Zf_Zujin A INNER JOIN dbo.Zf_Man B ON A.manid = B.manid');
ADQ_Zjgl.SQL.Add(ZfSfGjcxForm.returnstr);
ADQ_Zjgl.Open;
end;
finally
ZfSfGjcxForm.Free;
end;
end;
procedure TZfSfcxForm.FormCreate(Sender: TObject);
var
lop,f_count:integer;
begin
DateTP.Date :=date();
if not ADQ_Zjgl.Active then ADQ_Zjgl.Open;
f_count := DBGrid1.columns.Count;
for lop := 0 to f_count -1 do
begin
fieldname.Items.Add(DBGrid1.columns[lop].FieldName);
Com_first.Items.Add(DBGrid1.columns[lop].Title.Caption);
end;
end;
procedure TZfSfcxForm.BitBtn_findClick(Sender: TObject);
var
f_name,Filterstr:string;
f_value:Variant;
begin
if (Com_first.Text='') or (Com_term.Text='') then exit;
f_name := fieldname.Items.Strings[Com_first.Items.IndexOf(Com_first.Text)];
case ADQ_Zjgl.FieldByName(f_name).DataType of
ftString,ftFloat:f_value := Com_result.Text;
ftdatetime:f_value := datetostr(DateTP.Date);
end;
Filterstr := 'SELECT A.id,A.fangno, A.manid, B.manname, A.Jkrq, A.fangya,'
+' A.fangprice, A.Ljf,A.Yf,A.sf, A.begindate, A.enddate,'
+'case A.status when ''1'' then ''已交款'' else ''未交款'' end as status '
+' FROM dbo.Zf_Zujin A INNER JOIN dbo.Zf_Man B ON A.manid = B.manid where '
+'' + f_name + ' ' + Com_term.Text + ' ''' + f_value + '''';
ADQ_Zjgl.close;
ADQ_Zjgl.SQL.Clear;
ADQ_Zjgl.SQL.Add(filterstr);
ADQ_Zjgl.Open;
end;
procedure TZfSfcxForm.Com_firstChange(Sender: TObject);
begin
Com_result.Visible := false;
DateTP.Visible := false;
case ADQ_Zjgl.FieldByName(fieldname.Items.Strings[Com_first.Items.IndexOf(Com_first.Text)]).DataType of
ftString,ftFloat:Com_result.Visible := true;
ftDateTime:DateTP.Visible := true;
end;
end;
procedure TZfSfcxForm.BBtn_PrintClick(Sender: TObject);
begin
if ADQ_Zjgl.IsEmpty then
begin
messagebox(0,'请查询后再打印!','余科华提示',MB_OK+MB_ICONWARNING);
exit;
end
else
begin
BbForm_report:=TBbForm_report.Create(nil);
try
BbForm_report.QRL_SKr.Caption:=CurrentUserName;
BbForm_report.QRL_Yf.Caption:=inttostr(yearof(date))+'年'+inttostr(monthof(date))+'月';
BbForm_report.QRL_Dyrq.Caption:=inttostr(yearof(date))+'年'+inttostr(monthof(date))+'月'+inttostr(dayof(date))+'日';
BbForm_report.Fz_report.Preview ;
finally
BbForm_report.Free ;
end;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -