📄 ag_histroylist.pas
字号:
unit AG_HistroyList;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, ExtCtrls, DB, ADODB;
type
TFrmAG_HistroyList = class(TForm)
Panel1: TPanel;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
Label1: TLabel;
ListBox1: TListBox;
ADOQuery1: TADOQuery;
Button1: TButton;
procedure FormShow(Sender: TObject);
procedure ListBox1DblClick(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
ReportENameList: TStrings;
end;
function SetWork(var AReportCName, AReportEName: string): Boolean;
implementation
uses main, PublicUnit;
{$R *.dfm}
function SetWork(var AReportCName, AReportEName: string): Boolean;
var
FrmAG_HistroyList: TFrmAG_HistroyList;
begin
Result := False;
Application.CreateForm(TFrmAG_HistroyList, FrmAG_HistroyList);
with FrmAG_HistroyList do
begin
if ShowModal = mrOK then
if ListBox1.ItemIndex <> -1 then
begin
AReportCName := ListBox1.Items[ListBox1.ItemIndex];
AReportEName := GetSaveReportDir + ReportENameList[ListBox1.ItemIndex];
Result := True;
end;
Free;
end;
end;
{-------------------------------------------------------------------------------}
procedure TFrmAG_HistroyList.FormShow(Sender: TObject);
begin
ReportENameList := TStringList.Create;
with ADOQuery1 do
begin
Close;
ConnectionString := 'Provider=SQLOLEDB.1;Persist Security Info=False;User ID='
+ FrmMain.DbUser + ';Password=' + FrmMain.DbPass + ';Initial Catalog=' +
FrmMain.DbName + ';Data Source=' + PublicUnit.ServerName;
Sql.Clear;
Sql.Add('Select *');
Sql.Add('From Report_HistroyList');
try
Open;
except
MessageDlg('数据库无法打开,无法列出列表!', mtInformation, [mbOk], 0);
Exit;
end;
ListBox1.Items.Clear;
while not Eof do
begin
ListBox1.Items.Add(FieldByName('中文名称').AsString);
ReportENameList.Add(FieldByName('英文名称').AsString);
Next;
end;
Close;
end;
if ListBox1.Items.Count <> 0 then
ListBox1.ItemIndex := 0;
end;
{-------------------------------------------------------------------------------}
procedure TFrmAG_HistroyList.ListBox1DblClick(Sender: TObject);
begin
BitBtn1.Click;
end;
procedure TFrmAG_HistroyList.Button1Click(Sender: TObject);
var
ReportHistroyCName, ReportHistroyEName: string;
begin
Function_DB_ReadRight.UserOrUserGroupName := UserName;
Function_DB_ReadRight.UserOrUserGroupIdentify := '用户';
Function_DB_ReadRight.FunctionResourceName := '历史删除';
if Function_DB_ReadRight.GetFunctionResourceRight <> 1 then
begin
MessageDlg('对不起,您没有权限执行当前工作!', mtInformation, [mbOk], 0);
Exit;
end;
if ListBox1.Items.Count = 0 then
Exit;
if MessageDlg('确定要删除历史统计项' + ListBox1.Items[ListBox1.ItemIndex] +
'吗?', mtConfirmation, [mbYes, mbNo], 0) <> mrYes then
Exit;
ReportHistroyCName := ListBox1.Items[ListBox1.ItemIndex];
ReportHistroyEName := ReportENameList[ListBox1.ItemIndex];
with ADOQuery1 do
begin
Close;
ConnectionString := 'Provider=SQLOLEDB.1;Persist Security Info=False;User ID='
+ FrmMain.DbUser + ';Password=' + FrmMain.DbPass + ';Initial Catalog=' +
FrmMain.DbName + ';Data Source=' + PublicUnit.ServerName;
Sql.Clear;
Sql.Add('Delete Report_HistroyList');
Sql.Add('Where 中文名称=''' + ReportHistroyCName + ''' and 英文名称=''' +
ReportHistroyEName + '''');
try
ExecSql;
except
ShowMessage('无法删除当前工作!');
Exit;
end;
Close;
if FileExists(GetSaveReportDir + ReportHistroyEName) then
DeleteFile(GetSaveReportDir + ReportHistroyEName);
WriteToHistroy('历史删除', Date, Time, '删除历史统计分析《' +
ReportHistroyCName + '》', UserName);
ReportENameList.Delete(ListBox1.ItemIndex);
ListBox1.Items.Delete(ListBox1.ItemIndex);
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -