1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
unit MAQLM;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DBXpress, DB, SqlExpr, FMTBcd, DBClient, Provider, Grids, DBGrids,
ExtCtrls, DBCtrls, StdActns, ActnList, ImgList, Menus, StdCtrls;
type
TForm1 = class(TForm)
SQLConnection1: TSQLConnection;
SQLDataSet1: TSQLDataSet;
DataSetProvider1: TDataSetProvider;
ClientDataSet1: TClientDataSet;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
DBNavigator1: TDBNavigator;
ImageList1: TImageList;
ActionList1: TActionList;
EditCut1: TEditCut;
EditCopy1: TEditCopy;
EditPaste1: TEditPaste;
Action1: TAction;
Action2: TAction;
MainMenu1: TMainMenu;
Fichier1: TMenuItem;
Quitter1: TMenuItem;
Edition1: TMenuItem;
Couper1: TMenuItem;
Copier1: TMenuItem;
Coller1: TMenuItem;
N1: TMenuItem;
Misejourimmdiate1: TMenuItem;
Button1: TButton;
Label1: TLabel;
Image1: TImage;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Action2Execute(Sender: TObject);
procedure Action1Execute(Sender: TObject);
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Action1Execute(Sender: TObject);
begin
if ClientDataSet1.State in [dsEdit, dsInsert] then
ClientDataSet1.ApplyUpdates(-1);
// ClientDataSet1.Post; // Ca sert a rien si y a un ApplyUpdate de fait après
end;
procedure TForm1.Action2Execute(Sender: TObject);
begin
Close;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
var
Option: TMessageButton;
begin
Action := caFree;
if ClientDataSet1.State in [dsEdit, dsInsert] then
// ClientDataSet1.Post; // Ca sert a rien si y a un ApplyUpdate de fait après
if ClientDataSet1.ChangeCount> 0 then
begin
Option := Application.MessageBox(
'Il y a des mises à jour en attente. Voulez-vous les écrire dans la base ?',
'Mises à jour en attente',[smbYes, smbNo, smbCancel], smsWarning, smbYes);
case Option of
smbYes: ClientDataSet1.ApplyUpdates(-1);
smbNo : ClientDataSet1.Cancel; // manque ça
smbCancel: Action := caNone;
end;
end;
end;
end. |
Partager