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 27 by tony, Tue Apr 14 13:10:23 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 86 | Line 97 | type
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);
# Line 131 | Line 143 | implementation
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
# Line 215 | Line 230 | 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
# Line 261 | Line 283 | begin
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;
# Line 270 | Line 292 | end;
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);
# Line 283 | Line 306 | end;
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  
# Line 383 | Line 398 | begin
398   end;
399  
400   end.
401 <
401 >

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines