Example: Simple Maintain Table Screen
Jump to navigation
Jump to search
Example Screen
The example screen can be found here:
U:\openpetraorg\csharp\ICT\Petra\Client\lib\MPersonnel\gui\setup\AbilityAreaSetup.yaml U:\openpetraorg\csharp\ICT\Petra\Client\lib\MPersonnel\gui\setup\AbilityAreaSetup.ManualCode.cs
That's how it looks like:
When copying the example screen as a starting point for the individual Maintain Table screens the layout does not need to be changed because it is identical for all of the screens. There is only one exception to that: the width of the TextBox for the 'Code' (=the first TextBox in the Detail Panel) as the number of characters which can be entered there is varying for each of the screens [see DB definition 'varchar(X)
', where X is the number of characters allowed]:
- don't specify a width if the varchar value is greater than 10, we will go with the default with (which is 150 pixel) in this case;
- if the varchar value is lower than 10: specify a width that allows the number of characters to be displayed ('
Width=xxx
'. - For the screens which are marked with '(*5)' in the 'Comment' column: make the 'Code' TextBox as wide as needed for displaying two-digit numbers (the maximum value is '99' for those TextBoxes).
Explanation of Methods in the ManualCode.cs file
- '
RunOnceOnActivationManual
' is necessary to prevent the user from changing the value of the Control 'chkDetailDeletableFlag
'. The WinForms Generator does this automatically if a Control named 'chkDetailDeletable
' exists, but as in those screens the database field ends with the suffix '_flag_l
', the Control ends with the suffix '...Flag
' and the Generator cannot find it and therefore not deactivate it automatically. This Method needs to be in the ManualCode.cs file but you don't need to change anything in that Method. - '
EnableDisableUnassignableDate
' is enabling/disabling as well as clearing the content of the Control 'dtpDetailUnassignableDate
' if the user is changing the value of Control 'chkDetailUnassignableFlag
'. This Method needs to be in the ManualCode.cs file but you don't need to change anything in that Method. - '
GetDetailDataFromControlsManual
': This method is needed only in case a column in a DB Table has the constraint 'NOT NULL' and if this column is not put on the Maintain Table screen. Under those circumstances an Exception would be thrown in case the user would try to save changed data using the 'Save' button. The reason for that is that openPETRA wouldn't assign a value to that DB Table column (not even empty string, "") as it is not used in the screen. 'GetDetailDataFromControlsManual
' gets around this problem by manually assigning an empty string value to such DB Table columns before the changed data is sent to the PetraServer for saving. This method needs to be left out of all ManualCode.cs files except for the ManualCode.cs files of screens where this manual assignment is needed (for instance in screen 'Positions').