ThinForm.pas
上传用户:fh681027
上传日期:2022-07-23
资源大小:1959k
文件大小:3k
源码类别:

Delphi控件源码

开发平台:

Delphi

  1. unit ThinForm;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  5.   Db, DBClient, Grids, DBGrids, StdCtrls, ExtCtrls, ComCtrls, MConnect,
  6.   MidasCon;
  7. type
  8.   TForm1 = class(TForm)
  9.     ClientDataSet1: TClientDataSet;
  10.     DataSource1: TDataSource;
  11.     Panel1: TPanel;
  12.     ButtonUpdate: TButton;
  13.     ButtonSnap: TButton;
  14.     ButtonReload: TButton;
  15.     OpenDialog1: TOpenDialog;
  16.     SaveDialog1: TSaveDialog;
  17.     ClientDataSet2: TClientDataSet;
  18.     ButtonDelta: TButton;
  19.     ButtonUndo: TButton;
  20.     DBGrid1: TDBGrid;
  21.     DCOMConnection1: TDCOMConnection;
  22.     ClientDataSet1DEPT_NO: TStringField;
  23.     ClientDataSet1EMP_NO: TSmallintField;
  24.     ClientDataSet1FIRST_NAME: TStringField;
  25.     ClientDataSet1HIRE_DATE: TSQLTimeStampField;
  26.     ClientDataSet1JOB_CODE: TStringField;
  27.     ClientDataSet1JOB_COUNTRY: TStringField;
  28.     ClientDataSet1JOB_GRADE: TSmallintField;
  29.     ClientDataSet1LAST_NAME: TStringField;
  30.     ClientDataSet1PHONE_EXT: TStringField;
  31.     ClientDataSet1Status: TStringField;
  32.     procedure ButtonUpdateClick(Sender: TObject);
  33.     procedure ButtonSnapClick(Sender: TObject);
  34.     procedure ButtonReloadClick(Sender: TObject);
  35.     procedure ButtonDeltaClick(Sender: TObject);
  36.     procedure ClientDataSet1CalcFields(DataSet: TDataSet);
  37.     procedure ButtonUndoClick(Sender: TObject);
  38.     procedure ClientDataSet1ReconcileError(DataSet: TClientDataSet;
  39.       E: EReconcileError; UpdateKind: TUpdateKind;
  40.       var Action: TReconcileAction);
  41.     procedure ClientDataSet1AfterPost(DataSet: TDataSet);
  42.     procedure Form1Create(Sender: TObject);
  43.   private
  44.     { Private declarations }
  45.   public
  46.     { Public declarations }
  47.   end;
  48. var
  49.   Form1: TForm1;
  50. implementation
  51. {$R *.DFM}
  52. uses
  53.   TypInfo, Reconc, DeltForm;
  54. procedure TForm1.ButtonUpdateClick(Sender: TObject);
  55. begin
  56.   ClientDataSet1.ApplyUpdates (-1);
  57.   FormDelta.Hide;
  58. end;
  59. procedure TForm1.ButtonSnapClick(Sender: TObject);
  60. begin
  61.   if SaveDialog1.Execute then
  62.     ClientDataSet1.SaveToFile (SaveDialog1.FileName);
  63. end;
  64. procedure TForm1.ButtonReloadClick(Sender: TObject);
  65. begin
  66.   if OpenDialog1.Execute then
  67.     ClientDataSet1.LoadFromFile (OpenDialog1.FileName);
  68. end;
  69. procedure TForm1.ButtonDeltaClick(Sender: TObject);
  70. begin
  71.   if ClientDataSet1.ChangeCount > 0 then
  72.   begin
  73.     ClientDataSet2.Data :=
  74.       ClientDataSet1.Delta;
  75.     ClientDataSet2.Open;
  76.     FormDelta.DataSource1.DataSet :=
  77.        ClientDataSet2;
  78.     FormDelta.Show;
  79.   end
  80.   else
  81.     FormDelta.Hide;
  82. end;
  83. procedure TForm1.ClientDataSet1CalcFields(DataSet: TDataSet);
  84. begin
  85.   ClientDataSet1Status.AsString :=
  86.     GetEnumName (TypeInfo(TUpdateStatus),
  87.       Integer (ClientDataSet1.UpdateStatus));
  88. end;
  89. procedure TForm1.ButtonUndoClick(Sender: TObject);
  90. begin
  91.   ClientDataSet1.UndoLastChange (True);
  92.   ClientDataSet1.RefreshRecord;
  93. end;
  94. procedure TForm1.ClientDataSet1ReconcileError(DataSet: TClientDataSet;
  95.   E: EReconcileError; UpdateKind: TUpdateKind;
  96.   var Action: TReconcileAction);
  97. begin
  98.   Action := HandleReconcileError(DataSet, UpdateKind, E);
  99. end;
  100. procedure TForm1.ClientDataSet1AfterPost(DataSet: TDataSet);
  101. begin
  102.   if FormDelta.Visible and
  103.     (ClientDataSet1.ChangeCount > 0) then
  104.   begin
  105.     ClientDataSet2.Data := ClientDataSet1.Delta;
  106.   end;
  107. end;
  108. procedure TForm1.Form1Create(Sender: TObject);
  109. begin
  110.   ClientDataSet1.Open;
  111. end;
  112. end.