📄 addaccountunit.pas
字号:
unit AddAccountUnit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, DBGrids, DB, DBTables, StdCtrls;
type
TAddAccountForm = class(TForm)
Label1: TLabel;
Label2: TLabel;
edtAccount: TEdit;
edtAPwd: TEdit;
Label3: TLabel;
CBPurview: TComboBox;
btadd: TButton;
beexit1: TButton;
Table1: TTable;
DataSource1: TDataSource;
procedure FormShow(Sender: TObject);
procedure btaddClick(Sender: TObject);
procedure beexit1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
AddAccountForm: TAddAccountForm;
implementation
{$R *.dfm}
procedure TAddAccountForm.FormShow(Sender: TObject);
begin
if table1.Active=true then
table1.Active:=false;
table1.DatabaseName:='Addressbook';
table1.TableName:='Login';
table1.Active:=true;
end;
procedure TAddAccountForm.btaddClick(Sender: TObject);
var a:boolean; //判断是否添加用户
begin
a:=true;
if (edtAccount.Text<>'') and (edtApwd.Text<>'') and (CBPurview.Text<>'')then
begin
while not table1.Eof do
begin
if edtAccount.Text=table1.FieldByName('User').AsString then
begin
a:=false;
showmessage('用户名已经存在!');
break;
end
else
begin
a:=true;
table1.Next;
end;
end;
if a=true then
begin
table1.Append;
table1.FieldByName('User').AsString:=edtAccount.Text;
table1.FieldByName('Pwd').AsString:=edtApwd.Text;
table1.FieldByName('Purview').AsString:=CBPurview.Text;
table1.Post;
showmessage('用户添加成功!');
end;
end
else
showmessage('用户名,密码,权限不能为空!');
edtAccount.Text:='';
edtApwd.Text:='';
CBPurview.Text:='';
end;
procedure TAddAccountForm.beexit1Click(Sender: TObject);
begin
table1.Close;
AddAccountForm.Close;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -