📄 deleteuser.pas
字号:
unit DeleteUser;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, Buttons, DB, SUIForm, SUIDlg, SUIButton;
type
TFrmDelete = class(TForm)
suiForm1: TsuiForm;
Panel1: TPanel;
ListBox1: TListBox;
suiMessageDialog1: TsuiMessageDialog;
suiButton1: TsuiButton;
suiButton2: TsuiButton;
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
FrmDelete: TFrmDelete;
implementation
uses DataModule, yhgl, pubunit;
{$R *.dfm}
procedure TFrmDelete.BitBtn2Click(Sender: TObject);
begin
Close;
end;
procedure TFrmDelete.BitBtn1Click(Sender: TObject);
var UserName : String;
begin
if ListBox1.ItemIndex = -1 then Exit;
UserName:=ListBox1.Items[ListBox1.ItemIndex];
with DataModule1.tbl_Power do begin
if Locate('用户名',trim(UserName),[loCaseInsensitive]) then begin
suiMessageDialog1.ButtonCount := 2;
suiMessageDialog1.Button1Caption := '是(&Y)';
suiMessageDialog1.Button2Caption := '否(&N)';
suiMessageDialog1.Button1ModalResult := mrYes;
suiMessageDialog1.Button2ModalResult := mrNo;
suiMessageDialog1.Caption := Self.Caption ;
suiMessageDialog1.IconType := suiHelp;
suiMessageDialog1.Text := '是否删除用户名为 '+UserName+' 的记录?';
if suiMessageDialog1.ShowModal = mrYes then begin
Delete ;
listBox1.Items.Delete(listBox1.itemindex);
end;
end;
end;
Close;
end;
procedure TFrmDelete.FormCloseQuery(Sender: TObject;
var CanClose: Boolean);
begin
with DataModule1 do
begin
tbl_Power.Next ;
if tbl_Power.UpdatesPending then
begin
try
db1.StartTransaction ;
tbl_Power.ApplyUpdates ;
tbl_Power.CommitUpdates ;
db1.Commit ;
except
on E : Exception do
begin
suiMessageDialog1.ButtonCount := 1;
suiMessageDialog1.Button1Caption := '确定(&S)';
suiMessageDialog1.Button1ModalResult := mrOK;
suiMessageDialog1.Caption := Self.Caption ;
suiMessageDialog1.IconType := suiStop;
suiMessageDialog1.Text := '数据错误无法保存:'+E.Message ;
suiMessageDialog1.ShowModal ;
tbl_Power.CancelUpdates ;
db1.Rollback ;
Abort ;
end;
end;
end;
end;
end;
procedure TFrmDelete.FormCreate(Sender: TObject);
begin
ChangeInterface(Self,suiForm1);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -