Create ETD Str type ;
Create the table and add that Edt to that table
Create the form With the same name of the table
1.Step:-
Open the NumberSeqReference_General class in AOT, and add
the following code to the bottom of loadModule():
numRef.DataTypeId = typeId2ExtendedTypeId(typeid(EmplId));
numRef.ReferenceHelp = literalstr("Employee
identification");
numRef.WizardContinuous = false;
numRef.WizardManual = NoYes::No;
numRef.WizardAllowChangeDown = NoYes::Yes;
numRef.WizardAllowChangeUp = NoYes::Yes;
numRef.WizardHighest = 9999;
numRef.SortField = 7;
this.create(numRef);
2.Step:-
Run the number sequence
wizard by clicking on the Wizard button in Basic | Setup |
Number sequences | Number sequences, and click Next:
3.Step:-
Delete everything apart from
the line where Module is Basic and Reference
is Employee (use keyboard shortcut ALT+F9
to delete lines). Note the number
sequence code Basi_202, and click Next:
4.Step:-
On the last page, click Finish
to complete the wizard:
5.Step:-
Find the newly created number
sequence in Number sequences form:
6.Step:-
Open Basic | Setup | Company
information and go to the Number sequences
tab page. Here, we should see the new number sequence code along with
the
existing ones:
7.Step:-
The last thing to do is to create
a helper method for this sequence.
Locate CompanyInfo table in AOT and add the following method:
public server static
NumberSequenceReference numRefEmplId()
{
return
NumberSeqReference::findReference(typeid2extendedtypeid(typeid(EmplId)));
}
8.Step:-
In AOT, open
EmplTable form and add the following code to the bottom of its class
declaration:
NumberSeqFormHandler
numberSeqFormHandler;
9.Step:-
Also, create a new method
called numberSeqFormHandler() in the same
form:
NumberSeqFormHandler
numberSeqFormHandler()
{;
if (!numberSeqFormHandler)
{
numberSeqFormHandler = NumberSeqFormHandler::newForm(
CompanyInfo::numRefEmplId().NumberSequence,
element,
EmplTable_ds,
fieldnum(EmplTable, EmplId));
}
return numberSeqFormHandler;
}
10 Step:-
In the same form, in the EmplTable data source's create(), add the
following line
before its super() method:
element.numberSeqFormHandler().formMethodDataSourceCreatePre();
11. Step:-
And add the following code to the bottom of the same method:
if (!extern)
{
element.numberSeqFormHandler().formMethodDataSourceCreate();
}
12. Step:-
In the same data source in its delete(),
add the following line right
after ttsbegin:
element.numberSeqFormHandler().formMethodDataSourceDelete();
13. Step:-
In the same data source in its write(), add the following line
right after super():
element.numberSeqFormHandler().formMethodDataSourceWrite();
14. Step:-
In the same data source in its validateWrite(), add the
following code right
after super():
ret =
element.numberSeqFormHandler().formMethodDataSourceValidateWrite(ret)
&& ret;
15. Step:-
In the same
data source in its linkActive(), add the following line right after the
variable declaration section:
element.numberSeqFormHandler().formMethodDataSourceLinkActive();
16. Step:-
Finally, add the following code to the form's close() right before
super():
if (numberSeqFormHandler)
{
numberSeqFormHandler.formMethodClose();
}
How it works:-
How it works...
First, we declare the NumberSeqFormHandler object in the form's
class declaration. Then,
we create a new form method numberSeqFormHandler(), which creates an
object of type
NumberSeqFormHandler if it does not exist yet and returns it. This method allows us
to store
handler creation code in one place and reuse
it as many times as we need.
We use the static constructor method NumberSeqFormHandler::newForm() to
create a
new number sequence handler. It accepts
several arguments:
ff The number
sequence code, which was created in the prerequisite recipe. Here, we
call the numRefEmplId()
helper method from the CompanyInfo table to find which
number sequence should be used when creating
new employees. It was created
earlier in the other recipe.
ff The form object
itself.
ff The form data
source where we need to apply the number sequence handler.
ff The number of the
field into which the number sequence will be populated.
The rest of the code in the various data
source member methods ensures that the relevant
NumberSeqFormHandler class methods are executed. The rest is done automatically
inside
the class.
No comments:
Post a Comment