📄 frm_statusu.pas
字号:
unit frm_statusU;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, frm_infoU, StdCtrls, DB, Grids, DBGrids,Control_StatusU,ClassesU,
Control_StudentU;
type
Tfrm_status = class(Tfrm_info)
edt_stdNo: TEdit;
Label1: TLabel;
Label2: TLabel;
cbx_type: TComboBox;
Label3: TLabel;
edt_changeDate: TEdit;
Label4: TLabel;
edt_oldClass: TEdit;
Label5: TLabel;
Label6: TLabel;
Lab_newclass: TLabel;
edt_newClass: TEdit;
Label8: TLabel;
Memo_reason: TMemo;
Label9: TLabel;
Memo_remark: TMemo;
lab_newSchool: TLabel;
edt_newSchool: TEdit;
Label18: TLabel;
edt_stdNo_s: TEdit;
btn_search_stdNo: TButton;
procedure cbx_typeChange(Sender: TObject);
procedure btn_addClick(Sender: TObject);
procedure btn_delClick(Sender: TObject);
procedure btn_editClick(Sender: TObject);
procedure DBGrid_infoCellClick(Column: TColumn);
procedure btn_search_stdNoClick(Sender: TObject);
private
//通过用户选择的学籍变动类型来改变界面
procedure ChangeUIByType(typeStr:string);
public
procedure FillData;override;
end;
var
frm_status: Tfrm_status;
implementation
{$R *.dfm}
procedure Tfrm_status.FillData;
begin
DataSource_info.DataSet:=Control_StatusU.GetStatusArray;
self.DBGrid_info.Columns[0].Visible :=false;
end;
procedure Tfrm_status.ChangeUIByType(typeStr:string);
begin
if (typeStr='退学') or (typeStr='休学') then
begin
self.Lab_newclass.Visible:=false;
self.edt_newClass.Visible:=false;
self.lab_newSchool.Visible:=false;
self.edt_newSchool.Visible:=false;
end
else
begin
if (typeStr='转学') then
begin
self.Lab_newclass.Visible:=false;
self.edt_newClass.Visible:=false;
self.lab_newSchool.Visible:=true;
self.edt_newSchool.Visible:=true;
end;
if (typeStr='调班') then
begin
self.Lab_newclass.Visible:=true;
self.edt_newClass.Visible:=true;
self.lab_newSchool.Visible:=false;
self.edt_newSchool.Visible:=false;
end;
end;
end;
procedure Tfrm_status.cbx_typeChange(Sender: TObject);
begin
inherited;
ChangeUIByType(cbx_type.Text);
end;
procedure Tfrm_status.btn_addClick(Sender: TObject);
var
Student:TStudent;
Status:TStatus;
begin
inherited;
if((self.edt_stdNo.Text='')) then
begin
MessageBox(Handle, '内容填写不正确!', '信息', MB_ICONEXCLAMATION);
exit;
end;
Student:=TStudent.Create;
Student:=Control_StudentU.GetStudentByStudentNo(self.edt_stdNo.Text);
if Student=nil then
begin
MessageBox(Handle, '学号填写不正确!', '信息', MB_ICONEXCLAMATION);
edt_stdNo.SetFocus;
exit;
end;
self.edt_oldClass.Text:=Student.ClassName;
Status:=TStatus.Create;
Status.studentNo:=self.edt_stdNo.Text;
Status.changeType:=self.cbx_type.Text;
Status.changeDate:=DateToStr(now);
Status.oldClass:=self.edt_oldClass.Text;
Status.newSchool:=self.edt_newSchool.Text;
Status.newClass:=self.edt_newClass.Text;
Status.reason:=self.Memo_reason.Text;
Status.remark:=self.Memo_remark.Text;
if(Control_StatusU.AddStatus(Status)) then
begin
MessageBox(Handle, '添加成功!', '信息', MB_ICONASTERISK);
//刷新内容
FillData;
end
else
begin
MessageBox(Handle, '添加失败!', '信息', MB_ICONEXCLAMATION);
exit;
end;
end;
procedure Tfrm_status.btn_delClick(Sender: TObject);
begin
inherited;
if MessageBox(Handle, '您确定要删除该条信息', '信息',
MB_ICONQUESTION or MB_OKCANCEL) = IDOK then
begin
Control_statusU.Delstatus(self.edt_stdNo.Tag);
FillData;
if self.DBGrid_info.Fields[0].IsNull then
exit;
self.edt_stdNo.Tag:=self.DBGrid_info.Fields[0].Value;//保存id
self.edt_stdNo.Text:=self.DBGrid_info.Fields[1].Value;
self.cbx_type.Text:=self.DBGrid_info.Fields[2].Value;
self.edt_changeDate.Text:=self.DBGrid_info.Fields[3].Value;
self.edt_oldClass.Text:=self.DBGrid_info.Fields[4].Value;
self.edt_newSchool.Text:=self.DBGrid_info.Fields[5].Value;
self.edt_newClass.Text:=self.DBGrid_info.Fields[6].Value;
self.Memo_reason.Text :=self.DBGrid_info.Fields[7].Value;
self.Memo_remark.Text:=self.DBGrid_info.Fields[8].Value;
end;
end;
procedure Tfrm_status.btn_editClick(Sender: TObject);
var
status:Tstatus;
Student:TStudent;
typeStr:string;
begin
inherited;
if edt_stdNo.Text ='' then
begin
MessageBox(Handle, '没有可以修改的数据!', '信息', MB_ICONEXCLAMATION);
exit;
end
else
begin
if((edt_stdNo.Text='')) then
begin
MessageBox(Handle, '内容填写不正确!', '信息', MB_ICONEXCLAMATION);
exit;
end;
Student:=TStudent.Create;
Student:=Control_StudentU.GetStudentByStudentNo(self.edt_stdNo.Text);
if Student=nil then
begin
MessageBox(Handle, '学号填写不正确!', '信息', MB_ICONEXCLAMATION);
edt_stdNo.SetFocus;
exit;
end;
self.edt_oldClass.Text:=Student.ClassName;
typeStr:=self.cbx_type.Text;
if (typeStr='退学') or (typeStr='休学') then
begin
self.edt_newClass.Text:='';
self.edt_newSchool.Text:='';
end
else
begin
if (typeStr='转学') then
begin
self.edt_newClass.Text:='';
end;
if (typeStr='调班') then
begin
self.edt_newSchool.Text:='';
end;
end;
Status:=TStatus.Create;
Status.id:=self.edt_stdNo.Tag;
Status.studentNo:=self.edt_stdNo.Text;
Status.changeType:=self.cbx_type.Text;
Status.changeDate:=self.edt_changeDate.Text;
Status.oldClass:=self.edt_oldClass.Text;
Status.newSchool:=self.edt_newSchool.Text;
Status.newClass:=self.edt_newClass.Text;
Status.reason:=self.Memo_reason.Text;
Status.remark:=self.Memo_remark.Text;
if(Control_statusU.Editstatus(status)) then
begin
MessageBox(Handle, '修改成功!', '信息', MB_ICONASTERISK);
//刷新内容
FillData;
end
else
begin
MessageBox(Handle, '修改失败!', '信息', MB_ICONEXCLAMATION);
exit;
end;
self.edt_stdNo.SetFocus;
end;
end;
procedure Tfrm_status.DBGrid_infoCellClick(Column: TColumn);
var
typeStr:string;
begin
inherited;
if self.DBGrid_info.Fields[0].IsNull then
exit;
typeStr:=self.DBGrid_info.Fields[2].Value;//变动类型
if (typeStr='退学') or (typeStr='休学') then
begin
self.Lab_newclass.Visible:=false;
self.edt_newClass.Visible:=false;
self.lab_newSchool.Visible:=false;
self.edt_newSchool.Visible:=false;
end
else
begin
if (typeStr='转学') then
begin
self.Lab_newclass.Visible:=false;
self.edt_newClass.Visible:=false;
self.lab_newSchool.Visible:=true;
self.edt_newSchool.Visible:=true;
end;
if (typeStr='调班') then
begin
self.Lab_newclass.Visible:=true;
self.edt_newClass.Visible:=true;
self.lab_newSchool.Visible:=false;
self.edt_newSchool.Visible:=false;
end;
end;
self.edt_stdNo.Tag:=self.DBGrid_info.Fields[0].Value;//保存id
self.edt_stdNo.Text:=self.DBGrid_info.Fields[1].Value;
self.cbx_type.Text :=self.DBGrid_info.Fields[2].Value;
self.edt_changeDate.Text:=DatetoStr(self.DBGrid_info.Fields[3].Value);
self.edt_oldClass.Text:=self.DBGrid_info.Fields[4].Value;
self.edt_newSchool.Text:=self.DBGrid_info.Fields[5].Value;
self.edt_newClass.Text:=self.DBGrid_info.Fields[6].Value;
self.Memo_reason.Text:=self.DBGrid_info.Fields[7].Value;
self.Memo_remark.Text:=self.DBGrid_info.Fields[8].Value;
end;
procedure Tfrm_status.btn_search_stdNoClick(Sender: TObject);
begin
inherited;
if self.edt_stdNo_s.Text='' then
DataSource_info.DataSet:=Control_statusU.GetStatusArray
else
DataSource_info.DataSet:=GetStatusQueryByStdNo(self.edt_stdNo_s.Text);
self.DBGrid_info.Columns[0].Visible :=false;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -