📄 gly.pas
字号:
unit gly;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, Grids, DBGrids, StdCtrls, ExtCtrls, Buttons, ComCtrls,
ToolWin;
type
Tglyfrm = class(TForm)
CoolBar1: TCoolBar;
ToolBar1: TToolBar;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
SpeedButton4: TSpeedButton;
Panel1: TPanel;
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Panel2: TPanel;
DBGrid1: TDBGrid;
DataSource1: TDataSource;
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure SpeedButton3Click(Sender: TObject);
procedure SpeedButton4Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure DBGrid1CellClick(Column: TColumn);
private
{ Private declarations }
public
{ Public declarations }
end;
var
glyfrm: Tglyfrm;
implementation
{$R *.dfm}
uses dbdata;
procedure Tglyfrm.SpeedButton1Click(Sender: TObject);
begin
if edit1.Text='' then
application.MessageBox('请输入操作员名称','提示',64)
else
if edit2.Text='' then
application.MessageBox('请输入操作员密码','提示',64)
else
begin
with data.ADOlogin do
begin
close;
sql.Clear;
sql.Add('select * from 操作员信息表 where 操作员名称=:a');
parameters.ParamByName('a').Value:=trim(edit1.Text);
open;
end;
if data.ADOlogin.RecordCount>0 then
begin
application.MessageBox('操作员已经存在!','提示',64);
edit1.Clear;
edit2.Clear;
edit1.SetFocus;
end
else
try
with data.ADOlogin do
begin
close;
sql.Clear;
sql.Add('insert 操作员信息表 values (:a,:b)');
parameters.ParamByName('a').Value:=trim(edit1.Text);
parameters.ParamByName('b').Value:=trim(edit2.Text);
execsql
end;
self.OnShow(sender);
application.MessageBox('添加成功','提示',64);
edit1.Clear;
edit2.Clear;
except
application.MessageBox('添加失败','提示',64);
end;
end;
end;
procedure Tglyfrm.SpeedButton2Click(Sender: TObject);
begin
with data.ADOlogin do
begin
edit;
FieldByName ('操作员名称').Value:=trim(edit1.Text);
fieldbyname ('操作员密码').Value:=trim(edit2.Text);
post;
end;
application.MessageBox('修改成功','提示',64);
edit1.Clear;
edit2.Clear;
end;
procedure Tglyfrm.SpeedButton3Click(Sender: TObject);
begin
if messagebox(self.Handle,'确定要删除吗?','提示',mb_yesno+mb_iconquestion)=idyes then
data.ADOlogin.Delete;
edit1.Clear;
edit2.Clear;
end;
procedure Tglyfrm.SpeedButton4Click(Sender: TObject);
begin
close;
end;
procedure Tglyfrm.FormShow(Sender: TObject);
begin
with data.ADOlogin do
begin
close;
sql.Clear;
sql.Add('select * from 操作员信息表');
open;
end;
data.ADOlogin.Active:=true;
end;
procedure Tglyfrm.DBGrid1CellClick(Column: TColumn);
begin
If DBGrid1.DataSource.DataSet<> Nil then
if DBGrid1.DataSource.DataSet.RecordCount>0 then
edit1.Text:=data.ADOlogin.FieldByName('操作员名称').Value;
edit2.Text:=data.ADOlogin.FieldByName('操作员密码').Value;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -