ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/trunk/examples/employee/unit1.pas
(Generate patch)

Comparing ibx/trunk/examples/employee/unit1.pas (file contents):
Revision 21 by tony, Thu Feb 26 10:33:34 2015 UTC vs.
Revision 29 by tony, Sat May 9 11:37:49 2015 UTC

# Line 20 | Line 20 | type
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;
# Line 69 | Line 80 | type
80      Panel2: TPanel;
81      EmployeeEditorPanel: TPanel;
82      SpeedButton1: TSpeedButton;
83 +    JobGradeChangeTimer: TTimer;
84 +    JobCodeChangeTimer: TTimer;
85      TotalsQueryTOTALSALARIES: TIBBCDField;
86      TotalsSource: TDataSource;
87      TotalsQuery: TIBQuery;
# Line 86 | Line 99 | type
99      IBDatabase1: TIBDatabase;
100      IBTransaction1: TIBTransaction;
101      procedure EmployeesAfterPost(DataSet: TDataSet);
102 +    procedure EmployeesValidatePost(Sender: TObject; var CancelPost: boolean);
103 +    procedure JobCodeChangeTimerTimer(Sender: TObject);
104 +    procedure JobGradeChangeTimerTimer(Sender: TObject);
105      procedure JobGradeDBComboBoxCloseUp(Sender: TObject);
106      procedure SelectDeptExecute(Sender: TObject);
107      procedure AddEmployeeExecute(Sender: TObject);
# Line 131 | Line 147 | implementation
147  
148   uses IB, Unit2;
149  
150 + const
151 +  sNoName = '<no name>';
152 +
153   function ExtractDBException(msg: string): string;
154   var Lines: TStringList;
155   begin
# Line 215 | Line 234 | begin
234    Employees.Refresh
235   end;
236  
237 + procedure TForm1.EmployeesValidatePost(Sender: TObject; var CancelPost: boolean
238 +  );
239 + begin
240 +  {Cancel if no name entered}
241 +  CancelPost := (EmployeesLAST_NAME.AsString = sNoName) and  (EmployeesFIRST_NAME.AsString = sNoName);
242 + end;
243 +
244 + procedure TForm1.JobCodeChangeTimerTimer(Sender: TObject);
245 + begin
246 +  Countries.Active := false;
247 +  Countries.Active := true;
248 +  JobCodeChangeTimer.Interval := 0;
249 + end;
250 +
251 + procedure TForm1.JobGradeChangeTimerTimer(Sender: TObject);
252 + begin
253 +  Countries.Active := false;
254 +  JobCodes.Active := false;
255 +  Countries.Active := true;
256 +  JobCodes.Active := true;
257 +  JobGradeChangeTimer.Interval := 0;
258 + end;
259 +
260   procedure TForm1.JobGradeDBComboBoxCloseUp(Sender: TObject);
261   begin
262    JobGradeDBComboBox.EditingDone; //See http://bugs.freepascal.org/view.php?id=27186
# Line 261 | Line 303 | begin
303    EmployeesJOB_CODE.AsString := 'SRep';
304    EmployeesJOB_GRADE.AsInteger := 4;
305    EmployeesSALARY.AsCurrency := 20000;
306 <  EmployeesFIRST_NAME.AsString := '<no name>';
307 <  EmployeesLAST_NAME.AsString := '<no name>';
306 >  EmployeesFIRST_NAME.AsString := sNoName;
307 >  EmployeesLAST_NAME.AsString := sNoName;
308    EmployeesHIRE_DATE.AsDateTime := now;
309    EmployeesDEPT_NO.AsString := '000';
310    FDirty := true;
# Line 270 | Line 312 | end;
312  
313   procedure TForm1.EmployeesAfterOpen(DataSet: TDataSet);
314   begin
315 <  TotalsQuery.Active := true
315 >  TotalsQuery.Active := true;
316 >  IBDynamicGrid1.SetFocus;
317   end;
318  
319   procedure TForm1.EmployeesAfterScroll(DataSet: TDataSet);
320   begin
321 <  Countries.Active := false;
279 <  JobCodes.Active := false;
280 <  Countries.Active := true;
281 <  JobCodes.Active := true;
321 >  JobGradeChangeTimer.Interval := 200;
322   end;
323  
324   procedure TForm1.EmployeesBeforeClose(DataSet: TDataSet);
325   begin
286  with DataSet do
287    if State in [dsInsert,dsEdit] then
288    try
289     Post;
290    except
291      Cancel;
292      raise;
293    end;
326    TotalsQuery.Active := false
327   end;
328  
# Line 322 | Line 354 | end;
354  
355   procedure TForm1.EmployeesJOB_CODEChange(Sender: TField);
356   begin
357 <  Countries.Active := false;
326 <  Countries.Active := true;
357 >  JobCodeChangeTimer.Interval := 200;
358   end;
359  
360   procedure TForm1.EmployeesJOB_GRADEChange(Sender: TField);
361   begin
362 <  Countries.Active := false;
332 <  JobCodes.Active := false;
333 <  Countries.Active := true;
334 <  JobCodes.Active := true;
362 >  JobGradeChangeTimer.Interval := 200;
363   end;
364  
365   procedure TForm1.FormClose(Sender: TObject; var CloseAction: TCloseAction);
# Line 383 | Line 411 | begin
411   end;
412  
413   end.
414 <
414 >

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines