Skip to content

Commit

Permalink
Merge pull request #35 from IBM/feature/new_dept_employee
Browse files Browse the repository at this point in the history
Create employee from department screen
  • Loading branch information
worksofliam authored Jan 23, 2024
2 parents e4bc22a + 08f739f commit eaee792
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion qddssrc/depts.dspf
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
A 2 35'Departments'
A DSPATR(UL)
A COLOR(WHT)
A 4 6'5=View'
A 4 6'5=View 8=New Employee'
A COLOR(BLU)
4 changes: 2 additions & 2 deletions qddssrc/nemp.dspf
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
A 10 2'Department'
A DSPATR(UL)
A COLOR(WHT)
A XDEPT 3A B 10 14
A XDEPT 3A O 10 14

A 11 9'Job'
A DSPATR(UL)
Expand All @@ -36,7 +36,7 @@
A COLOR(WHT)
A XSAL 10A B 12 14

A 13 8'Phone'
A 13 7'Phone'
A DSPATR(UL)
A COLOR(WHT)
A XTEL 4A B 13 14
Expand Down
5 changes: 5 additions & 0 deletions qrpglesrc/depts.pgm.sqlrpgle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
DepartmentNumber Char(3);
End-Pr;

Dcl-Pr NewEmp ExtPgm;
DepartmentNumber Char(3);
End-Pr;

//---------------------------------------------------------------*

/include 'qrpgleref/constants.rpgleinc'
Expand Down Expand Up @@ -143,6 +147,7 @@
Employees(XID);
When (SelVal = '8');
// Insert new employee screen
NewEmp(XID);
Endsl;

If (XSEL <> *Blank);
Expand Down
10 changes: 9 additions & 1 deletion qrpglesrc/newemp.pgm.sqlrpgle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ ctl-opt dftactgrp(*no);

// TODO: need a way to let the parent program pass in a department id

dcl-pi NEWEMP;
currentDepartment Char(3);
end-pi;

// ---------------------------------------------------------------*

/INCLUDE 'qrpgleref/constants.rpgleinc'
Expand Down Expand Up @@ -46,6 +50,8 @@ else;
XID = autoEmpId;
Endif;

XDEPT = currentDepartment;

Dow (NOT Exit);

Write HEADER_FMT;
Expand Down Expand Up @@ -82,7 +88,7 @@ Dcl-Proc HandleInsert;
newEmp.FIRSTNME = XFIRST;
newEmp.MIDINIT = XINIT;
newEmp.LASTNAME = XLAST;
newEmp.WORKDEPT = XDEPT;
newEmp.WORKDEPT = currentDepartment;
newEmp.JOB = XJOB;
newEmp.HIREDATE = %Date;
newEmp.PHONENO = XTEL;
Expand Down Expand Up @@ -122,6 +128,8 @@ Dcl-Proc GetError;
return 'Last name cannot be blank';
endif;

// We have left this in so the user
// cannot continue if no dept is passed in.
if (XDEPT = '');
return 'Department cannot be blank';
endif;
Expand Down

0 comments on commit eaee792

Please sign in to comment.