Module Order.vw
1Use dfClient.pkg
2Use DataDict.pkg
3Use dfEntry.pkg
4Use dfSpnEnt.pkg
5Use dfCEntry.pkg
6Use dfTable.pkg
7Use Windows.pkg
8
9Use Vendor.DD
10Use Invt.DD
11Use Customer.DD
12Use SalesP.DD
13Use OrderHea.DD
14Use OrderDtl.DD
15
16Use cSigCJdbForm.pkg
17
18DEFERRED_VIEW Activate_oOrderEntryView FOR ;
19;
20Object oOrderEntryView is a dbView
21 Set Border_Style to Border_Thick
22 Set Maximize_Icon to True
23 Set Label to "Order Entry"
24 Set Location to 2 3
25 Set Size to 174 383
26 Set piMinSize to 174 383
27
28 Object Vendor_DD is a Vendor_DataDictionary
29 End_Object // Vendor_DD
30
31 Object Invt_DD is a Invt_DataDictionary
32 Set DDO_Server to Vendor_DD
33 End_Object // Invt_DD
34
35 Object Customer_DD is a Customer_DataDictionary
36 End_Object // Customer_DD
37
38 Object SalesP_DD is a Salesp_DataDictionary
39 End_Object // SalesP_DD
40
41 Object OrderHea_DD is a OrderHea_DataDictionary
42 Set DDO_Server to Customer_DD
43 Set DDO_Server to SalesP_DD
44 End_Object // OrderHea_DD
45
46 Object OrderDtl_DD is a OrderDtl_DataDictionary
47 Set DDO_Server to OrderHea_DD
48 Set DDO_Server to Invt_DD
49 Set Constrain_File to OrderHea.File_Number
50 End_Object // OrderDtl_DD
51
52 Set Main_DD to OrderHea_DD
53 Set Server to OrderHea_DD
54
55 Object oDbContainer3d1 is a dbContainer3d
56 Set Size to 85 377
57 Set Location to 2 3
58 Set peAnchors to anTopLeftRight
59 Object oOrderHea_Order_Number is a dbForm
60 Entry_Item OrderHea.Order_Number
61 Set Label to "Order Number:"
62 Set Size to 13 42
63 Set Location to 4 63
64 Set peAnchors to anTopLeft
65 Set Label_Col_Offset to 2
66 Set Label_Justification_Mode to jMode_Right
67 End_Object // oOrderHea_Order_Number
68
69 Object oOrderHea_Customer_Number is a dbForm
70 Entry_Item Customer.Customer_Number
71 Set Label to "Customer Number:"
72 Set Size to 13 42
73 Set Location to 4 201
74 Set peAnchors to anTopRight
75 Set Label_Col_Offset to 2
76 Set Label_Justification_Mode to jMode_Right
77
78 // If order record exists, disallow entry in customer window.
79 Procedure Refresh Integer iMode
80 Handle hoSrvr
81 Boolean bCrnt
82 Get Server to hoSrvr // get the data_set
83 Get HasRecord of hoSrvr to bCrnt // has record in data_set
84 // Set displayonly to true if iCrnt is non-zero
85 Set Enabled_State to (not(bCrnt))
86 Forward Send Refresh iMode // do normal refrsh
87 // don't leave us sitting on a displayonly window
88 If (bCrnt and Focus(Self)=Self) Send Next
89 End_Procedure // Refresh
90
91 End_Object // oOrderHea_Customer_Number
92
93 Object oOrderHea_Order_Date is a cSigCJdbForm
94 Entry_Item OrderHea.Order_Date
95 Set Label to "Order Date:"
96 Set Size to 13 67
97 Set Location to 4 299
98 Set peAnchors to anTopRight
99 Set Label_Col_Offset to 2
100 Set Label_Justification_Mode to jMode_Right
101 End_Object // oOrderHea_Order_Date
102
103 Object oCustomer_Name is a dbForm
104 Entry_Item Customer.Name
105 Set Label to "Customer Name:"
106 Set Size to 13 180
107 Set Location to 18 63
108 Set peAnchors to anTopLeftRight
109 Set Label_Col_Offset to 2
110 Set Label_Justification_Mode to jMode_Right
111 Set Prompt_Button_Mode to pb_PromptOff
112
113 // We want this to be a displayonly field
114 Set Enabled_State to False
115
116 End_Object // oCustomer_Name
117
118 Object oCustomer_Address is a dbForm
119 Entry_Item Customer.Address
120 Set Label to "Street Address:"
121 Set Size to 13 180
122 Set Location to 34 63
123 Set peAnchors to anTopLeftRight
124 Set Label_Col_Offset to 2
125 Set Label_Justification_Mode to jMode_Right
126 End_Object // oCustomer_Address
127
128 Object oCustomer_City is a dbForm
129 Entry_Item Customer.City
130 Set Label to "City/State/Zip:"
131 Set Size to 13 84
132 Set Location to 49 63
133 Set peAnchors to anTopLeftRight
134 Set Label_Col_Offset to 2
135 Set Label_Justification_Mode to jMode_Right
136 End_Object // oCustomer_City
137
138 Object oCustomer_State is a dbForm
139 Entry_Item Customer.State
140 Set Size to 13 20
141 Set Location to 49 155
142 Set peAnchors to anTopRight
143 End_Object // oCustomer_State
144
145 Object oCustomer_Zip is a dbForm
146 Entry_Item Customer.Zip
147 Set Size to 13 60
148 Set Location to 49 183
149 Set peAnchors to anTopRight
150 End_Object // oCustomer_Zip
151
152 Object oOrderHea_Ordered_By is a dbForm
153 Entry_Item OrderHea.Ordered_By
154 Set Label to "Ordered By:"
155 Set Size to 13 67
156 Set Location to 34 299
157 Set peAnchors to anTopRight
158 Set Label_Col_Offset to 2
159 Set Label_Justification_Mode to jMode_Right
160 End_Object // oOrderHea_Ordered_By
161
162 Object oOrderHea_Salesperson_ID is a dbForm
163 Entry_Item Salesp.Id
164 Set Label to "Salesperson ID:"
165 Set Size to 13 40
166 Set Location to 49 299
167 Set peAnchors to anTopRight
168 Set Label_Col_Offset to 2
169 Set Label_Justification_Mode to jMode_Right
170 End_Object // oOrderHea_Salesperson_ID
171
172 Object oOrderHea_Terms is a dbComboForm
173 Entry_Item OrderHea.Terms
174 Set Label to "Terms:"
175 Set Size to 13 85
176 Set Location to 64 63
177 Set peAnchors to anTopLeft
178 Set Form_Border to 0
179 Set Label_Col_Offset to 2
180 Set Label_Justification_Mode to jMode_Right
181 Set Entry_State to False
182
183 End_Object // oOrderHea_Terms
184
185 Object oOrderHea_Ship_Via is a dbComboForm
186 Entry_Item OrderHea.Ship_Via
187 Set Label to "Ship Via:"
188 Set Size to 13 103
189 Set Location to 64 183
190 Set peAnchors to anTopRight
191 Set Form_Border to 0
192 Set Label_Col_Offset to 2
193 Set Label_Justification_Mode to jMode_Right
194 Set Entry_State to False
195
196 Procedure Switch
197 // the normal switch behavior is to attempt to keep
198 // keep looking for additional objects to switch to if. If
199 // we can't switch to the dtl table, we want to stop! So just
200 // do a simple activate.
201 Send Activate of oOrderDtl_Grid
202 End_Procedure // Switch
203
204 End_Object // oOrderHea_Ship_Via
205
206 End_Object // oDbContainer3d1
207
208 Object oOrderDtl_Grid is a dbGrid
209 Set Size to 63 377
210 Set Location to 90 3
211
212 Begin_Row
213 Entry_Item Invt.Item_id
214 Entry_Item Invt.Description
215 Entry_Item Invt.Unit_Price
216 Entry_Item OrderDtl.Price
217 Entry_Item OrderDtl.Qty_Ordered
218 Entry_Item OrderDtl.Extended_Price
219 End_Row
220
221 Set Main_File to OrderDtl.File_Number
222 Set Server to OrderDtl_DD
223
224 Set Form_Width 0 to 55
225 Set Header_Label 0 to "Item ID"
226
227 Set Form_Width 1 to 119
228 Set Header_Label 1 to "Description"
229
230 Set Form_Width 2 to 55
231 Set Header_Label 2 to "Unit Price"
232
233 Set Form_Width 3 to 43
234 Set Header_Label 3 to "Price"
235
236 Set Form_Width 4 to 43
237 Set Header_Label 4 to "Quantity"
238
239 Set Form_Width 5 to 55
240 Set Header_Label 5 to "Total"
241
242 Set Column_Button 4 to Form_Button_Spin // make qty column spinner
243 Set Column_Minimum_Position 4 to 0 // with range of 0 to 999
244 Set Column_Maximum_Position 4 to 999
245
246 // Change: Table entry checking.
247 // Set child_table_state to true which will
248 // cause table to save when exiting and
249 // attempt to save header when entering.
250 Set Child_Table_State to True // Saves when exit object
251 Set Ordering to 1
252 Set peAnchors to anAll
253 Set peResizeColumn to rcAll
254 Set Wrap_State to True
255 Set pbEmbeddedPrompts to True
256
257 // Called when entering the table. Check with the header if it
258 // has a valid saved record. If not, disallow entry.
259 Function Child_Entering Returns Integer
260 Integer iRetVal
261 // Check with header to see if it is saved.
262 Delegate Get Save_Header to iRetVal
263 Function_Return iRetVal // if non-zero do not enter
264 End_Function // Child_Entering
265
266 // Change: Assign insert-row key append a row
267 // Create new behavior to support append a row
268 // Optimize the table refresh
269 Set Allow_Insert_Add_State to False
270 On_Key kAdd_Mode Send Append_a_Row // Hot Key for KAdd_Mode = Shift+F10
271
272 // Add new record to the end of the table.
273 Procedure Append_a_Row // Q: how would a keyboard do this?
274 Send End_Of_Data // A: Go to end of table and
275 Send Down // down 1 line to empty line
276 End_Procedure // Append_a_Row
277
278 // The way this table is set up, items can never be added out
279 // of order. New items are always added to the end of the table.
280 // By setting Auto_Regenerate_State to false we are telling the
281 // table to never bother reordering after adding records. This is
282 // a minor optimization.
283
284 Set Auto_Regenerate_State to False // table is always in order.
285
286 End_Object // oOrderDtl_Grid
287
288 Object oOrderHea_Order_Total is a dbForm
289 Entry_Item OrderHea.Order_Total
290 Set Label to "Order Total:"
291 Set Size to 13 60
292 Set Location to 156 307
293 Set peAnchors to anBottomRight
294 Set Label_Col_Offset to 3
295 Set Label_Justification_Mode to jMode_Right
296 End_Object // oOrderHea_Order_Total
297
298
299 // Change: Create custom confirmation messages for save and delete
300 // We must create the new functions and assign verify messages
301 // to them.
302 Function Confirm_Delete_Order Returns Integer
303 Integer iRetVal
304 Get Confirm "Delete Entire Order?" to iRetVal
305 Function_Return iRetVal
306 End_Function
307
308 // Only confirm on the saving of new records
309 Function Confirm_Save_Order Returns Integer
310 Integer iNoSave iSrvr
311 Boolean bOld
312 Get Server to iSrvr
313 Get HasRecord of iSrvr to bOld
314 If not bOld ;
315 Get Confirm "Save this NEW order header?" to iNoSave
316 Function_Return iNoSave
317 End_Function
318
319 // Define alternate confirmation Messages
320 Set Verify_Save_MSG to GET_Confirm_save_order
321 Set Verify_Delete_MSG to GET_Confirm_delete_order
322
323 // Change: Table entry checking - attempt to save header record
324 // before entering a table (this is called by table. Return
325 // a non-zero if the save failed (i.e., don't enter table)
326 Function Save_Header Returns Integer
327 Boolean bHasRec bChanged
328 Handle hoSrvr
329
330 Get Server to hoSrvr // The Header DDO.
331 Get HasRecord of hoSrvr to bHasRec // Do we have a record?
332 Get Should_Save to bChanged // Are there any current changes?
333
334 // If there is no record and no changes we have an error.
335 If ( not(bHasRec) and not(bChanged) ) Begin // no rec
336 Send Error 99 "You must First Create & Save Main Order Header" //""
337 Function_Return 1
338 End
339
340 // Attempt to Save the current Record
341 // request_save_no_clear does a save without clearing.
342 Send Request_Save_No_Clear
343
344 // The save succeeded if there are now no changes, and we
345 // have a saved record. Should_save tells us if we've got changes.
346 // We must check the data-sets hasRecord property to see if
347 // we have a record. If it is not, we had no save.
348 Get Should_Save to bChanged // is a save still needed
349 Get HasRecord of hoSrvr to bHasRec // current record of the DD
350 // if no record or changes still exist, return an error code of 1
351 If ( not(bHasRec) or (bChanged)) ;
352 Function_Return 1
353 End_Function // Save_Header
354
355 Procedure Find_Record_Order_View String sID
356 Send Clear of OrderHea_DD
357 Move sID to OrderHea.Order_Number
358 Send Find of OrderHea_DD Ge 1
359 End_Procedure
360
361CD_End_Object // oOrderEntryView
362
363Procedure Activate_Order_View String sID
364 Send Activate_oOrderEntryView
365 Send Find_Record_Order_View of oOrderEntryView sID
366End_Procedure
367