?? mzlx.pas
字號:
unit mzlx;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DB, Grids, DBGrids, ExtCtrls, Buttons, ComCtrls,
ToolWin;
type
Tmzlxfrm = class(TForm)
CoolBar1: TCoolBar;
ToolBar1: TToolBar;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
SpeedButton4: TSpeedButton;
SpeedButton5: TSpeedButton;
Panel1: TPanel;
GroupBox1: TGroupBox;
DBGrid1: TDBGrid;
DataSource1: TDataSource;
Label1: TLabel;
Edit1: TEdit;
procedure FormShow(Sender: TObject);
procedure DBGrid1CellClick(Column: TColumn);
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure SpeedButton3Click(Sender: TObject);
procedure SpeedButton4Click(Sender: TObject);
procedure SpeedButton5Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
m:integer;
end;
const
m=0;
var
mzlxfrm: Tmzlxfrm;
implementation
{$R *.dfm}
uses dbdata;
procedure Tmzlxfrm.FormShow(Sender: TObject);
begin
with data.ADOQYmzlx do
begin
close;
sql.Clear;
sql.Add('select * from 民族表');
open
end;
data.ADOQYmzlx.Active:=true;
if data.ADOQYmzlx.FieldByName('民族').Value=null then
application.MessageBox('數據庫中沒有數據,請添加數據!','提示',64)
end;
procedure Tmzlxfrm.DBGrid1CellClick(Column: TColumn);
begin
If DBGrid1.DataSource.DataSet<> Nil then
if DBGrid1.DataSource.DataSet.RecordCount>0 then
edit1.Text:=data.ADOQYmzlx.FieldByName('民族').Value
end;
procedure Tmzlxfrm.SpeedButton1Click(Sender: TObject);
begin
if trim(edit1.Text)<>'' then
begin
with data.ADOpublic do
begin
close;
sql.Clear;
sql.Add('select * from 民族表 where 民族=:a');
parameters.ParamByName('a').Value:=trim(edit1.Text);
open;
end;
if data.ADOpublic.RecordCount>0 then
begin
application.MessageBox('信息不能重復','提示',64);
edit1.Clear;
edit1.SetFocus;
end
else
begin
with data.ADOQYmzlx do
begin
edit;
fieldbyname('民族').Value:=trim(edit1.Text);
post
end;
application.MessageBox('修改成功','提示',64);
edit1.Clear;
end;
end;
end;
procedure Tmzlxfrm.SpeedButton2Click(Sender: TObject);
begin
if trim(edit1.Text)<>'' then
try
with data.ADOQYmzlx do
begin
close;
sql.Clear;
sql.Add('insert 民族表 values (:a)');
parameters.ParamByName('a').Value:=trim(edit1.Text);
execsql;
end;
edit1.Clear;
self.OnShow(sender);
application.MessageBox('添加成功','提示',64);
except
application.MessageBox('系統出錯!','提示',64);
end
else
application.MessageBox('請輸入民族','提示',64);
end;
procedure Tmzlxfrm.SpeedButton3Click(Sender: TObject);
begin
with data.ADOQYygxx do
begin
close;
sql.Clear;
sql.Add('select 民族 from 人事表 where 民族 = :a');
parameters.ParamByName('a').Value:=trim(edit1.Text);
open;
end;
if data.ADOQYygxx.RecordCount>0 then
application.MessageBox('此信息已經使用,不能刪除!','警告',64)
else
if messagebox(self.Handle,'真的要刪除嗎?','提示',mb_yesno+mb_iconquestion)=idyes then
begin
data.ADOQYmzlx.Delete;
edit1.Clear;
end;
end;
procedure Tmzlxfrm.SpeedButton4Click(Sender: TObject);
begin
edit1.Clear;
end;
procedure Tmzlxfrm.SpeedButton5Click(Sender: TObject);
begin
close;
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -