📄 operatormanage.pas
字号:
unit operatormanage;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, SUIForm, DB, DBTables, SUIButton, SUIImagePanel,
SUIGroupBox, SUIRadioGroup, StdCtrls, SUIEdit;
type
Toperatormanageform = class(TForm)
suiform1: TsuiForm;
Lable1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
suiRadioGroup1: TsuiRadioGroup;
suiCheckGroup1: TsuiCheckGroup;
suiButton1: TsuiButton;
suiButton2: TsuiButton;
suiCheckBox1: TsuiCheckBox;
suiCheckBox2: TsuiCheckBox;
suiCheckBox3: TsuiCheckBox;
suiRadioButton1: TsuiRadioButton;
suiRadioButton2: TsuiRadioButton;
suiRadioButton3: TsuiRadioButton;
Table1: TTable;
suiedit1: TsuiEdit;
suiedit2: TsuiEdit;
suiedit3: TsuiEdit;
suiedit4: TsuiEdit;
procedure FormActivate(Sender: TObject);
procedure suiButton2Click(Sender: TObject);
procedure suiButton1Click(Sender: TObject);
procedure suiRadioButton3Click(Sender: TObject);
procedure suiedit1Exit(Sender: TObject);
procedure suiRadioButton1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
operatormanageform: Toperatormanageform;
i:integer;
implementation
{$R *.dfm}
procedure Toperatormanageform.FormActivate(Sender: TObject);
begin
suiedit1.Text:='';
suiedit2.Text:='';
suiedit3.Text:='';
suiedit4.Text:='';
suiedit4.Enabled:=false;
i:=3;
//检测操作员表是否存在
table1.DatabaseName:='DBMS';
table1.TableName:='operator';
end;
//退出模块
procedure Toperatormanageform.suiButton2Click(Sender: TObject);
begin
close;
end;
procedure Toperatormanageform.suiButton1Click(Sender: TObject);
var test:boolean;
begin
table1.Active:=true;
table1.EditKey;
table1.FieldByName('name').AsString:=suiedit1.Text;
table1.GotoKey;
if table1.FieldByName('name').AsString=suiedit1.Text then
test:=true
else test:=false;
if suiradiobutton1.Checked then
//用户选中增加操作员方式
begin
if not test then
with table1 do
begin
append;
edit;
fieldbyname('name').AsString:=suiedit1.Text;
fieldbyname('password').AsString:=suiedit2.Text;
fieldbyname('department').AsString:=suiedit3.Text;
fieldbyname('time').AsDateTime:=date();
fieldbyname('right_1').AsBoolean:=suicheckbox1.Checked;
fieldbyname('right_2').AsBoolean:=suicheckbox2.Checked;
fieldbyname('right_3').AsBoolean:=suicheckbox3.Checked;
post;
end
else begin
application.MessageBox('改用户存在,请重新输入!','提示信息',MB_OK);
suiedit1.SetFocus;
end;
end;
if suiradiobutton2.Checked then
//选择删除模式
if test then
begin
table1.Delete;
suiedit1.SetFocus;
end
else begin
application.MessageBox('改用户不存在,请重新输入!','提示信息',MB_OK);
suiedit1.SetFocus;
end;
if suiradiobutton3.Checked then
//用户资料修改方式
if test then
begin
with table1 do
begin
active:=true;
EditKey;
fieldbyname('name').AsString:=suiedit1.Text;
gotokey;
edit;
fieldbyname('password').AsString:=suiedit2.Text;
fieldbyname('department').AsString:=suiedit3.Text;
fieldbyname('time').AsDateTime:=date();
fieldbyname('right_1').AsBoolean:=suicheckbox1.Checked;
fieldbyname('right_2').AsBoolean:=suicheckbox2.Checked;
fieldbyname('right_3').AsBoolean:=suicheckbox3.Checked;
post;
end;
end;
table1.Active:=false;
suiedit1.Text:='';
suiedit2.Text:='';
suiedit3.Text:='';
suiedit4.Text:='';
suicheckbox1.Checked:=false;
suicheckbox2.Checked:=true;
suicheckbox3.Checked:=false;
suiedit1.SetFocus;
suiradiobutton1.Enabled:=false;
suiradiobutton2.Enabled:=false;
suiradiobutton3.Enabled:=false;
end;
procedure Toperatormanageform.suiRadioButton3Click(Sender: TObject);
begin
if suiedit1.Text<>'' then
begin
table1.Active:=true;
table1.EditKey;
table1.FieldByName('name').AsString:=suiedit1.Text;
table1.GotoKey;
if table1.FieldByName('name').AsString=suiedit1.Text then
begin
suiedit2.Text:=table1.fieldbyname('password').AsString;
suiedit3.Text:=table1.fieldbyname('department').AsString;
suicheckbox1.Checked:=table1.FieldByName('right_1').AsBoolean;
suicheckbox2.Checked:=table1.FieldByName('right_2').AsBoolean;
suicheckbox3.Checked:=table1.FieldByName('right_3').AsBoolean;
suiedit4.Text:=datetostr(date());
end
else begin
application.MessageBox('改用户不存在,请重新输入!','提示信息',MB_OK);
suiedit1.SetFocus;
end;
end;
end;
procedure Toperatormanageform.suiedit1Exit(Sender: TObject);
begin
suiradiobutton1.Enabled:=true;
suiradiobutton2.Enabled:=true;
suiradiobutton3.Enabled:=true;
end;
procedure Toperatormanageform.suiRadioButton1Click(Sender: TObject);
begin
suiedit4.Text:=datetostr(date());
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -