?? unit12.~pas
字號:
unit Unit12;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, ComCtrls, Buttons, DB, DBTables;
type
Ttianchong = class(TForm)
Panel1: TPanel;
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
Label1: TLabel;
kecheng: TComboBox;
Panel2: TPanel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
tino: TLabel;
timu: TEdit;
xuanb: TEdit;
xuanc: TEdit;
xuand: TEdit;
xuana: TEdit;
tj: TBitBtn;
tianchong: TQuery;
Label8: TLabel;
daan: TComboBox;
Label9: TLabel;
kechengt: TComboBox;
Panel3: TPanel;
Label10: TLabel;
kong1: TLabel;
k: TLabel;
Label13: TLabel;
Label14: TLabel;
Label15: TLabel;
tinot: TLabel;
Label17: TLabel;
timut: TEdit;
k2: TEdit;
k3: TEdit;
k4: TEdit;
k1: TEdit;
kongshu: TComboBox;
BitBtn2: TBitBtn;
BitBtn1: TBitBtn;
BitBtn3: TBitBtn;
procedure tjClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure kechengtChange(Sender: TObject);
procedure kechengChange(Sender: TObject);
procedure timutKeyPress(Sender: TObject; var Key: Char);
procedure k1KeyPress(Sender: TObject; var Key: Char);
procedure k2KeyPress(Sender: TObject; var Key: Char);
procedure k3KeyPress(Sender: TObject; var Key: Char);
procedure k4KeyPress(Sender: TObject; var Key: Char);
procedure timuKeyPress(Sender: TObject; var Key: Char);
procedure xuanaKeyPress(Sender: TObject; var Key: Char);
procedure xuanbKeyPress(Sender: TObject; var Key: Char);
procedure xuancKeyPress(Sender: TObject; var Key: Char);
procedure xuandKeyPress(Sender: TObject; var Key: Char);
procedure kongshuKeyPress(Sender: TObject; var Key: Char);
procedure daanKeyPress(Sender: TObject; var Key: Char);
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
tianchong: Ttianchong;
implementation
uses Unit2;
{$R *.dfm}
procedure Ttianchong.tjClick(Sender: TObject);
var
xk,tk:string;
begin
tianchong.SQL.Clear ;
if (timu.Text <>'') and (xuana.Text <>'') and (xuanb.Text <>'') and (xuanc.Text <>'') and (xuand.Text <>'') then
begin
if kecheng.Text ='外語' then
begin
xk:='外語選擇題庫';
tianchong.SQL.Add('select * from 外語選擇題庫');
end
else
begin
xk:='線性代數選擇題庫';
tianchong.SQL.Add('select * from 線性代數選擇題庫');
end;
tianchong.Open;
tino.Caption :=inttostr(tianchong.RecordCount+1);
tianchong.SQL.Clear ;
tianchong.SQL.Add('insert into '+xk+' (題號,題型,題目,選項A,選項B,選項C,選項D,正確答案,所屬課程,是否選中) values(:no,:tx,:tm,:xa,:xb,:xc,:xd,:daan,:kecheng,'+''''+'false'+''''+')');
tianchong.ParamByName('no').AsString :=tino.Caption ;
tianchong.ParamByName('tx').AsString :='選擇題';
tianchong.ParamByName ('tm').AsString :=timu.Text ;
tianchong.ParamByName ('xa').AsString :=xuana.Text ;
tianchong.ParamByName ('xb').AsString :=xuanb.Text ;
tianchong.ParamByName ('xc').AsString :=xuanc.Text ;
tianchong.ParamByName ('xd').AsString :=xuand.Text;
tianchong.ParamByName ('daan').AsString :=daan.text;
tianchong.ParamByName ('kecheng').AsString :=kecheng.Text ;
tianchong.ExecSQL ;
timu.Text :='';
xuana.Text :='';
xuanb.Text:='';
xuanc.Text:='';
xuand.Text:='';
timu.SetFocus ;
if kecheng.Text ='外語' then
begin
tianchong.SQL.Clear ;
xk:='外語選擇題庫';
tianchong.SQL.Add('select * from 外語選擇題庫');
end
else
begin
tianchong.SQL.Clear ;
xk:='線性代數選擇題庫';
tianchong.SQL.Add('select * from 線性代數選擇題庫');
end;
tianchong.Open;
tino.Caption :=inttostr(tianchong.RecordCount+1);
end
else
showmessage('請將試題信息填寫完整');
end;
procedure Ttianchong.FormActivate(Sender: TObject);
var
xk:string;
begin
tianchong.SQL.Clear ;
if kecheng.Text ='外語' then
begin
xk:='外語選擇題庫';
tianchong.SQL.Add('select * from 外語選擇題庫');
end
else
begin
xk:='線性代數選擇題庫';
tianchong.SQL.Add('select * from 線性代數選擇題庫');
end;
tianchong.Open;
tino.Caption :=inttostr(tianchong.RecordCount+1);
//初始化填空題號
tianchong.SQL.Clear ;
if kecheng.Text ='外語' then
begin
xk:='外語填空題庫';
tianchong.SQL.Add('select * from 外語填空題庫');
end
else
begin
xk:='線性代數填空題庫';
tianchong.SQL.Add('select * from 線性代數填空題庫');
end;
tianchong.Open;
tinot.Caption :=inttostr(tianchong.RecordCount+1);
// 初始化完畢
end;
procedure Ttianchong.BitBtn2Click(Sender: TObject);
var
xk,tk:string;
begin
tianchong.SQL.Clear ;
if k1.Text <>'' then
k1.Tag:=k1.Tag+1;
if k2.text<>'' then
k1.Tag:=k1.Tag+1;
if k3.text<>'' then
k1.Tag:=k1.Tag+1;
if k4.text<>'' then
k1.Tag:=k1.Tag+1;
if inttostr(k1.tag)=kongshu.Text then
begin
if (timut.Text <>'') and not ((k1.Text ='?') and (k2.Text ='?') and (k3.Text ='?') and (k4.Text ='?')) then
begin
if kechengt.Text ='外語' then
begin
tk:='外語填空題庫';
tianchong.SQL.Add('select * from 外語填空題庫');
end
else
begin
tk:='線性代數填空題庫';
tianchong.SQL.Add('select * from 線性代數填空題庫');
end;
tianchong.Open;
tinot.Caption :=inttostr(tianchong.RecordCount+1);
tianchong.SQL.Clear ;
tianchong.SQL.Add('insert into '+tk+' (題號,題型,題目,空1,空2,空3,空4,填空數目,所屬課程,是否選中) values(:no,:tx,:tm,:xa,:xb,:xc,:xd,:ts,:kecheng,'+''''+'false'+''''+')');
tianchong.ParamByName('no').AsString :=tinot.Caption ;
tianchong.ParamByName('tx').AsString :='填空';
tianchong.ParamByName ('tm').AsString :=timut.Text ;
if k1.text='' then
tianchong.ParamByName ('xa').AsString :='?'
else
tianchong.ParamByName ('xa').AsString :=k1.Text ;
if k2.Text ='' then
tianchong.ParamByName ('xb').AsString :='?'
else
tianchong.ParamByName ('xb').AsString :=k2.Text ;
if k3.Text ='' then
tianchong.ParamByName ('xc').AsString :='?'
else
tianchong.ParamByName ('xc').AsString :=k3.Text ;
if k4.Text ='' then
tianchong.ParamByName ('xd').AsString :='?'
else
tianchong.ParamByName ('xd').AsString :=k4.Text;
tianchong.ParamByName ('ts').AsString :=kongshu.text;
tianchong.ParamByName ('kecheng').AsString :=kechengt.Text ;
tianchong.ExecSQL ;
timut.Text :='';
if kechengt.Text ='外語' then
begin
tianchong.SQL.Clear ;
xk:='外語填空題庫';
tianchong.SQL.Add('select * from 外語填空題庫');
end
else
begin
tianchong.SQL.Clear ;
xk:='線性代數填空題庫';
tianchong.SQL.Add('select * from 線性代數填空題庫');
end;
tianchong.Open;
tinot.Caption :=inttostr(tianchong.RecordCount+1);
k1.Text :='';
k2.Text :='';
k3.Text :='';
k4.Text:='';
end
else
showmessage('請將試題信息填寫完整');
end
else
begin
showmessage('對不起!填空數目與實際空數不符,請查證!');
end;
k1.Tag:=0;
timut.SetFocus ;
end;
procedure Ttianchong.kechengtChange(Sender: TObject);
begin
if kechengt.Text ='外語' then
begin
tianchong.SQL.Clear ;
tianchong.SQL.Add('select * from 外語填空題庫');
tianchong.Open;
end
else
begin
tianchong.SQL.Clear ;
tianchong.SQL.Add('select * from 線性代數填空題庫');
tianchong.Open;
end;
tinot.Caption :=inttostr(tianchong.RecordCount+1);
end;
procedure Ttianchong.kechengChange(Sender: TObject);
begin
if kecheng.Text ='外語' then
begin
tianchong.SQL.Clear ;
tianchong.SQL.Add('select * from 外語選擇題庫');
tianchong.open;
end
else
begin
tianchong.SQL.Clear ;
tianchong.SQL.Add('select * from 線性代數選擇題庫');
tianchong.open;
end;
tino.Caption :=inttostr(tianchong.RecordCount+1);
end;
procedure Ttianchong.timutKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
BitBtn2Click(Sender);
end;
procedure Ttianchong.k1KeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
BitBtn2Click(Sender);
end;
procedure Ttianchong.k2KeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
BitBtn2Click(Sender);
end;
procedure Ttianchong.k3KeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
BitBtn2Click(Sender);
end;
procedure Ttianchong.k4KeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
BitBtn2Click(Sender);
end;
procedure Ttianchong.timuKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
tjClick(Sender);
end;
procedure Ttianchong.xuanaKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
tjClick(Sender);
end;
procedure Ttianchong.xuanbKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
tjClick(Sender);
end;
procedure Ttianchong.xuancKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
tjClick(Sender);
end;
procedure Ttianchong.xuandKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
tjClick(Sender);
end;
procedure Ttianchong.kongshuKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
BitBtn2Click(Sender);
end;
procedure Ttianchong.daanKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
tjClick(Sender);
end;
procedure Ttianchong.BitBtn1Click(Sender: TObject);
begin
xuqiu.show;
tianchong.Close;
end;
procedure Ttianchong.BitBtn3Click(Sender: TObject);
begin
tianchong.Close;
xuqiu.show;
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -