📄 unitprtchuxuan.pas.~65~
字号:
unit UnitprtChuxuan;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, frxClass, frxIBXComponents, frxDBSet, frxExportRTF;
type
TfmprtChuxuan = class(TForm)
BitBtn1: TBitBtn;
frxDBDataset1: TfrxDBDataset;
frxIBXComponents1: TfrxIBXComponents;
ListBox1: TListBox;
frxReport1: TfrxReport;
frxRTFExport1: TfrxRTFExport;
procedure FormShow(Sender: TObject);
function frxReport1UserFunction(const MethodName: string;
var Params: Variant): Variant;
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
function getSpecialty(s_code:String):String;//查询专业代码所对应的学校
function GetSchool(bmh:String):String;//获取学校名称
end;
implementation
uses unitDatamodule;
{$R *.dfm}
procedure TfmprtChuxuan.BitBtn1Click(Sender: TObject);
begin
dm.Query1.Transaction.Active:=false;
dm.Query1.Transaction.StartTransaction;
dm.Query1.Close;
if ListBox1.Items[ListBox1.ItemIndex]='五年专艺术类' then
begin
dm.Query1.SQL.Text:='select lqzy,bmh,stdname,sex,birth,school,total,tdf,bxzgf,tyzgf,yx'+
' from student where lqzy='''+copy(ListBox1.Items[ListBox1.itemindex],2,5)+''''+
' order by lqzy asc,tdf desc,yx desc';
end
else if ListBox1.Items[ListBox1.ItemIndex]='五年专' then
begin
end
else if ListBox1.Items[ListBox1.ItemIndex]='中志类' then
begin
end
else
begin
dm.Query1.SQL.Text:='select lqzy,bmh,stdname,sex,birth,school,total,tdf,bxzgf,tyzgf,yx'+
' from student where lqzy='''+copy(ListBox1.Items[ListBox1.itemindex],2,5)+''''+
' order by lqzy asc,tdf desc,yx desc';
end
dm.Query1.Open;
frxReport1.PrepareReport();
frxReport1.ShowReport();
end;
function TfmprtChuxuan.getSpecialty(s_code: String): String;
begin
// dm.Query2.Transaction.Active:=false;
dm.Query2.Close;
dm.Query2.SQL.Text:='select specialty from zhaoshengcode where s_code='''+s_code+'''';
dm.Query2.Open;
result:=dm.Query2.FieldByName('specialty').AsString;
end;
function TfmprtChuxuan.frxReport1UserFunction(const MethodName: string;
var Params: Variant): Variant;
begin
if MethodName='GETSPECIALTY' then
result:=GetSpecialty(params[0])
else if MethodName='GETSCHOOL' then
result:=GetSchool(Params[0])
end;
procedure TfmprtChuxuan.FormShow(Sender: TObject);
begin
frxReport1.AddFunction('function GetSpecialty(s_code:String):string');
frxReport1.AddFunction('function GetSchool(bmh:String):String');
dm.Query1.Transaction.Active:=false;
dm.Query1.Close;
dm.Query1.SQL.Text:='select specialty,s_code from zhaoshengcode order by s_code';
dm.Query1.Open;
Listbox1.Items.Clear;
dm.Query1.First;
while not dm.Query1.Eof do
begin
listbox1.Items.Add('('+dm.Query1.FieldByName('s_code').AsString+
')'+dm.Query1.FieldByName('specialty').AsString);
dm.Query1.Next;
end;
listBox1.Items.Add('五年专艺术类');
listBox1.Items.Add('五年专');
listBox1.Items.Add('中志类')
if ListBox1.Count>0 then
Listbox1.ItemIndex:=0;
end;
function TfmprtChuxuan.GetSchool(bmh: String): String;
begin
// dm.Query2.Transaction.Active:=false;
dm.Query2.Close;
dm.Query2.SQL.Text:='select schname from school where schorder='''+copy(bmh,1,4)+'''';
dm.Query2.Open;
result:=dm.Query2.FieldByName('schname').AsString;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -