-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathUtrans.pas
More file actions
73 lines (61 loc) · 1.61 KB
/
Utrans.pas
File metadata and controls
73 lines (61 loc) · 1.61 KB
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
unit Utrans;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Data.DB, FireDAC.Stan.Intf,
FireDAC.Stan.Option, FireDAC.Stan.Param, FireDAC.Stan.Error, FireDAC.DatS,
FireDAC.Phys.Intf, FireDAC.DApt.Intf, FireDAC.Stan.Async, FireDAC.DApt,
FireDAC.Comp.DataSet, FireDAC.Comp.Client, Vcl.StdCtrls, Vcl.ExtCtrls,
Vcl.DBCtrls, Vcl.Grids, Vcl.DBGrids;
type
TTransForm = class(TForm)
DBGrid1: TDBGrid;
DBNavigator1: TDBNavigator;
Button1: TButton;
DBGrid2: TDBGrid;
FDQuery1: TFDQuery;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
TransForm: TTransForm;
implementation
{$R *.dfm}
uses Udm;
procedure TTransForm.Button1Click(Sender: TObject);
begin
DM.FDConnection1.StartTransaction;
try
try
FDQuery1.Close;
FDQuery1.SQL.Text := 'delete from insa where dept_code =:code';
FDQuery1.Params[0].AsString := dm.Dept.Fields[0].AsString;
FDQuery1.ExecSQL;
except
ShowMessagE('사원 삭제 오류');
raise;
end;
try
DM.Dept.Delete;
except
ShowMessage('부서 삭제 오류');
raise;
end;
DM.FDConnection1.Commit;
except
DM.FDConnection1.Rollback;
end;
DM.Dept.Refresh;
DM.Insa.Refresh;
end;
procedure TTransForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if DM.FDConnection1.InTransaction then
DM.FDConnection1.Rollback;
Action := caFree;
end;
end.