📄 unit3.pas
字号:
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, DBTables, StdCtrls, Mask, DBCtrls, Grids, DBGrids, ExtCtrls;
type
TForm3 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
DBEdit1: TDBEdit;
DBEdit2: TDBEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Button1: TButton;
Button2: TButton;
Query1: TQuery;
Query2: TQuery;
DataSource1: TDataSource;
Query3: TQuery;
DataSource2: TDataSource;
DBGrid1: TDBGrid;
Label5: TLabel;
DataSource3: TDataSource;
Table1: TTable;
DBNavigator2: TDBNavigator;
Button3: TButton;
Button4: TButton;
StringGrid1: TStringGrid;
Query4: TQuery;
Table1CNO: TStringField;
Table1CNAME: TStringField;
Table1CREDIT: TFloatField;
Table1CTIME: TFloatField;
Table1QUOTA: TFloatField;
Query5: TQuery;
Button5: TButton;
Query5CNO: TStringField;
Query5CNAME: TStringField;
Query5CREDIT: TFloatField;
Query5CTIME: TFloatField;
Query5QUOTA: TFloatField;
Query6: TQuery;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure StringGrid1SelectCell(Sender: TObject; ACol, ARow: Integer;
var CanSelect: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form3: TForm3;
implementation
{$R *.dfm}
var
col,row :integer;
acno :array[1..5,1..4] of string ;
procedure TForm3.Button1Click(Sender: TObject);
begin
query1.sql.add('select passwd from student');
query1.sql.add('where sno='+edit1.text);
showmessage(query1.sql.text);
query1.Open;
showmessage(query1.fields[0].Value);
if edit2.text=query1.fields[0].Value then
begin
query2.ParamByName('sno').value:=edit1.text;
query2.open;
query3.ParamByName('sno').value:=edit1.text;
query3.open;
table1.Open;
button3.Enabled:=true;
button4.Enabled:=true;
button5.Enabled:=true;
end
else
showmessage('密码不正确');
end;
procedure TForm3.Button2Click(Sender: TObject);
begin
close;
end;
procedure TForm3.FormShow(Sender: TObject);
begin
stringGrid1.Cells[0,1]:= '第一节' ;
stringGrid1.Cells[0,2]:= '第二节' ;
stringGrid1.Cells[0,3]:= '第三节' ;
stringGrid1.Cells[0,4]:= '第四节' ;
stringGrid1.Cells[1,0]:= '星期一' ;
stringGrid1.Cells[2,0]:= '星期二' ;
stringGrid1.Cells[3,0]:= '星期三' ;
stringGrid1.Cells[4,0]:= '星期四' ;
stringGrid1.Cells[5,0]:= '星期五' ;
edit1.SetFocus;
end;
procedure TForm3.Button3Click(Sender: TObject);
begin
col:=table1ctime.AsInteger div 10;
row:=table1ctime.Asinteger mod 10;
stringGrid1.Cells[col,row]:=table1cname.value;
acno[col,row]:=table1cno.value;
Table1.Edit ;
Table1quota.value:=table1quota.value-1;
Table1.Post ;
query4.close;
query4.parambyname('sno').value:=edit1.text ;
query4.parambyname('cno').value:=table1cno.value;
query4.execsql;
end;
procedure TForm3.Button5Click(Sender: TObject);
begin
query5.close;
query5.ParamByName('sno').value:=edit1.text;
query5.open;
While not query5.EOF do
Begin
col:=query5ctime.AsInteger div 10;
row:=query5ctime.AsInteger-col*10 ;
stringGrid1.Cells[col,row]:=query5cname.value ;
acno[col,row]:=query5cno.value;
query5.Next;
End;
end;
procedure TForm3.Button4Click(Sender: TObject);
begin
query6.close;
query6.parambyname('sno').value:=strtoint(edit1.text);
query6.parambyname('cno').value:=acno[col,row];
query6.execsql;
table1.locate('cno',acno[col,row],[]);
Table1.Edit ;
Table1quota.value:=table1quota.value+1;
Table1.Post ;
stringGrid1.Cells[col,row]:='' ;
acno[col,row]:='' ;
end;
procedure TForm3.StringGrid1SelectCell(Sender: TObject; ACol,
ARow: Integer; var CanSelect: Boolean);
begin
col:=acol;
row:=arow;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -