home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / Runimage / Delphi50 / Help / Examples / Update / CUPERROR.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1999-08-11  |  1.5 KB  |  64 lines

  1. unit CUpError;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   StdCtrls, ExtCtrls,DB,dbitypes,dbiprocs,dbtables;
  8.  
  9. type
  10.   TFormError = class(TForm)
  11.     Panel1: TPanel;
  12.     LabelOld: TLabel;
  13.     LabelNew: TLabel;
  14.     LabelMessage: TLabel;
  15.     EditOld: TEdit;
  16.     EditNew: TEdit;
  17.     ButtonIgnore: TButton;
  18.     ButtonRetry: TButton;
  19.     ButtonAbort: TButton;
  20.  
  21.   private
  22.     { Private declarations }
  23.   public
  24.   function ErrorDecision(DataSet : TDataSet; E: EDataBaseError;
  25.                                  UpdateKind: TUpdateKind):TUpdateAction;
  26.     { Public declarations }
  27.   end;
  28.  
  29. var
  30.   FormError: TFormError;
  31.  
  32. implementation
  33.  
  34. uses CUpDM;
  35.  
  36. {$R *.DFM}
  37.  
  38. function TFormError.Errordecision(Dataset: TDataSet;
  39.              E: EDataBaseError; UpdateKind: TUpdateKind):
  40.              TUpdateAction;
  41.     const
  42.       UpdateKindStr: array[TUpdateKind] of String =('Modify Error',
  43.                      'Insert Error','Delete Error');
  44.       begin
  45.         Panel1.caption := UpdateKindStr[UpdateKind];
  46.         LabelMessage.Caption := E.Message;
  47.         EditOld.text := DataModuleCache.QueryCache.Fields[0].OldValue;
  48.         EditNew.text := DataModuleCache.QueryCache.Fields[0].NewValue;
  49.         ShowModal;
  50.         case ModalResult of
  51.         mrRetry:
  52.         begin
  53.           DataModuleCache.QueryCache.Fields[0].newvalue := EditNew.text;
  54.           Result := uaRetry;
  55.         end;
  56.         mrIgnore: Result := uaSkip;
  57.         else
  58.           result := uaAbort;
  59.  
  60.       end;
  61.    end;
  62.  
  63. end.
  64.