📄 useroption.~pas
字号:
//
//模块名称:用户添加及修改
//参数说明:
//
unit useroption;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, basepop, XPMenu, StdCtrls, Buttons, TFlatGroupBoxUnit,
TFlatButtonUnit, TFlatEditUnit, TFlatHintUnit, TFlatCheckBoxUnit,
fcTreeView;
type
Tuseroption_frm = class(Tbasepop_frm)
FlatGroupBox1: TFlatGroupBox;
FlatButton1: TFlatButton;
FlatButton2: TFlatButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
FlatEdit1: TFlatEdit;
FlatEdit2: TFlatEdit;
FlatEdit3: TFlatEdit;
fcTreeView1: TfcTreeView;
procedure FlatButton2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FlatEdit1KeyPress(Sender: TObject; var Key: Char);
procedure FlatButton1Click(Sender: TObject);
private
id:integer;
flag:boolean;
public
{ Public declarations }
end;
var
useroption_frm: Tuseroption_frm;
implementation
uses userright, datashare;
{$R *.dfm}
procedure Tuseroption_frm.FlatButton2Click(Sender: TObject);
begin
inherited;
close;
end;
procedure Tuseroption_frm.FormCreate(Sender: TObject);
var
i:integer;
str:string;
begin
{inherited;
flag:=false;
for i:=0 to componentcount-1 do
begin
if components[i] is TFlatEdit then
(components[i] as TFlatEdit).Text:='';
end;
if Oper_type='0' then
begin
self.Caption:='操作人员新增';
FlatGroupBox1.Caption:='操作人员添加';
FlatButton1.Caption:='添 加';
end
else
begin
self.Caption:='操作人员修改';
FlatGroupBox1.Caption:='操作人员修改';
FlatButton1.Caption:='保 存';
try
with datashare_frm.Query1 do
begin
close;
sql.Clear;
str:='select OPERID,OPPASS,OPMANG from USERS where OPNAME=:para1';
sql.add(str);
params[0].AsString:=useradmin_frm.fcTreeView2.Selected.Text;
prepare;
open;
id:=fieldbyname('OPERID').AsInteger;
FlatEdit1.Text:=useradmin_frm.fcTreeView2.Selected.Text;
FlatEdit2.Text:=fieldbyname('OPPASS').AsString;
FlatEdit3.Text:=FlatEdit2.Text;
params.Clear;
close;
end;
except
on e:exception do
application.MessageBox(pchar(e.Message),'恩普软件',MB_OK+MB_IconStop+MB_SystemModal);
end;
end;
end;}
end;
procedure Tuseroption_frm.FlatEdit1KeyPress(Sender: TObject;
var Key: Char);
begin
inherited;
if(Key=#13)then
perform(WM_NEXTDLGCTL,0,0);
end;
procedure Tuseroption_frm.FlatButton1Click(Sender: TObject);
var
Str:string;
CurItem:TfcTreeNode;
begin
inherited;
if length(trim(Flatedit1.Text))=0 then
begin
application.MessageBox('请输入用户名称!','恩普软件',MB_OK+MB_IconInformation+MB_SystemModal);
Flatedit1.SetFocus;
exit;
end;
if length(trim(Flatedit2.Text))=0 then
begin
application.MessageBox('请输入登录口令!','恩普软件',MB_OK+MB_IconInformation+MB_SystemModal);
Flatedit2.SetFocus;
exit;
end;
if length(trim(Flatedit3.Text))=0 then
begin
application.MessageBox('请输入核对口令!','恩普软件',MB_OK+MB_IconInformation+MB_SystemModal);
Flatedit3.SetFocus;
exit;
end;
if trim(Flatedit2.Text)<>trim(Flatedit3.Text) then
begin
application.MessageBox('请核对口令!','恩普软件',MB_OK+MB_IconInformation+MB_SystemModal);
Flatedit3.SetFocus;
exit;
end;
//if Oper_type='0' then
//begin
try //添加
with datashare_frm.Query1 do
begin
close;
sql.Clear;
str:='select count(*) from users where OPNAME=:p1';
sql.Add(str);
params[0].AsString:=trim(Flatedit1.Text);
prepare;
open;
if fields[0].Value<>0 then
begin
application.MessageBox('该用户名已经存在!','恩普软件',MB_OK+MB_Iconinformation+MB_SystemModal);
flatedit1.SetFocus;
exit;
end;
end;
with datashare_frm.Query2 do
begin
close;
sql.Clear;
str:='insert into USERS(OPNAME,OPPASS,OPMANG) values(:p1,:p2,:p3)';
sql.Add(str);
params[0].AsString:=trim(Flatedit1.Text);
params[1].AsString:=trim(Flatedit2.Text);
params[2].AsString:='0';
Execsql;
{close;
sql.Clear;
str:='select operid from users where opname=:p1';
sql.Add(str);
params[0].AsString:=trim(flatedit1.Text);
prepare;
open;}
end;
application.MessageBox('新用户增加成功!','恩普软件',MB_OK+MB_IconInformation+MB_SystemModal);
flatedit3.Text :='';
flatedit2.Text :='';
flatedit1.Text :='';
{TreeItem:=useradmin_form.fcTreeView2.Items.AddChild(useradmin_form.fcTreeView2.Items.GetFirstNode,Flatedit1.Text);
TreeItem.CheckboxType:=tvctRadioGroup;}
// TreeItem.Checked:=true;
{TreeItem.StringData:=datashare_form.EQuery1.fieldbyname('OPERID').AsString;
TreeItem.StringData2:='0';
TreeItem.ImageIndex:=1;
TreeItem.SelectedIndex:=1;
TreeItem.StateIndex:=1;}
except
on e:exception do
application.MessageBox(pchar(e.Message),'恩普软件',MB_OK+MB_IconStop+MB_SystemModal);
end;
{end else
begin
try
with datashare_frm.Query1 do
begin
close;
sql.Clear;
str:='update users set opname=:p1,oppass=:p2,opmang=:p3 where operid=:p4';
sql.Add(str);
params[0].AsString:=trim(flatedit1.Text);
params[1].AsString:=trim(flatedit2.Text);
params[2].AsString:='0';
params[3].AsInteger:=id;
execsql;
//useradmin_form.fctreeview2.Selected.Text:=trim(flatedit1.Text);
end;
except
on e:exception do
application.MessageBox(pchar(e.Message),'恩普软件',MB_OK+MB_IconStop+MB_SystemModal);
end;
application.MessageBox('用户信息修改成功!','恩普软件',MB_OK+MB_IconInformation+MB_SystemModal);
end;}
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -