20 |
|
EmployeesDEPT_PATH: TIBStringField; |
21 |
|
IBLookupComboEditBox1: TIBLookupComboEditBox; |
22 |
|
IBLookupComboEditBox2: TIBLookupComboEditBox; |
23 |
+ |
IBQuery1DEPT_NO: TIBStringField; |
24 |
+ |
IBQuery1EMP_NO: TSmallintField; |
25 |
+ |
IBQuery1FIRST_NAME: TIBStringField; |
26 |
+ |
IBQuery1FULL_NAME: TIBStringField; |
27 |
+ |
IBQuery1HIRE_DATE: TDateTimeField; |
28 |
+ |
IBQuery1JOB_CODE: TIBStringField; |
29 |
+ |
IBQuery1JOB_COUNTRY: TIBStringField; |
30 |
+ |
IBQuery1JOB_GRADE: TSmallintField; |
31 |
+ |
IBQuery1LAST_NAME: TIBStringField; |
32 |
+ |
IBQuery1PHONE_EXT: TIBStringField; |
33 |
+ |
IBQuery1SALARY: TIBBCDField; |
34 |
|
SelectDept: TAction; |
35 |
|
Button4: TButton; |
36 |
|
Button5: TButton; |
97 |
|
IBDatabase1: TIBDatabase; |
98 |
|
IBTransaction1: TIBTransaction; |
99 |
|
procedure EmployeesAfterPost(DataSet: TDataSet); |
100 |
+ |
procedure EmployeesValidatePost(Sender: TObject; var CancelPost: boolean); |
101 |
|
procedure JobGradeDBComboBoxCloseUp(Sender: TObject); |
102 |
|
procedure SelectDeptExecute(Sender: TObject); |
103 |
|
procedure AddEmployeeExecute(Sender: TObject); |
143 |
|
|
144 |
|
uses IB, Unit2; |
145 |
|
|
146 |
+ |
const |
147 |
+ |
sNoName = '<no name>'; |
148 |
+ |
|
149 |
|
function ExtractDBException(msg: string): string; |
150 |
|
var Lines: TStringList; |
151 |
|
begin |
230 |
|
Employees.Refresh |
231 |
|
end; |
232 |
|
|
233 |
+ |
procedure TForm1.EmployeesValidatePost(Sender: TObject; var CancelPost: boolean |
234 |
+ |
); |
235 |
+ |
begin |
236 |
+ |
{Cancel if no name entered} |
237 |
+ |
CancelPost := (EmployeesLAST_NAME.AsString = sNoName) and (EmployeesFIRST_NAME.AsString = sNoName); |
238 |
+ |
end; |
239 |
+ |
|
240 |
|
procedure TForm1.JobGradeDBComboBoxCloseUp(Sender: TObject); |
241 |
|
begin |
242 |
|
JobGradeDBComboBox.EditingDone; //See http://bugs.freepascal.org/view.php?id=27186 |
283 |
|
EmployeesJOB_CODE.AsString := 'SRep'; |
284 |
|
EmployeesJOB_GRADE.AsInteger := 4; |
285 |
|
EmployeesSALARY.AsCurrency := 20000; |
286 |
< |
EmployeesFIRST_NAME.AsString := '<no name>'; |
287 |
< |
EmployeesLAST_NAME.AsString := '<no name>'; |
286 |
> |
EmployeesFIRST_NAME.AsString := sNoName; |
287 |
> |
EmployeesLAST_NAME.AsString := sNoName; |
288 |
|
EmployeesHIRE_DATE.AsDateTime := now; |
289 |
|
EmployeesDEPT_NO.AsString := '000'; |
290 |
|
FDirty := true; |
292 |
|
|
293 |
|
procedure TForm1.EmployeesAfterOpen(DataSet: TDataSet); |
294 |
|
begin |
295 |
< |
TotalsQuery.Active := true |
295 |
> |
TotalsQuery.Active := true; |
296 |
> |
IBDynamicGrid1.SetFocus; |
297 |
|
end; |
298 |
|
|
299 |
|
procedure TForm1.EmployeesAfterScroll(DataSet: TDataSet); |
306 |
|
|
307 |
|
procedure TForm1.EmployeesBeforeClose(DataSet: TDataSet); |
308 |
|
begin |
286 |
– |
with DataSet do |
287 |
– |
if State in [dsInsert,dsEdit] then |
288 |
– |
try |
289 |
– |
Post; |
290 |
– |
except |
291 |
– |
Cancel; |
292 |
– |
raise; |
293 |
– |
end; |
309 |
|
TotalsQuery.Active := false |
310 |
|
end; |
311 |
|
|
398 |
|
end; |
399 |
|
|
400 |
|
end. |
401 |
< |
|
401 |
> |
|