📄 thmsunit.pas
字号:
unit thmsUnit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, GridsEh, DBGridEh, StdCtrls, Buttons, ExtCtrls, PrnDbgeh,prvieweh,printers,DBGridEHImpExp;
type
TthmsForm = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
Label1: TLabel;
ComboBox1: TComboBox;
BitBtn2: TBitBtn;
BitBtn1: TBitBtn;
BitBtn3: TBitBtn;
BitBtn4: TBitBtn;
DBGridEh1: TDBGridEh;
PrintDBGridEh1: TPrintDBGridEh;
SaveDialog1: TSaveDialog;
procedure lemsNewll;
procedure lemsQxnewll;
procedure combobox1change(Sender: TObject);
procedure thmsformcreate(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn4Click(Sender: TObject);
procedure BitBtn3Click(Sender: TObject);
private
{ Private declarations }
bm,dbegin,dend:string;
public
{ Public declarations }
end;
var
thmsForm: TthmsForm;
implementation
uses dm,thqsunit, GrqxUnit;
{$R *.dfm}
procedure TthmsForm.lemsNewll;
begin
combobox1.Items.Add('全部');
dmdata.BjqlADOTable.Active:=false;
dmdata.BjqlADOTable.Active:=true;
dmdata.BjqlADOTable.First;
while not dmdata.BjqlADOTable.eof do
begin
combobox1.Items.Add(dmdata.BjqlADOTable['QL']);
dmdata.BjqlADOTable.Next;
end;
combobox1.ItemIndex:=0;
end;
procedure TthmsForm.lemsQxnewll;
begin
if bm = '全部' then
begin
if combobox1.Text = '全部' then
begin
with dmdata.leQxADOQuery do
begin
close;
sql.Clear;
sql.Add('select a.id,a.ql_id,a.rq,a.sl,a.qxhm,a.jxhm,a.lybm,a.qt,a.jbr,a.jjr,b.ql from t_ms_jl as a,t_bjql as b where (a.ql_id=b.km)and(qt=5)and(RQ >=:a)and(rq <=:b) order by a.id');
parameters.ParamByName('a').Value:=strtodate(dbegin);
parameters.ParamByName('b').Value:=strtodate(dend);
open;
end;
end
else
begin
with dmdata.bjqladoquery do
begin
close;
sql.Clear;
sql.Add('select * from T_Bjql where (QL = :a)');
parameters.ParamByName('a').Value:=trim(combobox1.Text);
open;
end;
with dmdata.leQxADOQuery do
begin
close;
sql.Clear;
sql.Add('select a.id,a.ql_id,a.rq,a.sl,a.qxhm,a.jxhm,a.lybm,a.qt,a.jbr,a.jjr,b.ql from t_ms_jl as a,t_bjql as b where (a.ql_id=b.km)and (qt=5)and(RQ >=:a)and(rq <=:b)and (ql_id = :c) order by a.id');
parameters.ParamByName('a').Value:=strtodate(dbegin);
parameters.ParamByName('b').Value:=strtodate(dend);
parameters.ParamByName('c').Value:=dmdata.bjqladoquery.fieldbyname('km').AsString;
open;
end;
end;
end
else
begin
if combobox1.Text = '全部' then
begin
with dmdata.BmADOQuery do
begin
close;
sql.Clear;
sql.Add('select * from T_bm where (dwbm = :a)');
parameters.ParamByName('a').Value:=trim(bm);
open;
end;
with dmdata.leQxADOQuery do
begin
close;
sql.Clear;
sql.Add('select a.id,a.ql_id,a.rq,a.sl,a.qxhm,a.jxhm,a.lybm,a.qt,a.jbr,a.jjr,b.ql from t_ms_jl as a,t_bjql as b where (a.ql_id=b.km)and (qt=5)and(RQ >=:a)and(rq <=:b)and(lybm = :c) order by a.id');
parameters.ParamByName('a').Value:=strtodate(dbegin);
parameters.ParamByName('b').Value:=strtodate(dend);
parameters.ParamByName('c').Value:=dmdata.bmadoquery.fieldbyname('km').AsString;
open;
end;
end
else
begin
with dmdata.BmADOQuery do
begin
close;
sql.Clear;
sql.Add('select * from T_bm where (dwbm = :a)');
parameters.ParamByName('a').Value:=trim(bm);
open;
end;
with dmdata.bjqladoquery do
begin
close;
sql.Clear;
sql.Add('select * from T_Bjql where (QL = :a)');
parameters.ParamByName('a').Value:=trim(combobox1.Text);
open;
end;
with dmdata.leQxADOQuery do
begin
close;
sql.Clear;
sql.Add('select a.id,a.ql_id,a.rq,a.sl,a.qxhm,a.jxhm,a.lybm,a.qt,a.jbr,a.jjr,b.ql from t_ms_jl as a,t_bjql as b where (a.ql_id=b.km)and (qt=5)and(RQ >=:a)and(rq <=:b)and (ql_id = :c)and(lybm=:d) order by a.id');
parameters.ParamByName('a').Value:=strtodate(dbegin);
parameters.ParamByName('b').Value:=strtodate(dend);
parameters.ParamByName('c').Value:=dmdata.bjqladoquery.fieldbyname('km').AsString;
parameters.ParamByName('d').Value:=dmdata.BmADOQuery.fieldbyname('km').AsString;
open;
end;
end;
end;
end;
procedure TthmsForm.combobox1change(Sender: TObject);
begin
lemsQxnewll;
end;
procedure TthmsForm.thmsformcreate(Sender: TObject);
var
yy,mm,dd:word;
begin
bm:=trim(thqsform.ComboBox1.Text);
dbegin:=trim(thqsform.ComboBox2.Text);
dend:=trim(thqsform.ComboBox3.Text);
lemsNewll;
lemsQxnewll;
decodedate(dmdata.ADOTable_T_user.fieldbyname('date').AsDateTime,yy,mm,dd);
printdbgrideh1.PageHeader.CenterText.Add(dmdata.ADOTable_T_user.fieldbyname('dh').AsString);
printdbgrideh1.Title.Add('票据退回查询'+' — '+bm);
printdbgrideh1.PageFooter.RightText.Add('制表人:'+dmdata.ADOTable_T_user.fieldbyname('name').AsString+' 打印日期:'+DateToStr(Now));
printdbgrideh1.PageFooter.CenterText.add('第&[Page]页 共&[Pages]页');
printdbgrideh1.PageFooter.LeftText.Add('查询日期:'+'('+dbegin+' — '+dend+')');
Caption:=Caption+' - '+thqsform.ComboBox1.Text;
thqsform.Close;
end;
procedure TthmsForm.BitBtn1Click(Sender: TObject);
begin
printerpreview.Orientation:=poLandscape;
printdbgrideh1.Preview;
end;
procedure TthmsForm.BitBtn2Click(Sender: TObject);
begin
if printdbgrideh1.PrinterSetupDialog = true then
printdbgrideh1.Print;
end;
procedure TthmsForm.BitBtn4Click(Sender: TObject);
begin
close;
end;
procedure TthmsForm.BitBtn3Click(Sender: TObject);
var
ExpClass:TDBGridEhExportClass;
Ext:String;
begin
SaveDialog1.FileName :='file1';
//if (ActiveControl is TDBGridEH) then
if saveDialog1.Execute then
begin
case SaveDialog1.FilterIndex of
1: begin ExpClass := TDBGridEhExportAsText; Ext := 'txt'; end;
2: begin ExpClass := TDBGridEhExportAsCSV; Ext := 'csv'; end;
3: begin ExpClass := TDBGridEhExportAsHTML; Ext := 'htm'; end;
4: begin ExpClass := TDBGridEhExportAsRTF; Ext := 'rtf'; end;
5: begin ExpClass := TDBGridEhExportAsXLS; Ext := 'xls'; end;
else
ExpClass := nil; Ext := '';
end;
if ExpClass <> nil then
begin
if UpperCase(Copy(SaveDialog1.FileName,Length(SaveDialog1.FileName)-2,3)) <> UpperCase(Ext) then
SaveDialog1.FileName := SaveDialog1.FileName+'.'+Ext;
SaveDBGridEhToExportFile(ExpClass,DBGridEh1,SaveDialog1.FileName,true);
end;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -