📄 unit4.~pas
字号:
unit Unit4;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DB, ADODB, DBCtrls;
type
TSearchForm = class(TForm)
Button1: TButton;
Button2: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
DBText1: TDBText;
DBText2: TDBText;
DBText3: TDBText;
DBText4: TDBText;
DBText6: TDBText;
ADOQuery1: TADOQuery;
ADOQuery2: TADOQuery;
ComboBox1: TComboBox;
DataSource1: TDataSource;
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
SearchForm: TSearchForm;
implementation
uses Unit1,Unit2;
{$R *.dfm}
procedure TSearchForm.Button2Click(Sender: TObject);
begin
close;
end;
procedure TSearchForm.Button1Click(Sender: TObject); //选课
begin
ADOQuery2.close;
ADOQuery2.SQL.Clear;
ADOQuery2.SQL.Add('select * from sc where sno=:Psno and cno=:Pcno');
ADOQuery2.Parameters.ParamByName('Psno').value:=MainForm.DBText3.Caption;
ADOQuery2.Parameters.ParamByName('Pcno').value:=dbtext1.Caption;
ADOQuery2.open; //判断待选课程是否已选
if not ADOQuery2.Eof then messagedlg(#10'您已经选过该课程,请核对课号!', mtwarning,[mbOk],0)
else begin
ADOQuery2.close;
ADOQuery2.SQL.Clear;
ADOQuery2.SQL.Add('insert into sc(sno,cno,kinder) values (:Psno,:Pcno,:Pkinder)');
ADOQuery2.Parameters.ParamByName('Psno').value:=MainForm.DBText3.Caption;
ADOQuery2.Parameters.ParamByName('Pcno').value:=dbtext1.Caption;
ADOQuery2.Parameters.ParamByName('Pkinder').value:=ComboBox1.Items[combobox1.itemindex];
ADOQuery2.ExecSQL;
//添加所选课程
MainForm.FormCreate(Sender);
MainForm.SearchEdit.Clear;
SearchForm.Close;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -