?? frm_evaluationu.pas.~1~
字號:
unit frm_evaluationU;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, frm_infoU, DB, StdCtrls, Grids, DBGrids,Control_evaluationU,
ClassesU,Control_StudentU;
type
Tfrm_evaluation = class(Tfrm_info)
Label1: TLabel;
edt_stdNo: TEdit;
edt_edate: TEdit;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Memo_remark: TMemo;
cbx_type: TComboBox;
Label5: TLabel;
Label18: TLabel;
edt_stdNo_s: TEdit;
btn_search_stdNo: TButton;
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
{ Private declarations }
public
procedure FillData;override;
end;
var
frm_evaluation: Tfrm_evaluation;
implementation
{$R *.dfm}
procedure Tfrm_evaluation.FillData;
begin
self.DataSource_info.DataSet:=Control_evaluationU.GetEvaluationArray;
self.DBGrid_info.Columns[0].Visible :=false;
end;
procedure Tfrm_evaluation.btn_addClick(Sender: TObject);
var
Evaluation:TEvaluation;
Student:TStudent;
begin
inherited;
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;
Evaluation:=TEvaluation.Create;
Evaluation.id:=edt_stdNo.Tag;
Evaluation.stdNo:=trim(self.edt_stdNo.Text);
Evaluation.Edate:=DateToStr(now);
Evaluation.Etype:=self.cbx_type.Text;
Evaluation.remark:=self.Memo_remark.Text;
if(Control_EvaluationU.AddEvaluation(Evaluation)) then
begin
MessageBox(Handle, '添加成功!', '信息', MB_ICONASTERISK);
//刷新內容
FillData;
if self.DBGrid_info.Fields[0].IsNull then
begin
self.edt_stdNo.Tag:=0;//保存id
self.edt_stdNo.Text:='';
self.edt_edate.Text :='';
self.cbx_type.ItemIndex:=0;
self.Memo_remark.Text:='';
end
else
begin
self.edt_stdNo.Tag:=self.DBGrid_info.Fields[0].Value;//保存id
self.edt_stdNo.Text:=self.DBGrid_info.Fields[1].Value;
self.edt_edate.Text :=self.DBGrid_info.Fields[2].Value;
self.cbx_type.Text:=self.DBGrid_info.Fields[3].Value;
self.Memo_remark.Text:=self.DBGrid_info.Fields[4].Value;
end;
end
else
begin
MessageBox(Handle, '添加失??!', '信息', MB_ICONEXCLAMATION);
exit;
end;
end;
procedure Tfrm_evaluation.btn_delClick(Sender: TObject);
begin
inherited;
if MessageBox(Handle, '您確定要刪除該信息', '信息',
MB_ICONQUESTION or MB_OKCANCEL) = IDOK then
begin
Control_evaluationU.Delevaluation(self.edt_stdNo.Tag);
FillData;
if self.DBGrid_info.Fields[0].IsNull then
begin
self.edt_stdNo.Tag:=0;//保存id
self.edt_stdNo.Text:='';
self.edt_edate.Text :='';
self.cbx_type.ItemIndex:=0;
self.Memo_remark.Text:='';
end
else
begin
self.edt_stdNo.Tag:=self.DBGrid_info.Fields[0].Value;//保存id
self.edt_stdNo.Text:=self.DBGrid_info.Fields[1].Value;
self.edt_edate.Text :=self.DBGrid_info.Fields[2].Value;
self.cbx_type.Text:=self.DBGrid_info.Fields[3].Value;
self.Memo_remark.Text:=self.DBGrid_info.Fields[4].Value;
end;
end;
end;
procedure Tfrm_evaluation.btn_editClick(Sender: TObject);
var
Evaluation:TEvaluation;
Student:TStudent;
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;
Evaluation:=TEvaluation.Create;
Evaluation.id:=edt_stdNo.Tag;
Evaluation.stdNo:=trim(self.edt_stdNo.Text);
Evaluation.Edate:=trim(self.edt_edate.Text);
Evaluation.Etype:=self.cbx_type.Text;
Evaluation.remark:=self.Memo_remark.Text;
if(Control_evaluationU.Editevaluation(evaluation)) then
begin
MessageBox(Handle, '修改成功!', '信息', MB_ICONASTERISK);
//刷新內容
FillData;
end
else
begin
MessageBox(Handle, '修改失??!', '信息', MB_ICONEXCLAMATION);
exit;
end;
self.edt_stdNo.SetFocus;
end;
end;
procedure Tfrm_evaluation.DBGrid_infoCellClick(Column: TColumn);
begin
inherited;
if self.DBGrid_info.Fields[0].IsNull then
begin
self.edt_stdNo.Tag:=0;//保存id
self.edt_stdNo.Text:='';
self.edt_edate.Text :='';
self.cbx_type.ItemIndex:=0;
self.Memo_remark.Text:='';
end
else
begin
self.edt_stdNo.Tag:=self.DBGrid_info.Fields[0].Value;//保存id
self.edt_stdNo.Text:=self.DBGrid_info.Fields[1].Value;
self.edt_edate.Text :=self.DBGrid_info.Fields[2].Value;
self.cbx_type.Text:=self.DBGrid_info.Fields[3].Value;
self.Memo_remark.Text:=self.DBGrid_info.Fields[4].Value;
end;
end;
procedure Tfrm_evaluation.btn_search_stdNoClick(Sender: TObject);
begin
inherited;
self.DataSource_info.DataSet:=
Control_evaluationU.GetEvaluationByStdNO(self.edt_stdNo_s.Text);
self.DBGrid_info.Columns[0].Visible :=false;
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -