Handling projects using the SDK
 
This topic explains how to handle projects using the Project object of the SDK. There are several methods available for doing this task. You have to decide whether or not to have user interface and if you want Venice to do most of the work or completely handle the data yourself.
Details will be given about how to insert, update or delete a complete project and how to consult, insert, update or delete details.
 
In the SDK several methods are available for handling the projects of your Venice installation.
 
Insert
What?
This method allows you to insert a complete project, but only via the user interface (using the project dialog of Venice).
How?
By using the method Insert, using the project dialog of Venice, eInsertMode = imDialog).
 
Update
What?
This method allows you to update a complete project, but only via the user interface (using the project dialog of Venice). Using this method to update a project without user interface is also possible but the changes will be limited to the data of the header and to fields which can be modified in the grid of the corresponding Venice module only. Extra fields cannot be modified using this method.
How?
By using the method Update, without (eUpdateMode != umDialog) or with user interface (using the project dialog of Venice, eUpdateMode = umDialog).
 
Delete
What?
This method allows you to delete a complete project, but without user interface. You can also use this method to test if a project can be deleted without actually deleting it.
How?
By using the method Delete (for testing only, set eDeleteMode to dmTestOnly).
 
PrepareProject
What?
This method allows you to completely handle (insert, update, delete and consult) all parts of a project: header, details and extra fields, without user interface.
How?
If you want to securely handle projects, make sure to follow these steps:
 
Preparing the object
In this step, you prepare the object for inserting a new project, duplicating, updating or consulting an existing one by calling the PrepareProject method, by stating the appropriate 'ePrepareAction'.
It will load the necessary data of all related records in accordance with the action you requested:

Header data Detail data Extra fields
paInsert Data of the current project (overridden by the Init method) None None until a template code is assigned
Extra fields of the project with default values
paDuplicate Data of the project you want to duplicate None Extra fields of the project with default values (extra field data are not duplicated)
paUpdate Data of the project you want to update Detail data of the project you want to update Extra fields (saved values) of the project you want to update
paView Data of the project you want to consult Detail data of the project you want to consult Extra fields (saved values) of the project you want to consult
More information on how to handle extra fields can be found in the topic How to use extra fields?.
After calling the PrepareProject, most of the properties, that are read-only in a normal situation, are no longer read-only and can be set. After calling the WriteProject or the CancelProject method is called (see 'Write or cancel'), these properties are read-only again.
After the necessary data is loaded, you must provide all new header data.
Make sure these data are correctly provided (using the properties of your object) before you proceed with the next steps.
For more information about which fields need to be supplied for inserting a new project, you can consult the project dialog in your Venice installation.
If you are updating an existing project, this method will lock the project until the WriteProject or the CancelProject method is called (see 'Write or cancel').
During the period of time between calling the PrepareProject method and the WriteProject method or the CancelProject method (see 'Write or cancel'), your application will use up 1 Import-user, except when the PrepareProject method was called using the value 'paView' for the parameter ePrepareAction.
Therefore, the option 'Import' must be installed in order to manipulate (create, duplicate or change) projects in the SDK.
If you provide a project number (property pNumber) with a value of 0, your project will automatically be numbered.
Not all of the header fields you updated will be written to disk and will stay unchanged, e.g. the project number (property pNumber) and template (property pTemplateCode) can no longer be modified.
 
Execute the actual action
Now, you must provide all the necessary data for the details, depending on the action you want to execute:
Action Method
Insert new detail InsertDetailSel
Update existing detail UpdateDetailSel
Delete existing detail DeleteDetail
Consult existing detail GetDetail
Number of details GetNumDetails
Get attachment path GetAttachmentPath
Get detail index IndexFromSeqNum
Set extra fields SetFieldVal

Remarks
More information on how to handle extra fields can be found in the topic How to use extra fields?.
 
Write or cancel
The final step is to save the provided data to disk using the WriteProject method or cancel the preparations using the CancelProject method.

Remarks
Make sure that this step is always executed, especially in situations where an exception is thrown, by providing accurate error handling!