errore.pas

来自「一套来自国外的ERP系统,有兴趣的朋友可以看看!」· PAS 代码 · 共 79 行

PAS
79
字号
unit errore;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ExtCtrls, Printers;

type
  Terrore_form = class(TForm)
    Panel1: TPanel;
    Label1: TLabel;
    Panel2: TPanel;
    spiegazioni: TMemo;
    Chiudi: TButton;
    StampaBtn: TButton;
    errore_Label: TMemo;
    PrintDialog1: TPrintDialog;
    procedure StampaBtnClick(Sender: TObject);
    procedure ChiudiClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure GestisciErrore(Sender: TObject; E: Exception);
    procedure SpiegaKey;
    procedure SpiegaAccess;
    procedure ScriviErrore(err,riga: string);
  end;

var
  errore_form: Terrore_form;

implementation

{$R *.DFM}
procedure Terrore_form.GestisciErrore(Sender: TObject; E: Exception) ;
Const
 nomeFile     : String = 'errbanco.txt' ;

Var
   ErrFile    : TextFile ;
   riga       : String ;
   Componente : Tcomponent ;

begin

 Assignfile(ErrFile,nomefile) ;
 If FileExists(nomefile) then
  Append(ErrFile)
 else
  Rewrite(ErrFile) ;
 riga := '"' + DateTimeToStr(now) + '","' + e.message + '","' +
         Sender.ClassName + '"' ;
 if sender is tcomponent then
  begin
   Componente := Sender as Tcomponent ;
   Repeat
    Riga := riga + ',' + Componente.Name ;
    Componente := Componente.Owner ;
   until Componente = nil ;
  end ;

 WriteLn(ErrFile,Riga) ;
 CloseFile(ErrFile) ;
 Errore_form := Terrore_form.Create(nil) ;
 ScriviErrore(e.message,Riga) ;
 if e.message = 'Key violation' then
    SpiegaKey ;
 if pos('ACCESS',Uppercase(e.message)) > 0 then
    SpiegaAccess ;
 Errore_form.Show ;
end;

procedure Terrore_form.SpiegaAccess;
begin
 Spiegazioni.Lines.Add('Istruzioni : ') ;
 Spiegazioni.Lines.Add('Generalmente questo errore si verifica in due casi :') ;
 Spiegazioni.Lines.Add('1. La memoria del sistema non 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?