📄 gzjbwh.pas
字号:
unit Gzjbwh;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Controls, Forms, Dialogs,
Grids, DBGrids, DB, StdCtrls, ExtCtrls, ADODB, GZGLCommon, Menus;
type
TGzjbForm = class(TForm)
dsGzjb: TDataSource;
adotGzjb: TADOTable;
dbGzjb: TDBGrid;
pmGzjb: TPopupMenu;
pnDel: TMenuItem;
ACtrlA1: TMenuItem;
ADOQuery1: TADOQuery;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure pnDelClick(Sender: TObject);
procedure pmGzjbPopup(Sender: TObject);
procedure ACtrlA1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
implementation
{$R *.dfm}
{ TGZJBForm }
procedure TGzjbForm.FormCreate(Sender: TObject);
var
l_adoq: TADOQuery;
begin
with adotGzjb do
begin
Connection := AdoGzgl;
Open;
end;
l_adoq := TADOQuery.Create(nil);
with l_adoq do
try
Connection := AdoGzgl;
l_adoq.SQL.Text := 'Select * from GzglField where GridName = ''dbGzjb''';
Open;
InitDBGrid(l_adoq, dbGzjb);
Close;
finally
Free;
end;
end;
procedure TGzjbForm.FormDestroy(Sender: TObject);
begin
with adotGzjb do
if Active then Close;
end;
procedure TGzjbForm.pnDelClick(Sender: TObject);
begin
if Application.MessageBox('是否删除此记录?', '确认', 1) = 1 then
begin
// 查询是否有员工使用了该工资级别,如有则不能删除
with TADOQuery.Create(nil) do
try
Connection := AdoGzgl;
Sql.Text := 'Select JbID from Zyxx where JbID = ' +
IntToStr(adotGzjb.fieldByname('JbID').AsInteger);
Open;
if Recordcount > 0 then
Application.MessageBox('工资级别已被引用,不能删除!', '提示')
else
adotGzjb.Delete;
Close;
finally
Free;
end;
end;
end;
procedure TGzjbForm.pmGzjbPopup(Sender: TObject);
begin
pnDel.Enabled := not (adotGzjb.Bof and adotGzjb.Eof);
end;
procedure TGzjbForm.ACtrlA1Click(Sender: TObject);
begin
with TADOQuery.Create(nil) do
Connection := AdoGzgl;
adotgzjb.row =adotgzjb.row+1;
sql.text:=('jbmc'+'jbgz'+'zwgz');
adotGzjb.add(sql.text);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -