?? 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 + -