?? whcd.pas
字號:
unit whcd;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, Grids, DBGrids, StdCtrls, ExtCtrls, Buttons, ComCtrls,
ToolWin;
type
Twhcdfrm = class(TForm)
CoolBar1: TCoolBar;
ToolBar1: TToolBar;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
SpeedButton4: TSpeedButton;
SpeedButton5: TSpeedButton;
Panel1: TPanel;
GroupBox1: TGroupBox;
Label1: TLabel;
Edit1: TEdit;
DBGrid1: TDBGrid;
DataSource1: TDataSource;
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;
var
whcdfrm: Twhcdfrm;
const
m=0;
implementation
uses dbdata;
{$R *.dfm}
procedure Twhcdfrm.FormShow(Sender: TObject);
begin
with data.ADOQYwhcd do
begin
close;
sql.Clear;
sql.Add('select * from 文化程度表');
open;
end;
data.ADOQYwhcd.Active:=true;
if data.ADOQYwhcd.FieldByName('文化程度').Value=null then
application.MessageBox('數據庫中沒有數據,請添加數據!','提示',64)
end;
procedure Twhcdfrm.DBGrid1CellClick(Column: TColumn);
begin
If DBGrid1.DataSource.DataSet<> Nil then
if DBGrid1.DataSource.DataSet.RecordCount>0 then
edit1.Text:=data.ADOQYwhcd.FieldByName('文化程度').Value
end;
procedure Twhcdfrm.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.ADOQYwhcd do
begin
edit;
fieldbyname('文化程度').Value:=trim(edit1.Text);
post
end;
application.MessageBox('修改成功','提示',64);
edit1.Clear;
end;
end
else
application.MessageBox('信息不能為空','提示',64);
end;
procedure Twhcdfrm.SpeedButton2Click(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.ADOQYwhcd.Delete;
edit1.Clear;
end;
end;
procedure Twhcdfrm.SpeedButton3Click(Sender: TObject);
begin
if trim(edit1.Text)<>'' then
try
with data.ADOQYwhcd do
begin
close;
sql.Clear;
sql.Add('insert 文化程度表 values (:a)');
parameters.ParamByName('a').Value:=trim(edit1.Text);
execsql;
end;
self.OnShow(sender);
application.MessageBox('添加成功','提示',64);
edit1.Clear;
except
application.MessageBox('系統出錯','警告',64);
close;
end
else
application.MessageBox('請輸入文化程度','提示',64);
end;
procedure Twhcdfrm.SpeedButton4Click(Sender: TObject);
begin
edit1.Clear;
end;
procedure Twhcdfrm.SpeedButton5Click(Sender: TObject);
begin
close;
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -