Module Order.vw
1Use Crystal\CheckForCrystal.dg
2Use dfClient.pkg
3Use DataDict.pkg
4Use dfEntry.pkg
5Use dfSpnEnt.pkg
6Use dfCEntry.pkg
7Use dfTable.pkg
8Use Windows.pkg
9Use cCrystal.pkg
10Use Vendor.DD
11Use Invt.DD
12Use Customer.DD
13Use SalesP.DD
14Use OrderHea.DD
15Use OrderDtl.DD
16Use cDbCJGrid.pkg
17Use cCJGridColumnRowIndicator.pkg
18
19
20Activate_View Activate_oOrderEntryView for oOrderEntryView
21Object oOrderEntryView is a dbView
22 Set Border_Style to Border_Thick
23 Set Maximize_Icon to True
24 Set Label to "Order Entry"
25 Set Location to 2 3
26 Set Size to 174 383
27 Set piMinSize to 174 383
28 Set pbAutoActivate to True
29
30 Object Vendor_DD is a Vendor_DataDictionary
31 End_Object // Vendor_DD
32
33 Object Invt_DD is a Invt_DataDictionary
34 Set DDO_Server to Vendor_DD
35 End_Object // Invt_DD
36
37 Object Customer_DD is a Customer_DataDictionary
38 End_Object // Customer_DD
39
40 Object SalesP_DD is a Salesp_DataDictionary
41 End_Object // SalesP_DD
42
43 Object OrderHea_DD is a OrderHea_DataDictionary
44 Set DDO_Server to Customer_DD
45 Set DDO_Server to SalesP_DD
46 End_Object // OrderHea_DD
47
48 Object OrderDtl_DD is a OrderDtl_DataDictionary
49 Set DDO_Server to OrderHea_DD
50 Set DDO_Server to Invt_DD
51 Set Constrain_File to OrderHea.File_Number
52 End_Object // OrderDtl_DD
53
54 Set Main_DD to OrderHea_DD
55 Set Server to OrderHea_DD
56
57 Object oDbContainer3d1 is a dbContainer3d
58 Set Size to 85 377
59 Set Location to 2 3
60 Set peAnchors to anTopLeftRight
61 Object oOrderHea_Order_Number is a dbForm
62 Entry_Item OrderHea.Order_Number
63 Set Label to "Order Number:"
64 Set Size to 13 42
65 Set Location to 4 63
66 Set peAnchors to anTopLeft
67 Set Label_Col_Offset to 2
68 Set Label_Justification_Mode to jMode_Right
69
70 End_Object // oOrderHea_Order_Number
71
72 Object oOrderHea_Customer_Number is a dbForm
73 Entry_Item Customer.Customer_Number
74 Set Label to "Customer Number:"
75 Set Size to 13 42
76 Set Location to 4 201
77 Set peAnchors to anTopRight
78 Set Label_Col_Offset to 2
79 Set Label_Justification_Mode to jMode_Right
80
81 // If order record exists, disallow entry in customer window.
82 Procedure Refresh Integer iMode
83 Handle hoSrvr
84 Boolean bCrnt
85 Get Server to hoSrvr // get the data_set
86 Get HasRecord of hoSrvr to bCrnt // has record in data_set
87 // Set displayonly to true if iCrnt is non-zero
88 Set Enabled_State to (not(bCrnt))
89 Forward Send Refresh iMode // do normal refrsh
90 // don't leave us sitting on a displayonly window
91 If (bCrnt and Focus(Self)=Self) Send Next
92 End_Procedure // Refresh
93
94 End_Object // oOrderHea_Customer_Number
95
96 Object oOrderHea_Order_Date is a dbSpinForm
97 Entry_Item OrderHea.Order_Date
98 Set Label to "Order Date:"
99 Set Size to 13 67
100 Set Location to 4 299
101 Set peAnchors to anTopRight
102 Set Label_Col_Offset to 2
103 Set Label_Justification_Mode to jMode_Right
104 End_Object // oOrderHea_Order_Date
105
106 Object oCustomer_Name is a dbForm
107 Entry_Item Customer.Name
108 Set Label to "Customer Name:"
109 Set Size to 13 180
110 Set Location to 18 63
111 Set peAnchors to anTopLeftRight
112 Set Label_Col_Offset to 2
113 Set Label_Justification_Mode to jMode_Right
114 Set Prompt_Button_Mode to pb_PromptOff
115
116 // We want this to be a displayonly field
117 Set Enabled_State to False
118
119 End_Object // oCustomer_Name
120
121 Object oCustomer_Address is a dbForm
122 Entry_Item Customer.Address
123 Set Label to "Street Address:"
124 Set Size to 13 180
125 Set Location to 34 63
126 Set peAnchors to anTopLeftRight
127 Set Label_Col_Offset to 2
128 Set Label_Justification_Mode to jMode_Right
129 End_Object // oCustomer_Address
130
131 Object oCustomer_City is a dbForm
132 Entry_Item Customer.City
133 Set Label to "City/State/Zip:"
134 Set Size to 13 84
135 Set Location to 49 63
136 Set peAnchors to anTopLeftRight
137 Set Label_Col_Offset to 2
138 Set Label_Justification_Mode to jMode_Right
139 End_Object // oCustomer_City
140
141 Object oCustomer_State is a dbForm
142 Entry_Item Customer.State
143 Set Size to 13 20
144 Set Location to 49 155
145 Set peAnchors to anTopRight
146 End_Object // oCustomer_State
147
148 Object oCustomer_Zip is a dbForm
149 Entry_Item Customer.Zip
150 Set Size to 13 60
151 Set Location to 49 183
152 Set peAnchors to anTopRight
153 End_Object // oCustomer_Zip
154
155 Object oOrderHea_Ordered_By is a dbForm
156 Entry_Item OrderHea.Ordered_By
157 Set Label to "Ordered By:"
158 Set Size to 13 67
159 Set Location to 34 299
160 Set peAnchors to anTopRight
161 Set Label_Col_Offset to 2
162 Set Label_Justification_Mode to jMode_Right
163 End_Object // oOrderHea_Ordered_By
164
165 Object oOrderHea_Salesperson_ID is a dbForm
166 Entry_Item Salesp.Id
167 Set Label to "Salesperson ID:"
168 Set Size to 13 40
169 Set Location to 49 299
170 Set peAnchors to anTopRight
171 Set Label_Col_Offset to 2
172 Set Label_Justification_Mode to jMode_Right
173 End_Object // oOrderHea_Salesperson_ID
174
175 Object oOrderHea_Terms is a dbComboForm
176 Entry_Item OrderHea.Terms
177 Set Label to "Terms:"
178 Set Size to 13 85
179 Set Location to 64 63
180 Set peAnchors to anTopLeft
181 Set Form_Border to 0
182 Set Label_Col_Offset to 2
183 Set Label_Justification_Mode to jMode_Right
184
185 End_Object // oOrderHea_Terms
186
187 Object oOrderHea_Ship_Via is a dbComboForm
188 Entry_Item OrderHea.Ship_Via
189 Set Label to "Ship Via:"
190 Set Size to 13 103
191 Set Location to 64 183
192 Set peAnchors to anTopRight
193 Set Form_Border to 0
194 Set Label_Col_Offset to 2
195 Set Label_Justification_Mode to jMode_Right
196
197 Procedure Switch
198 Boolean bEnabled
199 // the normal switch behavior is to attempt to keep
200 // keep looking for additional objects to switch to. If
201 // we can't switch to the dtl table, we want to stop!
202 Send Request_Save
203 Send EnableObjects // make sure grid is properly enabled and save button is disabled
204 Get Enabled_State of oOrderDtl_Grid to bEnabled
205 If bEnabled Begin
206 Forward Send Switch // of oOrderDtl_Grid
207 End
208 End_Procedure // Switch
209
210 End_Object // oOrderHea_Ship_Via
211
212// Object oSaveHdrButton is a Button
213// Set Size to 14 67
214// Set Location to 64 297
215// Set Label to 'Save Header'
216// Set peAnchors to anTopRight
217//
218// // fires when the button is clicked
219// Procedure OnClick
220// Boolean bCancel
221// Get Save_Header to bCancel
222// End_Procedure
223//
224// End_Object
225
226 End_Object // oDbContainer3d1
227
228 Object oOrderDtl_Grid is a cDbCJGrid
229 Set Server to OrderDtl_DD
230 Set Ordering to 1
231 Set Size to 63 377
232 Set Location to 90 3
233 Set peAnchors to anAll
234 Set pbAllowInsertRow to False
235 Set pbRestoreLayout to False
236 Set psLayoutSection to "OrderView_oOrderDtl_Grid2"
237 Set piLayoutBuild to 6
238 Set pbHeaderPrompts to True
239
240 On_Key Key_F11 Send Request_InsertRow
241
242 Object oMark is a cCJGridColumnRowIndicator
243 End_Object
244
245 Object oInvt_Item_ID is a cDbCJGridColumn
246 Entry_Item Invt.Item_ID
247 Set piWidth to 91
248 Set psCaption to "Item ID"
249 Set psImage to "ActionPrompt.ico"
250 End_Object
251
252 Object oInvt_Description is a cDbCJGridColumn
253 Entry_Item Invt.Description
254 Set piWidth to 213
255 Set psCaption to "Description"
256 End_Object
257
258 Object oInvt_Unit_Price is a cDbCJGridColumn
259 Entry_Item Invt.Unit_Price
260 Set piWidth to 53
261 Set psCaption to "Unit Price"
262 End_Object
263
264 Object oOrderDtl_Qty_Ordered is a cDbCJGridColumn
265 Entry_Item OrderDtl.Qty_Ordered
266 Set piWidth to 50
267 Set psCaption to "Quantity"
268 End_Object
269
270 Object oOrderDtl_Price is a cDbCJGridColumn
271 Entry_Item OrderDtl.Price
272 Set piWidth to 62
273 Set psCaption to "Price"
274 End_Object
275
276 Object oOrderDtl_Extended_Price is a cDbCJGridColumn
277 Entry_Item OrderDtl.Extended_Price
278 Set piWidth to 81
279 Set psCaption to "Total"
280 End_Object
281
282 End_Object // oOrderDtl_Grid
283
284 Object oOrderHea_Order_Total is a dbForm
285 Entry_Item OrderHea.Order_Total
286 Set Label to "Order Total:"
287 Set Size to 13 60
288 Set Location to 156 307
289 Set peAnchors to anBottomRight
290 Set Label_Col_Offset to 3
291 Set Label_Justification_Mode to jMode_Right
292 End_Object // oOrderHea_Order_Total
293
294 Object oPrintBtn is a Button
295 Set Label to "Print Order"
296 Set Location to 156 3
297 Set peAnchors to anBottomLeft
298 Set psToolTip to "Print preview of current order"
299
300 Procedure OnClick
301 Delegate Send PrintCurrentOrder // defined in view object
302 End_Procedure // OnClick
303
304 End_Object // oPrintBtn
305
306 Object oOrder_Report is a cCrystal
307 Set psReportName to "Orders.rpt"
308
309 Property Integer piOrderNumber 0
310
311 // Procedure : OnInitializeReport
312 // Purpose : This is a hook message sent by the Open_report procedure. You may use this
313 // procedure to set selection values, print options, etc. This procedure is
314 // intended for augmentation; it has no action by default.
315 Procedure OnInitializeReport Handle hoReport
316 Integer iOrder
317 String sSelection
318 Handle hoTerms hoShipVia
319 Variant[][2] vTerms
320 Variant[][2] vShipVia
321
322 Forward Send OnInitializeReport hoReport
323
324 Get CreateCDO of hoReport "Terms.ttx" to hoTerms
325 If (hoTerms) Begin
326 Get TableData of Terms_table to vTerms
327 Send AppendCDOData of hoReport hoTerms vTerms
328 End
329
330 Get CreateCDO of hoReport "ShipVia.ttx" to hoShipVia
331 If (hoShipVia) Begin
332 Get TableData of Ship_Table to vShipVia
333 Send AppendCDOData of hoReport hoShipVia vShipVia
334 End
335
336 Get piOrderNumber to iOrder
337
338 // Set the selection formula to print the one order.
339 Move ("{OrderHea.Order_Number} = " + String(iOrder)) to sSelection
340 Set ComRecordSelectionFormula of hoReport to sSelection
341
342 End_Procedure // OnInitializeReport
343
344 // pass order to print
345 Procedure PrintOrder Integer iNum
346 Boolean bCrystalOK
347
348 Set piOrderNumber to iNum
349
350 // check for Crystal
351 Get CheckCrystalEnvironment of oCheckForCrystal to bCrystalOK
352 If (bCrystalOK) Begin
353 Send RunReport
354 End
355 Else Begin
356 Send DisplayDialog of oCheckForCrystal
357 End
358
359 End_Procedure
360
361 End_Object // oOrder_Report
362
363 // Change: Create custom confirmation messages for save and delete
364 // We must create the new functions and assign verify messages
365 // to them.
366 Function Confirm_Delete_Order Returns Integer
367 Integer iRetVal
368 Get Confirm "Delete Entire Order?" to iRetVal
369 Function_Return iRetVal
370 End_Function
371
372 // Only confirm on the saving of new records
373 Function Confirm_Save_Order Returns Integer
374 Integer iNoSave iSrvr
375 Boolean bOld
376 Get Server to iSrvr
377 Get HasRecord of iSrvr to bOld
378 If not bOld Begin
379 Get Confirm "Save this NEW order header?" to iNoSave
380 End
381 Function_Return iNoSave
382 End_Function
383
384 // Define alternate confirmation Messages
385 Set Verify_Save_MSG to (RefFunc(Confirm_Save_Order))
386 Set Verify_Delete_MSG to (RefFunc(Confirm_Delete_Order))
387 Set Auto_Clear_DEO_State to False // don't clear Header on save
388
389// // Change: Table entry checking - attempt to save header record
390// // before entering a table (this is called by table. Return
391// // a non-zero if the save failed (i.e., don't enter table)
392// Function Save_Header Returns Integer
393// Boolean bHasRec bChanged
394// Handle hoSrvr
395//
396// Get Server to hoSrvr // The Header DDO.
397// Get HasRecord of hoSrvr to bHasRec // Do we have a record?
398// Get Should_Save to bChanged // Are there any current changes?
399//
400// // If there is no record and no changes we have an error.
401// If ( not(bHasRec) and not(bChanged) ) Begin // no rec
402// Send UserError "You must First Create & Save Main Order Header" ""
403// Function_Return 1
404// End
405//
406// // Attempt to Save the current Record
407// // request_save_no_clear does a save without clearing.
408// Send Request_Save_No_Clear
409//
410// // The save succeeded if there are now no changes, and we
411// // have a saved record. Should_save tells us if we've got changes.
412// // We must check the data-sets hasRecord property to see if
413// // we have a record. If it is not, we had no save.
414// Get Should_Save to bChanged // is a save still needed
415// Get HasRecord of hoSrvr to bHasRec // current record of the DD
416// // if no record or changes still exist, return an error code of 1
417// If ( not(bHasRec) or (bChanged)) ;
418// Function_Return 1
419// End_Function // Save_Header
420
421 // print the current order. This message will be sent
422 // by the print button
423 Procedure PrintCurrentOrder
424 Integer hDD iNum
425 Get Server to hDD // this will be the OrderHea DD
426 If (HasRecord(hDD)) Begin // only do this if record exists
427 Get Field_Current_Value of hDD Field OrderHea.Order_Number to iNum
428 Send PrintOrder of oOrder_Report iNum
429 End
430 End_Procedure
431
432 Object oIdle is a cIdleHandler
433 Procedure OnIdle
434 Delegate Send OnIdle
435 End_Procedure
436 End_Object
437
438 Procedure OnIdle
439 Send EnableObjects
440 End_Procedure
441
442 Procedure EnableObjects
443 Boolean bChanged bRec
444 Handle hoServer
445 Get Server to hoServer
446 Get Should_Save of hoServer to bChanged
447 Get HasRecord of hoServer to bRec
448// Set Enabled_State of oSaveHdrButton to bChanged
449 Set Enabled_State of oOrderDtl_Grid to (not(bChanged) and bRec)
450 Set Enabled_State of oPrintBtn to bRec
451 End_Procedure
452
453 Procedure Activating
454 Forward Send Activating
455 Set pbEnabled of oIdle to True
456 End_Procedure
457
458 Procedure DeActivating
459 Set pbEnabled of oIdle to False
460 Forward Send Deactivating
461 End_Procedure
462
463End_Object
464