-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathuDM.pas
More file actions
123 lines (102 loc) · 3.24 KB
/
uDM.pas
File metadata and controls
123 lines (102 loc) · 3.24 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
unit Udm;
interface
uses
System.SysUtils, System.Classes, FireDAC.Stan.Intf, FireDAC.Stan.Option,
vcl.dialogs, FireDAC.Stan.Error, FireDAC.UI.Intf, FireDAC.Phys.Intf, FireDAC.Stan.Def,
FireDAC.Stan.Pool, FireDAC.Stan.Async, FireDAC.Phys, FireDAC.Phys.IB,
FireDAC.Phys.IBDef, FireDAC.VCLUI.Wait, FireDAC.Stan.Param, FireDAC.DatS,
FireDAC.DApt.Intf, FireDAC.DApt, Data.DB, FireDAC.Comp.DataSet,
FireDAC.Comp.Client, FireDAC.Comp.UI, FireDAC.Phys.IBBase,
FireDAC.Moni.Base, FireDAC.Moni.FlatFile, FireDAC.VCLUI.Error;
type
TDM = class(TDataModule)
InsaQuery: TFDQuery;
InsaQuerySource: TDataSource;
FDGUIxWaitCursor1: TFDGUIxWaitCursor;
FDPhysIBDriverLink1: TFDPhysIBDriverLink;
Dept: TFDTable;
DeptSource: TDataSource;
InsaSource: TDataSource;
FDMoniFlatFileClientLink1: TFDMoniFlatFileClientLink;
Insa: TFDTable;
InsaNAME: TStringField;
InsaAGE: TSmallintField;
InsaDEPT_CODE: TStringField;
InsaCLASS: TStringField;
InsaSALARY: TIntegerField;
InsaPHOTO: TBlobField;
InsaGRADE: TStringField;
InsaTax: TFloatField;
InsaSection: TStringField;
FDConnection1: TFDConnection;
InsaIPSA_DATE: TDateField;
InsaID: TIntegerField;
FDGUIxErrorDialog1: TFDGUIxErrorDialog;
InsaDuring: TIntegerField;
procedure insaCalcFields(DataSet: TDataSet);
procedure insaBeforeInsert(DataSet: TDataSet);
procedure insaNewRecord(DataSet: TDataSet);
procedure insaAfterPost(DataSet: TDataSet);
procedure InsaSourceStateChange(Sender: TObject);
procedure InsaSourceDataChange(Sender: TObject; Field: TField);
procedure DeptSourceDataChange(Sender: TObject; Field: TField);
private
{ Private declarations }
public
{ Public declarations }
end;
var
DM: TDM;
implementation
{%CLASSGROUP 'Vcl.Controls.TControl'}
uses UInsa;
{$R *.dfm}
procedure TDM.DeptSourceDataChange(Sender: TObject; Field: TField);
begin
InsaQuery.Close;
InsaQuery.ParamByName('code').AsString :=
DM.Dept.Fields[0].AsString;
InsaQuery.Open;
end;
procedure TDM.insaAfterPost(DataSet: TDataSet);
begin
ShowMessage('µî·Ï/¼öÁ¤ ¿Ï·á');
end;
procedure TDM.insaBeforeInsert(DataSet: TDataSet);
begin
InsaForm.DBEdit2.SetFocus;
end;
procedure TDM.InsaCalcFields(DataSet: TDataSet);
var
yy1,mm1,dd1:word;
yy2,mm2,dd2:word;
begin
DecodeDate(Now, yy1,mm1,dd1);
DecodeDate(DM.InsaIpsa_Date.Value, yy2,mm2,dd2 );
if (yy1 = yy2) and (mm1 = mm2) then
InsaDuring.value := 0
else
InsaDuring.Value := yy1 - yy2;
InsaTax.Value := InsaSalary.Value * 0.1;
end;
procedure TDM.insaNewRecord(DataSet: TDataSet);
begin
InsaSalary.Value := 5000000;
InsaGrade.Value := '1';
InsaIpsa_Date.Value := Date;
end;
procedure TDM.InsaSourceDataChange(Sender: TObject; Field: TField);
begin
InsaForm.SpeedButton1.Enabled := not Insa.Bof;
InsaForm.SpeedButton2.Enabled := not Insa.Bof;
InsaForm.SpeedButton3.Enabled := not Insa.Eof;
InsaForm.SpeedButton4.Enabled := not Insa.Eof;
end;
procedure TDM.InsaSourceStateChange(Sender: TObject);
begin
InsaForm.Button1.Enabled := Insa.State = dsBrowse;
InsaForm.Button2.Enabled := Insa.State = dsBrowse;
InsaForm.Button3.Enabled := Insa.State in [dsInsert, dsEdit];
InsaForm.Button4.Enabled := Insa.State in [dsInsert, dsEdit];
end;
end.