Module SigCJTreeViewDemo - Sales Orders .vw
1Use dfallent.pkg
2Use cSigCjTreeView.pkg
3Use cDbSplitterContainer.pkg
4Use cSigCJdbForm.pkg
5Use SalesP.DD
6Use OrderHea.DD
7Use Customer.DD
8Use OrderDtl.DD
9Use dfClient.pkg
10
11Deferred_View Activate_oSigCJTreeViewDemo_SalesOrders_View for ;
12Object oSigCJTreeViewDemo_SalesOrders_View is a dbView
13
14 Set Border_Style to Border_Thick
15 Set Size to 205 525
16 Set Location to 2 2
17 Set Maximize_Icon to True
18 Set Icon to "SIG.ico"
19 Set Label to "Codejock Demo - Sales Tree View"
20
21 Set Verify_Data_Loss_Msg to 0
22 Set Verify_Exit_Msg to 0
23
24 Object oSalesp_DD is a SalesP_DataDictionary
25 End_Object
26
27 Object oCustomer_DD is a Customer_DataDictionary
28 End_Object
29
30 Object oOrderhea_DD is a OrderHea_DataDictionary
31 Set DDO_Server to oCustomer_DD
32 Set DDO_Server to oSalesp_DD
33 Property String psDDO_ID
34
35 Procedure OnConstrain
36 If (psDDO_ID(Self)) Constrain OrderHea.SalesPerson_ID eq (psDDO_ID(Self))
37 End_Procedure
38
39 End_Object
40
41 Object oOrderdtl_DD is a OrderDtl_DataDictionary
42 Set Constrain_file to OrderHea.File_number
43 Set DDO_Server to oOrderhea_DD
44 End_Object
45
46 Set Main_DD to oSalesp_DD
47 Set Server to oSalesp_DD
48
49 Object oDbSplitterContainer1 is a cDbSplitterContainer
50 Set piSplitterLocation to 139
51 Object oDbSplitterContainerChild1 is a cDbSplitterContainerChild
52
53 Object oSales_TreeView is a cSigCJTreeView
54 Set Size to 199 132
55 Set Location to 3 3
56 Set peAnchors to anAll
57 Set pbSorted to True
58 Set pbActive_Track to True
59 Property Handle phoCurrent_Node
60 Property Integer piCurrent_Node_Index
61
62 Procedure OnCreateTree
63 Forward Send OnCreateTree
64
65 Send Load_Sales
66 End_Procedure
67
68 Procedure OnNodeClick Handle hoNode
69 Forward Send OnNodeClick hoNode
70 // Showln "OnNodeClick " hoNode
71 End_Procedure
72
73 Procedure OnNodeChanging Handle hoNode Integer iIndex
74 Set phoCurrent_Node to hoNode
75 Set piCurrent_Node_Index to iIndex
76 // If you running with data aware components, then this is the hook to save the record before moving on.
77 // You will need to refind the Old node first
78 End_Procedure
79
80
81 Procedure Load_Sales
82 Handle hoNode hoDDO
83
84 Move (oSalesp_DD(Self)) to hoDDO
85
86 Send Clear of oSalesp_DD
87 Send Find of oSalesp_DD FIRST_RECORD 1
88 While (Found)
89 Get Add_Root_Node (Trim(SalesP.Name)) (Trim(SalesP.ID)) to hoNode
90 Set Node_Cargo of hoNode to (Trim(SalesP.ID))
91 Set Node_DDO of hoNode to hoDDO
92 Set Node_Recnum of hoNode to SalesP.Recnum
93 // Create a Child ghost in-order allow for expanding
94 Get Add_Child_Node "Ghost" "" (Trim(SalesP.ID)) to hoNode
95 Send Find of oSalesp_DD NEXT_RECORD 1
96 Loop
97 End_Procedure
98
99 Procedure Load_Orders String sParentKey
100 Handle hoNode
101
102 Send Clear of oOrderhea_DD
103 Send Find of oOrderhea_DD FIRST_RECORD 1
104 If (not(Found)) Begin
105 Get Add_Child_Node "No sales" "" sParentKey 2 to hoNode
106 Set psImage of hoNode to "Newdoc.ico"
107 End
108 While (Found)
109 Get Add_Child_Node (Trim(Customer.Name)) (String(OrderHea.Order_Number) +':'+ String(OrderHea.Customer_Number)) sParentKey 2 to hoNode
110 Set Node_Recnum of hoNode to OrderHea.Recnum
111 Set psImage of hoNode to "Newdoc.ico"
112 If (OrderHea.Order_Total > 5000) Begin
113 Set piForeColor of hoNode to clFuchsia
114 Set pbBold of hoNode to True
115 Set psImage of hoNode to "FlagUK_16.bmp"
116 End
117 Send Find of oOrderhea_DD NEXT_RECORD 1
118 Loop
119 End_Procedure
120
121 Procedure OnExpand Handle hoNode
122 String sCargo sParentKey
123 Integer iLevel
124
125 Get Node_Cargo of hoNode to sCargo
126 Get Node_Level of hoNode to iLevel
127 Get ComKey of hoNode to sParentKey
128
129 If (iLevel = 1) Begin // Sales Person level so Load Orders
130 Set psDDO_ID of oOrderhea_DD to (Trim(sCargo))
131 Send Rebuild_Constraints to oOrderhea_DD
132 Send Remove_Children of hoNode
133 Send Load_Orders sParentKey
134 End
135 End_Procedure
136
137 Procedure OnActive_Track Handle hoNode Integer iIndex
138 Integer iRecnum iLevel
139 Forward Send OnActive_Track hoNode iIndex
140
141 Get Node_Recnum of hoNode to iRecnum
142 Get Node_Level of hoNode to iLevel
143 If ((iRecnum > 0) and (iLevel = 2)) Begin
144 Set psDDO_ID of oOrderhea_DD to ""
145 Send Rebuild_Constraints to oOrderhea_DD
146 Send Find_By_Recnum of oOrderhea_DD OrderHea.File_Number iRecnum
147 Set phoCurrent_Node to hoNode
148 End
149 Else Send Clear_All of oOrderhea_DD
150
151 End_Procedure
152
153 Procedure OnNodeChanging Handle hoNode Integer iIndex
154 Integer iRecnum iLevel
155
156 Get Node_Recnum of hoNode to iRecnum
157 Get Node_Level of hoNode to iLevel
158 If ((iRecnum > 0) and (iLevel = 2)) Begin
159 Send Request_Save of oOrderhea_DD
160 End
161 End_Procedure
162
163 End_Object
164 End_Object
165
166 Object oDbSplitterContainerChild2 is a cDbSplitterContainerChild
167 Object oDbContainer3d1 is a dbContainer3d
168 Set Size to 85 405
169 Set Location to 0 0
170 Set peAnchors to anTopLeftRight
171 Set Server to oOrderhea_DD
172 Object oOrderHea_Order_Number is a dbForm
173 Entry_Item OrderHea.Order_Number
174 Set Label to "Order Number:"
175 Set Size to 13 42
176 Set Location to 4 63
177 Set peAnchors to anTopLeft
178 Set Label_Col_Offset to 2
179 Set Label_Justification_Mode to jMode_Right
180 End_Object // oOrderHea_Order_Number
181
182 Object oOrderHea_Customer_Number is a dbForm
183 Entry_Item Customer.Customer_Number
184 Set Label to "Customer Number:"
185 Set Size to 13 42
186 Set Location to 4 229
187 Set peAnchors to anTopRight
188 Set Label_Col_Offset to 2
189 Set Label_Justification_Mode to jMode_Right
190
191 // If order record exists, disallow entry in customer window.
192 Procedure Refresh Integer iMode
193 Handle hoSrvr
194 Boolean bCrnt
195 Get Server to hoSrvr // get the data_set
196 Get HasRecord of hoSrvr to bCrnt // has record in data_set
197 // Set displayonly to true if iCrnt is non-zero
198 Set Enabled_State to (not(bCrnt))
199 Forward Send Refresh iMode // do normal refrsh
200 // don't leave us sitting on a displayonly window
201 If (bCrnt and Focus(Self)=Self) Send Next
202 End_Procedure // Refresh
203
204 End_Object // oOrderHea_Customer_Number
205
206 Object oOrderHea_Order_Date is a cSigCJdbForm
207 Entry_Item OrderHea.Order_Date
208 Set Label to "Order Date:"
209 Set Size to 13 67
210 Set Location to 4 327
211 Set peAnchors to anTopRight
212 Set Label_Col_Offset to 2
213 Set Label_Justification_Mode to jMode_Right
214 End_Object // oOrderHea_Order_Date
215
216 Object oCustomer_Name is a dbForm
217 Entry_Item Customer.Name
218 Set Label to "Customer Name:"
219 Set Size to 13 208
220 Set Location to 18 63
221 Set peAnchors to anTopLeftRight
222 Set Label_Col_Offset to 2
223 Set Label_Justification_Mode to jMode_Right
224 Set Prompt_Button_Mode to pb_PromptOff
225
226 // We want this to be a displayonly field
227 Set Enabled_State to False
228
229 End_Object // oCustomer_Name
230
231 Object oCustomer_Address is a dbForm
232 Entry_Item Customer.Address
233 Set Label to "Street Address:"
234 Set Size to 13 208
235 Set Location to 34 63
236 Set peAnchors to anTopLeftRight
237 Set Label_Col_Offset to 2
238 Set Label_Justification_Mode to jMode_Right
239 End_Object // oCustomer_Address
240
241 Object oCustomer_City is a dbForm
242 Entry_Item Customer.City
243 Set Label to "City/State/Zip:"
244 Set Size to 13 112
245 Set Location to 49 63
246 Set peAnchors to anTopLeftRight
247 Set Label_Col_Offset to 2
248 Set Label_Justification_Mode to jMode_Right
249 End_Object // oCustomer_City
250
251 Object oCustomer_State is a dbForm
252 Entry_Item Customer.State
253 Set Size to 13 20
254 Set Location to 49 183
255 Set peAnchors to anTopRight
256 End_Object // oCustomer_State
257
258 Object oCustomer_Zip is a dbForm
259 Entry_Item Customer.Zip
260 Set Size to 13 60
261 Set Location to 49 211
262 Set peAnchors to anTopRight
263 End_Object // oCustomer_Zip
264
265 Object oOrderHea_Ordered_By is a dbForm
266 Entry_Item OrderHea.Ordered_By
267 Set Label to "Ordered By:"
268 Set Size to 13 67
269 Set Location to 34 327
270 Set peAnchors to anTopRight
271 Set Label_Col_Offset to 2
272 Set Label_Justification_Mode to jMode_Right
273 End_Object // oOrderHea_Ordered_By
274
275 Object oOrderHea_Salesperson_ID is a dbForm
276 Entry_Item Salesp.Id
277 Set Label to "Salesperson ID:"
278 Set Size to 13 40
279 Set Location to 49 327
280 Set peAnchors to anTopRight
281 Set Label_Col_Offset to 2
282 Set Label_Justification_Mode to jMode_Right
283 End_Object // oOrderHea_Salesperson_ID
284
285 Object oOrderHea_Terms is a dbComboForm
286 Entry_Item OrderHea.Terms
287 Set Label to "Terms:"
288 Set Size to 13 85
289 Set Location to 64 63
290 Set peAnchors to anTopLeft
291 Set Form_Border to 0
292 Set Label_Col_Offset to 2
293 Set Label_Justification_Mode to jMode_Right
294 Set Entry_State to False
295
296 End_Object // oOrderHea_Terms
297
298 Object oOrderHea_Ship_Via is a dbComboForm
299 Entry_Item OrderHea.Ship_Via
300 Set Label to "Ship Via:"
301 Set Size to 13 103
302 Set Location to 64 211
303 Set peAnchors to anTopRight
304 Set Form_Border to 0
305 Set Label_Col_Offset to 2
306 Set Label_Justification_Mode to jMode_Right
307 Set Entry_State to False
308
309 Procedure Switch
310 Send Activate of oOrderDtl_Grid
311 End_Procedure // Switch
312
313 End_Object // oOrderHea_Ship_Via
314
315 End_Object // oDbContainer3d1
316
317 Object oDbContainer3d2 is a dbContainer3d
318 Set Size to 119 383
319 Set Location to 85 1
320 Set Server to oOrderdtl_DD
321 Set peAnchors to anAll
322
323 Object oOrderDtl_Grid is a dbGrid
324 Set Size to 63 372
325 Set Location to 10 3
326
327 Begin_Row
328 Entry_Item Invt.Item_id
329 Entry_Item Invt.Description
330 Entry_Item Invt.Unit_Price
331 Entry_Item OrderDtl.Price
332 Entry_Item OrderDtl.Qty_Ordered
333 Entry_Item OrderDtl.Extended_Price
334 End_Row
335
336 Set Main_File to OrderDtl.File_Number
337 Set Server to oOrderDtl_DD
338
339 Set Form_Width 0 to 55
340 Set Header_Label 0 to "Item ID"
341
342 Set Form_Width 1 to 119
343 Set Header_Label 1 to "Description"
344
345 Set Form_Width 2 to 55
346 Set Header_Label 2 to "Unit Price"
347
348 Set Form_Width 3 to 43
349 Set Header_Label 3 to "Price"
350
351 Set Form_Width 4 to 43
352 Set Header_Label 4 to "Quantity"
353
354 Set Form_Width 5 to 55
355 Set Header_Label 5 to "Total"
356
357 Set Column_Button 4 to Form_Button_Spin // make qty column spinner
358 Set Column_Minimum_Position 4 to 0 // with range of 0 to 999
359 Set Column_Maximum_Position 4 to 999
360
361 // Change: Table entry checking.
362 // Set child_table_state to true which will
363 // cause table to save when exiting and
364 // attempt to save header when entering.
365 Set Child_Table_State to True // Saves when exit object
366 Set Ordering to 1
367 Set peAnchors to anAll
368 Set peResizeColumn to rcAll
369 Set Wrap_State to True
370 Set pbEmbeddedPrompts to True
371
372 // Called when entering the table. Check with the header if it
373 // has a valid saved record. If not, disallow entry.
374 Function Child_Entering Returns Integer
375 Integer iRetVal
376 // Check with header to see if it is saved.
377// Delegate Get Save_Header to iRetVal
378 Function_Return iRetVal // if non-zero do not enter
379 End_Function // Child_Entering
380
381 // Change: Assign insert-row key append a row
382 // Create new behavior to support append a row
383 // Optimize the table refresh
384 Set Allow_Insert_Add_State to False
385 On_Key kAdd_Mode Send Append_a_Row // Hot Key for KAdd_Mode = Shift+F10
386
387 // Add new record to the end of the table.
388 Procedure Append_a_Row // Q: how would a keyboard do this?
389 Send End_Of_Data // A: Go to end of table and
390 Send Down // down 1 line to empty line
391 End_Procedure // Append_a_Row
392
393 // The way this table is set up, items can never be added out
394 // of order. New items are always added to the end of the table.
395 // By setting Auto_Regenerate_State to false we are telling the
396 // table to never bother reordering after adding records. This is
397 // a minor optimization.
398
399 Set Auto_Regenerate_State to False // table is always in order.
400
401 End_Object // oOrderDtl_Grid
402 Object oOrderHea_Order_Total is a dbForm
403 Entry_Item OrderHea.Order_Total
404 Set Label to "Order Total:"
405 Set Size to 13 60
406 Set Location to 76 307
407 Set peAnchors to anBottomRight
408 Set Label_Col_Offset to 3
409 Set Label_Justification_Mode to jMode_Right
410 End_Object // oOrderHea_Order_Total
411 End_Object
412 End_Object
413 End_Object
414
415Cd_End_Object
416