📄 unit4.~pas
字号:
unit Unit4;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, DBCtrls, Mask, ComCtrls, DB, DBTables, ADODB;
type
TForm4 = class(TForm)
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
Label2: TLabel;
i_stud_id_2: TMaskEdit;
GroupBox1: TGroupBox;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
DBText1: TDBText;
DBText2: TDBText;
DBText3: TDBText;
i_reward: TRadioGroup;
Label6: TLabel;
i_descrip_2: TMemo;
Button2: TButton;
Button1: TButton;
GroupBox2: TGroupBox;
Label1: TLabel;
Label7: TLabel;
Label8: TLabel;
DBText4: TDBText;
DBText5: TDBText;
DBText6: TDBText;
i_stud_id_3: TMaskEdit;
Label9: TLabel;
i_punish: TRadioGroup;
Label10: TLabel;
i_descrip_3: TMemo;
Button3: TButton;
Button4: TButton;
DS_depart_info_2: TDataSource;
DS_class_info_2: TDataSource;
DS_stud_info_2: TDataSource;
DS_stud_info_3: TDataSource;
DS_depart_info_3: TDataSource;
DS_class_info_3: TDataSource;
T_class_info_2: TADOTable;
T_depart_info_2: TADOTable;
T_stud_info_2: TADOTable;
T_class_info_3: TADOTable;
T_depart_info_3: TADOTable;
T_stud_info_3: TADOTable;
T_counter_r: TADOTable;
T_reward: TADOTable;
T_punish: TADOTable;
T_counter_p: TADOTable;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure i_stud_id_3Change(Sender: TObject);
procedure i_stud_id_2Change(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure TabSheet2Show(Sender: TObject);
procedure TabSheet1Show(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form4: TForm4;
implementation
{$R *.dfm}
procedure TForm4.Button1Click(Sender: TObject);
begin
i_stud_id_2.Text:=''; //学号输入框清空
i_reward.ItemIndex:=0; //学籍变更复位到"转系"
i_descrip_2.Clear; //描述清空
i_stud_id_2.SetFocus;
end;
procedure TForm4.Button2Click(Sender: TObject);
var
counter:integer; //counter变量用于计数器增值
begin
T_stud_info_2.Open; //打开学生信息表
if T_stud_info_2.RecordCount>0 then //判断输入的学号是否存在
begin //学号存在,开始追加记录
T_counter_r.Open;
counter:=T_counter_r['COUNTER_VALUE'];
Inc(counter); //累加学籍变更计数器
T_counter_r.Edit;
T_counter_r['COUNTER_VALUE']:=counter;
T_counter_r.Post; //修改计数器值
T_reward.Open; //打开学籍变更表,追加记录
T_reward.AppendRecord([counter,i_stud_id_2.text,i_reward.ItemIndex,Now,i_descrip_2.text]);
Button1Click(nil); //初始化表单
end
else //学号输入有误
Application.MessageBox('请确认输入的学号是否正确!','错误',MB_OK);
i_stud_id_2.SetFocus;
end;
procedure TForm4.Button4Click(Sender: TObject);
begin
i_stud_id_3.Text:=''; //学号输入框清空
i_reward.ItemIndex:=0; //学籍变更复位到"转系"
i_descrip_3.Clear; //描述清空
i_stud_id_3.SetFocus;
end;
procedure TForm4.Button3Click(Sender: TObject);
var
counter:integer; //counter变量用于计数器增值
begin
T_stud_info_3.Open; //打开学生信息表
if T_stud_info_3.RecordCount>0 then //判断输入的学号是否存在
begin //学号存在,开始追加记录
T_counter_p.Open;
counter:=T_counter_p['COUNTER_VALUE'];
Inc(counter); //累加学籍变更计数器
T_counter_p.Edit;
T_counter_p['COUNTER_VALUE']:=counter;
T_counter_p.Post; //修改计数器值
T_punish.Open; //打开学籍变更表,追加记录
T_punish.AppendRecord([counter,i_stud_id_3.text,i_punish.ItemIndex,Now,'是',i_descrip_3.text]);
Button4Click(nil); //初始化表单
end
else //学号输入有误
Application.MessageBox('请确认输入的学号是否正确!','错误',MB_OK);
i_stud_id_3.SetFocus;
end;
procedure TForm4.i_stud_id_3Change(Sender: TObject);
begin
T_stud_info_3.Filter:='ID='''+trim(i_stud_id_3.Text)+''''; //设置过滤器
T_stud_info_3.Filtered:=True; //激活过滤器
T_stud_info_3.Open; //打开学生信息数据表
T_class_info_3.Open; //打开班级信息表
T_depart_info_3.Open; //打开院系信息表
end;
procedure TForm4.i_stud_id_2Change(Sender: TObject);
begin
T_stud_info_2.Filter:='ID='''+trim(i_stud_id_2.Text)+''''; //设置过滤器
T_stud_info_2.Filtered:=True; //激活过滤器
T_stud_info_2.Open; //打开学生信息数据表
T_class_info_2.Open; //打开班级信息表
T_depart_info_2.Open; //打开院系信息表
end;
procedure TForm4.FormClose(Sender: TObject; var Action: TCloseAction);
begin
i_stud_id_2.Text:=''; //学号输入框清空
i_reward.ItemIndex:=0; //学籍变更复位到"转系"
i_descrip_2.Clear; //描述清空
i_stud_id_3.Text:=''; //学号输入框清空
i_reward.ItemIndex:=0; //学籍变更复位到"转系"
i_descrip_3.Clear; //描述清空
T_reward.Close;
T_counter_r.Close;
T_counter_p.Close;
T_punish.Close;
T_stud_info_2.Close;
T_class_info_2.Close;
T_depart_info_2.Close;
T_stud_info_3.Close;
T_class_info_3.Close;
T_depart_info_3.Close;
T_reward.ConnectionString:='';
T_counter_r.ConnectionString:='';
T_counter_p.ConnectionString:='';
T_punish.ConnectionString:='';
T_stud_info_2.ConnectionString:='';
T_class_info_2.ConnectionString:='';
T_depart_info_2.ConnectionString:='';
T_stud_info_3.ConnectionString:='';
T_class_info_3.ConnectionString:='';
T_depart_info_3.ConnectionString:='';
end;
procedure TForm4.FormCreate(Sender: TObject);
begin
T_reward.ConnectionString:='Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=mydb';
T_counter_r.ConnectionString:='Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=mydb';
T_counter_p.ConnectionString:='Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=mydb';
T_punish.ConnectionString:='Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=mydb';
T_stud_info_2.ConnectionString:='Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=mydb';
T_class_info_2.ConnectionString:='Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=mydb';
T_depart_info_2.ConnectionString:='Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=mydb';
T_stud_info_3.ConnectionString:='Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=mydb';
T_class_info_3.ConnectionString:='Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=mydb';
T_depart_info_3.ConnectionString:='Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=mydb';
end;
procedure TForm4.TabSheet2Show(Sender: TObject);
begin
i_stud_id_3.SetFocus;
end;
procedure TForm4.TabSheet1Show(Sender: TObject);
begin
i_stud_id_2.SetFocus;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -