iordcourse.~pas
来自「delphi 学生选课系统的实现 附有sql 语句」· ~PAS 代码 · 共 134 行
~PAS
134 行
unit IorDCourse;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, DBGrids, StdCtrls;
type
TIorDCourseForm = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
Button2: TButton;
DBGrid1: TDBGrid;
procedure Onshow(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure OnHide(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
IorDCourseForm: TIorDCourseForm;
count:integer;
implementation
uses DataModule,Login;
{$R *.dfm}
procedure TIorDCourseForm.OnShow(Sender: TObject);
begin
with DataModuleForm.A_Stu_IorDCourse do
begin
Close;
SQL.Clear;
SQL.Add('select 课程详细信息.* from 课程详细信息,学生选课信息');
SQL.Add('where 课程详细信息.课程号 = 学生选课信息.课程号');
SQL.Add('and 课程详细信息.课序号 = 学生选课信息.课序号');
SQL.Add('and 学生选课信息.成绩 is NULL');
SQL.Add('and 学生选课信息.学号 = '+''''+Login.UseId+'''');
// Application.MessageBox(SQL.GetText,'信息',MB_OK);
Open;
end
end;
procedure TIorDCourseForm.Button1Click(Sender: TObject);
begin
if (Edit1.Text <> '')and(Edit2.Text <> '')then
begin
with DataModuleForm.A_Stu_Query do
begin
Close;
SQL.Clear;
SQL.Add('select 课程号,课序号 from 学生选课信息');
SQL.Add('where 课程号 = '+Edit1.Text);
SQL.Add('and 课序号 = '+Edit2.Text);
Open;
count := RecordCount;
end;
with DataModuleForm.A_Stu_IorDCourse do
if count =0 then
begin
Close;
SQL.Clear;
SQL.Add('insert into 学生选课信息');
SQL.Add('values('+Login.UseId+','+Edit1.Text+','+Edit2.Text+','+'NULL'+')');
Application.MessageBox(SQL.GetText,'信息',MB_OK);
ExecSQL;
Edit1.Clear;
Edit2.Clear;
Close;
SQL.Clear;
SQL.Add('select 课程详细信息.* from 课程详细信息,学生选课信息');
SQL.Add('where 课程详细信息.课程号 = 学生选课信息.课程号');
SQL.Add('and 课程详细信息.课序号 = 学生选课信息.课序号');
SQL.Add('and 学生选课信息.成绩 is NULL');
SQL.Add('and 学生选课信息.学号 = '+''''+Login.UseId+'''');
// Application.MessageBox(SQL.GetText,'信息',MB_OK);
Open;
end
else
begin
Application.MessageBox('该记录已经存在,添加失败!','错误',MB_OK);
end
end
else
begin
Application.MessageBox('输入框不能为空!','错误',MB_OK);
end
end;
procedure TIorDCourseForm.OnHide(Sender: TObject);
begin
Edit1.Clear;
Edit2.Clear;
end;
procedure TIorDCourseForm.Button2Click(Sender: TObject);
begin
with DataModuleForm.A_Stu_IorDCourse do
begin
Close;
SQL.Clear;
SQL.Add('delete from 学生选课信息');
SQL.Add('where 课程号 = '+Edit1.Text);
SQL.Add('and 课序号 = '+Edit2.Text);
// Application.MessageBox(SQL.GetText,'信息',MB_OK);
ExecSQL;
Edit1.Clear;
Edit2.Clear;
Close;
SQL.Clear;
SQL.Add('select 课程详细信息.* from 课程详细信息,学生选课信息');
SQL.Add('where 课程详细信息.课程号 = 学生选课信息.课程号');
SQL.Add('and 课程详细信息.课序号 = 学生选课信息.课序号');
SQL.Add('and 学生选课信息.成绩 is NULL');
SQL.Add('and 学生选课信息.学号 = '+''''+Login.UseId+'''');
// Application.MessageBox(SQL.GetText,'信息',MB_OK);
Open;
end
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?