-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathuInsa.pas
More file actions
455 lines (407 loc) · 12.5 KB
/
uInsa.pas
File metadata and controls
455 lines (407 loc) · 12.5 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
unit uinsa;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Data.DB, Vcl.Grids, Vcl.DBGrids,
Vcl.ComCtrls, Vcl.Buttons, Vcl.StdCtrls, Vcl.ExtCtrls, Vcl.DBCtrls, Vcl.Mask,
Vcl.ExtDlgs, FireDAC.Stan.Error,FireDAC.Phys.IBWrapper,System.DateUtils,Firedac.Stan.ExprFuncs,
UmyFrame,VCLTee.Series,FireDAC.Stan.Option;
type
TInsaForm = class(TForm)
PageControl1: TPageControl;
tabsheet1: TTabSheet;
tabsheet2: TTabSheet;
tabsheet3: TTabSheet;
TabControl1: TTabControl;
DBGrid1: TDBGrid;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
SpeedButton4: TSpeedButton;
Label1: TLabel;
ComboBox1: TComboBox;
Label2: TLabel;
Edit1: TEdit;
사번: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
DBEdit1: TDBEdit;
DBEdit2: TDBEdit;
DBEdit3: TDBEdit;
DBEdit4: TDBEdit;
DBEdit5: TDBEdit;
DBComboBox1: TDBComboBox;
DBLookupComboBox1: TDBLookupComboBox;
Label9: TLabel;
DBImage1: TDBImage;
DBRadioGroup1: TDBRadioGroup;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
OpenPictureDialog1: TOpenPictureDialog;
RadioGroup1: TRadioGroup;
TFrame11: TFrame1;
TabSheet4: TTabSheet;
CheckBox2: TCheckBox;
Button9: TButton;
Button10: TButton;
CheckBox3: TCheckBox;
DBGrid3: TDBGrid;
DBGrid2: TDBGrid;
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure SpeedButton3Click(Sender: TObject);
procedure SpeedButton4Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure ComboBox1Change(Sender: TObject);
procedure Edit1Change(Sender: TObject);
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
procedure TabControl1Change(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Label9Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure RadioGroup1Click(Sender: TObject);
procedure PageControl1DragDrop(Sender, Source: TObject; X, Y: Integer);
procedure PageControl1DragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
procedure PageControl1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure PageControl1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure PageControl1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure PageControl1StartDrag(Sender: TObject;
var DragObject: TDragObject);
procedure CheckBox3Click(Sender: TObject);
procedure Button10Click(Sender: TObject);
procedure Button9Click(Sender: TObject);
procedure CheckBox2Click(Sender: TObject);
private
FDraging: Boolean;
FDragPos: TPoint;
FDragTop: Integer;
FDragLeft:Integer;
{ Private declarations }
public
{ Public declarations }
end;
var
InsaForm: TInsaForm;
implementation
uses udm;
{$R *.dfm}
type
TTabDragObject = class(TBaseDragControlObject)
private
PageControl: TPageControl;
DragImageList: TImageList;
PageIndex: Integer;
CurrentWnd: HWnd;
protected
procedure WndProc(var Msg: TMessage); override;
function GetDragCursor(Accepted: Boolean; X, Y: Integer): TCursor; override;
end;
var
Newseries:TBarSeries;
procedure TInsaForm.PageControl1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if Button = mbLeft then FDraging := False;
end;
procedure TInsaForm.PageControl1StartDrag(Sender: TObject;
var DragObject: TDragObject);
begin
DragObject := TTabDragObject.Create( TPageControl(Sender) );
TTabDragObject(DragObject).PageControl := TPageControl(Sender);
TTabDragObject(DragObject).PageIndex := TPageControl(Sender).ActivePageIndex;
// TTabDragObject(DragObject).DragImageList := ImageList_Drag;
end;
procedure TInsaForm.Button10Click(Sender: TObject);
begin
DM.Insa.close;
dm.Insa.Disconnect;
DM.Insa.FetchOptions.RecsSkip := 5;
DM.Insa.FetchOptions.RecsMax := 5;
DM.Insa.Open;
end;
procedure TInsaForm.Button1Click(Sender: TObject);
begin
dm.Insa.Insert; //append;
end;
procedure TInsaForm.Button2Click(Sender: TObject);
begin
if messageDlg('정말 삭제 할래?', mtconfirmation, [mbYes, mbNo], 0) = mrYes then
try
dm.Insa.Delete;
except
on E : EFDDBEngineException do
if e.Kind = ekUKViolated then
showmessage('삭제 키 오류')
else if e.Kind = ekRecordLocked then
ShowMessage('레코드 락')
else ShowMessage(IntToStr(e.ErrorCode));
end;
end;
procedure TInsaForm.Button3Click(Sender: TObject);
begin
dm.Insa.Cancel;
end;
procedure TInsaForm.Button4Click(Sender: TObject);
begin
// if dm.Insa.State = DsBrowse then
// raise Exception.Create('조회중');
try
DM.Insa.Post;
except
on e:eFDDBEngineException do
if e.kind = ekUKViolated then
showmessage('중복키오류')
else if e.Kind = ekFKviolated then
showmessage('포린키오류')
else showmessage(e.Message);
end;
end;
procedure TInsaForm.Button9Click(Sender: TObject);
begin
DM.Insa.FetchNext;
end;
procedure TInsaForm.CheckBox2Click(Sender: TObject);
begin
DM.Insa.Close;
if TCheckBox(Sender).Checked then
begin
DM.Insa.FetchOptions.RowsetSize := 3;
DM.Insa.FetchOptions.Mode := TFDFetchMode.fmManual;
end
else
DM.Insa.FetchOptions.Mode := TFDFetchMode.fmOnDemand;
dm.Insa.Open;
end;
procedure TInsaForm.CheckBox3Click(Sender: TObject);
begin
// if TCheckBox(Sender).Checked then
// DM.subInsa.FetchOptions.DetailDelay := StrToIntDef(Edit1.Text, 300)
//else
// DM.subInsa.FetchOptions.DetailDelay := 0;
end;
procedure TInsaForm.ComboBox1Change(Sender: TObject);
begin
case ComboBox1.itemindex of
0:
begin
dm.Insa.IndexName := 'i_id';
dm.insaid.index := 0;
dm.insaName.index := 1;
end;
1:
begin
dm.Insa.IndexName := 'i_name';
dm.insaid.index := 1;
dm.insaName.index := 0;
end;
2:
dm.Insa.IndexName := 'i_dept';
end;
end;
procedure TInsaForm.Edit1Change(Sender: TObject);
begin
dm.Insa.IndexFieldNames := 'Name';
dm.Insa.FindNearest([edit1.text]);
end;
procedure TInsaForm.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if key =#13 then
// if not dm.Insa.FindKey([edit1.Text]) then
// showmessage('그런 사람 없음');
if not dm.insa.locate('name', edit1.text, []) then
showmessage('그런 사람 없음');
// [locaseinsensitive, lopartialkey])
end;
procedure TInsaForm.FormActivate(Sender: TObject);
begin
dm.InsaSourceStateChange(dm.InsaSource);
dm.InsaSourceDataChange(dm.insasource, dm.insaid);
end;
procedure TInsaForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
dm.InsaSource.OnStateChange := nil;
DM.InsaSource.OnDataChange := nil;
action := cafree;
end;
procedure TInsaForm.FormCreate(Sender: TObject);
begin
TFrame11.dbchart1.title.Text.Clear;
TFrame11.dbchart1.title.Text.Add( '사원별 급여&세금 현황');
NewSeries := TBarSeries.Create(TFrame11.dbchart1);
NewSeries.ParentChart := TFrame11.dbchart1;
NewSeries.DataSource := DM.Insa;
NewSeries.CheckDataSource;
NewSeries.Color := clBlue;
NewSeries.XLabelsSource := 'tax';
NewSeries.YValues.ValueSource := 'tax';
dm.InsaSource.OnStateChange := dm.InsaSourceStateChange;
DM.InsaSource.OnDataChange := dm.InsaSourceDataChange;
end;
procedure TInsaForm.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
case KEY of
vk_return: selectnext(activecontrol, true, true);
vk_up: selectnext(activecontrol,false, true);
vk_down: selectnext(activecontrol, true, true);
end;
end;
procedure TInsaForm.Label9Click(Sender: TObject);
begin
if openpictureDialog1.Execute then
dbimage1.Picture.LoadFromFile(openpicturedialog1.filename);
end;
procedure TInsaForm.PageControl1DragDrop(Sender, Source: TObject; X,
Y: Integer);
var
HitTests: THitTests;
SourceIndex, DestIndex: Integer;
begin
HitTests := TPageControl(Sender).GetHitTestInfoAt( X, Y );
if ( htOnItem in HitTests ) and ( Source is TTabDragObject ) and ( TTabDragObject(Source).PageControl = Sender ) then
begin
SourceIndex := TTabDragObject(Source).PageIndex;
DestIndex := TPageControl(Sender).IndexOfTabAt( X, Y );
TPageControl(Sender).Pages[ SourceIndex ].PageIndex := DestIndex;
end;
end;
procedure TInsaForm.PageControl1DragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
var
HitTests: THitTests;
DestIndex: Integer;
begin
HitTests := TPageControl(Sender).GetHitTestInfoAt( X, Y );
DestIndex := TPageControl(Sender).IndexOfTabAt( X, Y );
Accept := ( htOnItem in HitTests ) and
( Source is TTabDragObject ) and
( TTabDragObject(Source).PageControl = Sender ) and
( TTabDragObject(Source).PageIndex <> TPageControl(Sender).Pages[ DestIndex ].PageIndex );
// ImageList_Drag.DragMove( X - FDragLeft, FDragTop );
// ImageList_Drag.ShowDragImage;
end;
procedure TInsaForm.PageControl1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
FDraging := Button = mbLeft;
if FDraging then
FDragPos := Mouse.CursorPos;
end;
procedure TInsaForm.PageControl1MouseMove(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
var
Bitmap: TBitmap;
Rect: TRect;
DC: HDC;
begin
if FDraging and ( TPageControl(Sender).ActivePage <> nil ) then
begin
if ( Abs( FDragPos.X - Mouse.CursorPos.X ) >= 5 ) or ( Abs( FDragPos.Y - Mouse.CursorPos.Y ) >= 5 ) then
begin
TControl(Sender).BeginDrag( False );
Bitmap := TBitmap.Create;
Bitmap.PixelFormat := pf32Bit;
Rect := TPageControl(Sender).TabRect( TPageControl(Sender).ActivePageIndex );
InflateRect( Rect, 2, 2 );
FDragTop := Rect.Top;
FDragLeft := X - Rect.Left;
Bitmap.Width := Rect.Right - Rect.Left;
Bitmap.Height := Rect.Bottom - Rect.Top;
DC := GetDC( TWinControl(Sender).Handle );
BitBlt( Bitmap.Canvas.Handle, 0, 0, Bitmap.Width, Bitmap.Height, DC, Rect.Left, Rect.Top, SRCCOPY );
ReleaseDC( TWinControl(Sender).Handle, DC );
// Dark( Bitmap );
ShowCursor( True );
end;
end;
end;
procedure TInsaForm.RadioGroup1Click(Sender: TObject);
var
From_date:TDateTime;
to_Date:TDateTime;
begin
From_Date := incYear(now -1);
to_date := incYear(now, 1);
case radiogroup1.ItemIndex of
0: dm.Insa.Filtered := false;
1: begin
dm.Insa.Filtered := true;
dm.Insa.Filter := 'trunc(((sysdate - ipsa_date) + 1)/ 365) < 1';
end;
3: begin
// dm.Insa.Filtered := true;
end;
4: begin
// dm.Insa.Filtered := true;
end;
end;
end;
procedure TInsaForm.SpeedButton1Click(Sender: TObject);
begin
dm.Insa.First;
end;
procedure TInsaForm.SpeedButton2Click(Sender: TObject);
begin
if not dm.Insa.Bof then
dm.Insa.Prior;
end;
procedure TInsaForm.SpeedButton3Click(Sender: TObject);
begin
if not dm.Insa.Eof then
dm.Insa.Next;
end;
procedure TInsaForm.SpeedButton4Click(Sender: TObject);
begin
dm.Insa.Last;
end;
procedure TInsaForm.TabControl1Change(Sender: TObject);
begin
if tabcontrol1.TabIndex = 0 then
dm.Insa.Filtered := false
else
begin
dm.Insa.Filtered := true;
dm.Insa.Filter :=
'class =' + '''' + tabcontrol1.tabs[tabcontrol1.tabindex] + '''';
end;
end;
{ TTabDragObject }
function TTabDragObject.GetDragCursor(Accepted: Boolean; X,
Y: Integer): TCursor;
begin
if Accepted then Result := crArrow
else Result := crNoDrop;
end;
procedure TTabDragObject.WndProc(var Msg: TMessage);
var
Wnd: HWnd;
begin
inherited;
case Msg.Msg of
WM_MOUSEMOVE: begin
Wnd := WindowFromPoint( Mouse.CursorPos );
if Wnd <> CurrentWnd then
begin
if Wnd <> TWinControl(Control).Handle then
DragImageList.HideDragImage;
CurrentWnd := Wnd;
end;
end;
end;
end;
end.