[r8761]: ooDialog / trunk / examples / userGuide / exercises / Exercise07 / Order / OrderView.rex  Maximize  Restore  History

Download this file

291 lines (236 with data), 12.6 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
/*----------------------------------------------------------------------------*/
/* */
/* Copyright (c) 2011-2013 Rexx Language Association. All rights reserved. */
/* */
/* This program and the accompanying materials are made available under */
/* the terms of the Common Public License v1.0 which accompanies this */
/* distribution. A copy is also available at the following address: */
/* http://www.oorexx.org/license.html */
/* */
/* Redistribution and use in source and binary forms, with or */
/* without modification, are permitted provided that the following */
/* conditions are met: */
/* */
/* Redistributions of source code must retain the above copyright */
/* notice, this list of conditions and the following disclaimer. */
/* Redistributions in binary form must reproduce the above copyright */
/* notice, this list of conditions and the following disclaimer in */
/* the documentation and/or other materials provided with the distribution. */
/* */
/* Neither the name of Rexx Language Association nor the names */
/* of its contributors may be used to endorse or promote products */
/* derived from this software without specific prior written permission. */
/* */
/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
/* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */
/* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */
/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */
/* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY */
/* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */
/* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
/* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
/* */
/*----------------------------------------------------------------------------*/
/* ooDialog User Guide
Exercise 07: The OrderView class v01-01 25Aug12
OrderFormView.rex
Contains: class "OrderView".
Pre-requisite files: OrderView.rc, OrderView.h.
Description: A sample Order View component - part of the sample
Order Management application.
This is a "leaf" component - invoked by OrderListView.
Outstanding Problems: None reported.
Changes:
v01-00 07Jun12: First Version (Exercise06)
v01-01 25Aug12: Ex07 - changed to use the MVF.
------------------------------------------------------------------------------*/
.Application~addToConstDir("Order\OrderView.h")
::REQUIRES "ooDialog.cls"
::REQUIRES "Order\OrderModelsData.rex"
::REQUIRES "..\Support\RcView.rex"
/*==============================================================================
OrderView v01-01 25Aug12
-------------
The "view" (or "gui") part of the Order component - part of the sample
Order Management application.
Changes:
v01-00 07Jun12: First Version.
v01-01 25Aug12: Ex07 - changed to use the MVF.
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
::CLASS OrderView SUBCLASS RcView PUBLIC -- Ex07
::METHOD newInstance CLASS PUBLIC
use strict arg idModel, rootDlg -- Ex07
say ".OrderView-newInstance: rootDlg =" rootDlg
dlg = self~new("Order\OrderView.rc", "IDD_ORDER_DIALOG")
dlg~activate(idModel, rootDlg) -- Ex07
return dlg -- Ex07
/*----------------------------------------------------------------------------
Dialog Setup Methods
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
::METHOD init
-- creates the dialog instance but does not make it visible.
expose menuBar
say "OrderView-init-01"
forward class (super) continue
if \ self~createMenuBar then do -- if there was a problem
self~initCode = 1
return
end
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
::METHOD createMenuBar
-- Creates the menu bar on the dialog.
expose menuBar
say "OrderView-createMenuBar-01"
menuBar = .ScriptMenuBar~new("Order\OrderView.rc", IDR_ORDER_MENU, , , .true)
return .true
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
::METHOD activate UNGUARDED
expose rootDlg orderData
use strict arg idModelInstance, rootDlg -- Ex07
forward class (super) continue -- Ex07 - MVF: required to get Model's data
orderData = RESULT -- Ex07 - MVF: model's data returned by super
say "OrderView-activate-00: orderData = " orderData
-- Shows the Dialog - i.e. makes it visible to the user.
say "OrderView-activate-01: OrderNumber = " orderData["OrderNo"] orderData~orderNo
-- OrderNo SO-3456
-- CustNo BA0314
-- Disc 0
-- Cmtd Y
-- Date 120527
if rootDlg = "SA" then self~execute("SHOWTOP","IDI_ORDER_DLGICON")
else self~popUpAsChild(rootDlg,"SHOWTOP",,"IDI_ORDER_DLGICON")
return self -- Ex07
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
::METHOD initDialog
-- Called by ooDialog after SHOWTOP.
expose menuBar orderControls orderData -- Ex07
say "OrderView-initDialog-01"
menuBar~attachTo(self)
orderControls = .Directory~new
orderControls[ecOrderNameAddr] = self~newEdit( "IDC_ORDER_NAMEADDR")
orderControls[ecOrderDate] = self~newEdit( "IDC_ORDER_DATE" )
orderControls[ecOrderNo] = self~newEdit( "IDC_ORDER_ORDNO" )
orderControls[ecCustNo] = self~newEdit( "IDC_ORDER_CUSTNO" )
orderControls[lvOrderItems] = self~newListView("IDC_ORDER_ITEMS" )
orderControls[stNetCost] = self~newStatic( "IDC_ST_NET" )
orderControls[stDiscountPC] = self~newStatic( "IDC_ST_DISCOUNT_PC")
orderControls[stDiscount] = self~newStatic( "IDC_ST_DISCOUNT" )
orderControls[stTaxPC] = self~newStatic( "IDC_ST_TAX_PC" )
orderControls[stTax] = self~newStatic( "IDC_ST_TAX" )
orderControls[stTotal] = self~newStatic( "IDC_ST_TOTAL" )
-- Each Order Item consists of ProdNo, ProdName, Qty:
orderItems = orderControls[lvOrderItems]
orderItems~addExtendedStyle(GRIDLINES FULLROWSELECT)
orderItems~insertColumnPX(0,"Product No.",110,"LEFT")
orderItems~insertColumnPX(1,"Product Name",160,"LEFT")
orderItems~insertColumnPX(2,"Quantity",85,"LEFT")
self~connectListViewEvent("IDC_ORDER_ITEMS","ACTIVATE",showProduct) -- double-click
--font = self~createFontEx("Ariel", 10)
font = self~createFontEx("Courier", 8)
orderControls[lvOrderItems]~setFont(font)
self~showData
/*----------------------------------------------------------------------------
Event-Handler Methods - Menu Events
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
::METHOD showProduct
expose orderControls rootDlg
say "OrderView-showProduct-01: Show Product requested."
productItem = orderControls[lvOrderItems]~selected
say "OrderView-showProduct-01: item selected =" productItem
if item = -1 then do -- if no item selected.
ret = MessageDialog(.HRSolv~nilSelected, self~hwnd, title, 'WARNING')
return
end
info=.Directory~new
if orderControls[lvOrderItems]~getItemInfo(productItem, info) then do
say "OrderView-showOrder-02: info~text =" info~text
objectMgr = .local~my.ObjectMgr
objectMgr~showModel("ProductModel", info~text, self) --Ex07
self~disableControl("IDC_ORDLIST_SHOWORDER")
end
else do
say "OrderListView-showOrder-04: ~getItemInfo returned .false."
end
-- From OrderListView - to be modified:
/*
*/
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
::METHOD anAction UNGUARDED
self~noMenuFunction(.HRSov~anAction)
/*- - Help - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
::METHOD about UNGUARDED
self~noMenuFunction(.HRSov~HelpAbout)
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
::METHOD noMenuFunction UNGUARDED
use arg title
ret = MessageDialog(.HRSov~NoMenu, self~hwnd, title, 'WARNING')
/*----------------------------------------------------------------------------
Application Methods
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
::METHOD showData
expose orderControls orderData
say "--------------------"
say "OrderView-showData-00: contents of orderData:"
do i over orderdata
say i orderData[i]
end
--say "orderData['CustNo']:" orderData['CustNo'] -- orderData~CustNo, orderData~'CustNo' - neither work.
--say "--------------------"
-- Format & show the address:
custAddr = orderData["CustAddress"]
parse var custAddr street "," city "," state
say "OrderView-showData-01: address =" street city state orderData["Zip"]
eol = .endOfLine
custNameAddr = orderData["CustName"]||eol||street||eol||city||eol||state orderData["Zip"]
orderControls[ecOrderNameAddr]~setText(custNameAddr)
-- Format & show the order date:
orderDate = orderData["Date"]
yy = orderDate~left(2); dd = orderDate~right(2); mm = orderDate~substr(3,2)
orderDate = mm||"/"||dd||"/"||yy
orderControls[ecOrderDate]~setText(orderDate)
-- Show the Order NUmber:
orderControls[ecOrderNo]~setText(orderData["OrderNo"])
-- Show the Customer NUmber:
orderControls[ecCustNo]~setText(orderData["CustNo"])
-- Show the Order Items (aka Order Lines):
lvOrderLines = orderControls[lvOrderItems]
arr = orderData[OrderLines]
--say "OrderView-showData-02: order lines array dims =" arr~dimension
-- do i = 1 to arr~dimension(1)
-- say arr[i,2] arr[i,3] arr[i,4]
-- end
do i=1 to arr~dimension(1)
qty = arr[i,3]~right(8," ")
lvOrderLines~addRow( , , arr[i,2], arr[i,4], qty )
end
--lvOrderLines~setColumnWidth(0) -- set width of 2nd column to longest text entry.
--lvOrderLines~setColumnWidth(1)
--lvOrderLines~setColumnWidth(3)
--say "OrderView-showData-02: arrOrderLines =" arrOrderLines
--orderControls[lvOrderItems]
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
-- "Cancel" - This method over-rides the default Windows action of
-- 'cancel window' for an Escape key.
::METHOD cancel
response = askDialog(.HRSov~QExit, "N")
if response = 1 then forward class (super)
return
/*============================================================================*/
/*//////////////////////////////////////////////////////////////////////////////
==============================================================================
Human-Readable Strings (HRSov) v01-00 07Jun12
--------
The HRSofv class provides constant character strings for user-visible messages.
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
::CLASS HRSov PRIVATE -- Human-Readable Strings
::CONSTANT anAction "An Action"
::CONSTANT NoMenu "This menu item is not implemented."
::CONSTANT QExit "Are you sure you want to cancel this Order View?"
::CONSTANT HelpAbout "About Sales Order"
/*============================================================================*/

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks