📄 u_reward.pas
字号:
unit u_reward;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, DBCtrls, Mask, Buttons, DB, ADODB;
type
Tf_reward = class(TForm)
StaticText1: TStaticText;
RadioGroup1: TRadioGroup;
StaticText2: TStaticText;
Button2: TButton;
Button1: TButton;
Memo1: TMemo;
Edit1: TEdit;
GroupBox1: TGroupBox;
StaticText3: TStaticText;
StaticText4: TStaticText;
StaticText5: TStaticText;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
BitBtn1: TBitBtn;
ADOQuery1: TADOQuery;
ComboBox1: TComboBox;
ComboBox2: TComboBox;
ComboBox3: TComboBox;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label1: TLabel;
procedure BitBtn1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
f_reward: Tf_reward;
implementation
{$R *.dfm}
procedure Tf_reward.BitBtn1Click(Sender: TObject);
begin
if edit1.Text<>'' then
begin
try
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('select * from student where stuid='''+edit1.Text+'''');
adoquery1.Open;
if adoquery1.RecordCount=0 then
begin
showmessage('该学号不存在!');
edit1.SetFocus;
end
else
begin
edit2.Text:=adoquery1.fieldbyname('stuname').AsString;
edit3.Text:=adoquery1.fieldbyname('stuclass').AsString;
edit4.Text:=adoquery1.fieldbyname('studepart').AsString;
end;
except
showmessage('数据库连接失败!');
end;
end;
end;
procedure Tf_reward.Button2Click(Sender: TObject);
var
riqi,sqlstr,str:string;
begin
riqi:=combobox1.Text+'-'+combobox2.Text+'-'+combobox3.Text;
if radiogroup1.ItemIndex=0 then
str:='校特等奖';
if radiogroup1.ItemIndex=1 then
str:='校一等奖';
if radiogroup1.ItemIndex=2 then
str:='校二等奖';
if radiogroup1.ItemIndex=3 then
str:='校三等奖';
if radiogroup1.ItemIndex=4 then
str:='系一等奖';
if radiogroup1.ItemIndex=5 then
str:='系二等奖';
if radiogroup1.ItemIndex=6 then
str:='系三等奖';
try
sqlstr:='insert into stuinfo values('''+edit1.text+''','''+str+''','''+memo1.Text+''','''+riqi+''',''1'')';
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add(sqlstr);
adoquery1.ExecSQL;
showmessage('添加成功!');
except
showmessage('该用户名存在或数据库连接失败!');
end;
end;
procedure Tf_reward.Button1Click(Sender: TObject);
begin
close;
end;
procedure Tf_reward.FormShow(Sender: TObject);
var
i,j:integer;
year:string;
begin
year:=datetostr(now);
i:=strtoint(copy(year,0,4));
j:=i-5;
combobox1.Clear;
while j<=i do
begin
combobox1.Items.Add(inttostr(j));
j:=j+1;
end;
combobox1.ItemIndex:=0;
//显示月
i:=12;
j:=1;
combobox2.Clear;
while j<=i do
begin
if j<10 then
combobox2.Items.Add('0'+inttostr(j))
else
combobox2.Items.Add(inttostr(j));
j:=j+1;
end;
combobox2.ItemIndex:=0;
//显示天
i:=31;
j:=1;
combobox3.Clear;
while j<=i do
begin
if j<10 then
combobox3.Items.Add('0'+inttostr(j))
else
combobox3.Items.Add(inttostr(j));
j:=j+1;
end;
combobox3.ItemIndex:=0;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -