📄 enterscore.pas
字号:
unit EnterScore;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids, DBGrids, DBCtrls;
type
TEnterScoreForm = class(TForm)
DBGrid1: TDBGrid;
Label1: TLabel;
ComboBox1: TComboBox;
Label2: TLabel;
ComboBox2: TComboBox;
Label3: TLabel;
Edit1: TEdit;
Label4: TLabel;
Label5: TLabel;
Edit2: TEdit;
Edit3: TEdit;
Button1: TButton;
procedure OnShow(Sender: TObject);
procedure ComboBox1Change(Sender: TObject);
procedure OnHide(Sender: TObject);
procedure ComboBox2Change(Sender: TObject);
procedure OnCellClick(Column: TColumn);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
EnterScoreForm: TEnterScoreForm;
implementation
uses DataModule,Login;
{$R *.dfm}
procedure TEnterScoreForm.OnShow(Sender: TObject);
begin
with DataModuleForm.A_Tea_Query do
begin
Close;
SQL.Clear;
SQL.Add('select distinct 课程号 from 课程详细信息');
SQL.Add('where 教师编号 = '+''''+Login.UseId+'''');
Open;
if recordcount > 0 then
begin
First;
while not Eof do
begin
ComboBox1.Items.Add(FieldByName('课程号').AsString);
Next;
end;
end;
end
end;
procedure TEnterScoreForm.ComboBox1Change(Sender: TObject);
begin
with DataModuleForm.A_Tea_Query do
begin
Close;
SQL.Clear;
SQL.Add('select distinct 课序号 from 课程详细信息');
SQL.Add('where 课程号 = '+''''+ComboBox1.Text+'''');
Open;
ComboBox2.Items.clear;
ComboBox2.Text := '';
Edit1.Text := '';
Edit2.Text := '';
Edit3.Text := '';
if recordcount > 0 then
begin
First;
while not Eof do
begin
ComboBox2.Items.Add(FieldByName('课序号').AsString);
Next;
end;
end;
end
end;
procedure TEnterScoreForm.OnHide(Sender: TObject);
begin
ComboBox1.Clear;
ComboBox2.Clear;
ComboBox1.Text := '';
ComboBox2.Text := '';
Edit1.Text := '';
Edit2.Text := '';
Edit3.Text := '';
end;
procedure TEnterScoreForm.ComboBox2Change(Sender: TObject);
begin
with DataModuleForm.A_Tea_Query do
begin
Close;
SQL.Clear;
SQL.Add('select 课程名 from 课程详细信息');
SQL.Add('where 课程号 = '+''''+ComboBox1.Text+'''');
SQL.Add('and 课序号 = '+''''+ComboBox2.Text+'''');
// Application.MessageBox(SQL.GetText,'信息',MB_OK);
Open;
Edit1.Text := FieldByName('课程名').AsString;
end;
with DataModuleForm.A_Tea_Display do
begin
Close;
SQL.Clear;
SQL.Add('select * from 学生选课信息');
SQL.Add('where 课程号 = '+''''+ComboBox1.Text+'''');
SQL.Add('and 课序号 = '+''''+ComboBox2.Text+'''');
// Application.MessageBox(SQL.GetText,'信息',MB_OK);
Open;
end;
end;
procedure TEnterScoreForm.OnCellClick(Column: TColumn);
begin
Edit2.Text := DataModuleForm.A_Tea_Display.FieldByName('学号').AsString;
Edit3.Text := DataModuleForm.A_Tea_Display.FieldByName('成绩').AsString;
end;
procedure TEnterScoreForm.Button1Click(Sender: TObject);
begin
with DataModuleForm.A_Tea_Score do
begin
Close;
SQL.Clear;
SQL.Add('update 学生选课信息');
SQL.Add('set 成绩 = '+Edit3.Text);
SQL.Add('where 学号 = '+Edit2.Text);
SQL.Add('and 课程号 = '+ComboBox1.Text);
SQL.Add('and 课序号 = '+ComboBox2.Text);
// Application.MessageBox(SQL.GetText,'信息',MB_OK);
ExecSQL;
Application.MessageBox('成绩添加/修改成功!','信息',MB_OK);
Edit2.Text := '';
Edit3.Text := '';
end;
with DataModuleForm.A_Tea_Display do
begin
Close;
SQL.Clear;
SQL.Add('select * from 学生选课信息');
SQL.Add('where 课程号 = '+''''+ComboBox1.Text+'''');
SQL.Add('and 课序号 = '+''''+ComboBox2.Text+'''');
// Application.MessageBox(SQL.GetText,'信息',MB_OK);
Open;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -