-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInventoryCountingPanel.bbj
137 lines (90 loc) · 3.85 KB
/
InventoryCountingPanel.bbj
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
class public InventoryCountingPanel
field private BBjChildWindow panel!
field private BBjInputE itemNo!
field private BBjCEdit itemData!
field private BBjInputN qtyCounted!
field private BBjButton save!
field private BBjNumber sqlchan
field private BBjString currItem$
rem pass child window for this panel
method public InventoryCountingPanel(BBjChildWindow wnd!)
#panel! = wnd!
#panel!.setPanelStyle("display","flex")
#panel!.setPanelStyle("flex-direction","column")
#panel!.setPanelStyle("gap","20px")
#panel!.setPanelStyle("max-width","500px")
#panel!.addStaticText("<html><h1>Inventory Counting</h1>")
#itemNo! = #panel!.addInputE("")
#itemNo!.setAttribute("label","Item#")
#itemNo!.setAttribute("invalid-message","Item not found.")
#itemNo!.setAttribute("validation-style","inline")
#itemNo!.setAttribute("auto-validate","false")
#itemNo!.setCallback(BBjAPI.ON_INPUT_KEYPRESS,#this!,"onItemNo")
#itemNo!.setCallback(BBjAPI.ON_GAINED_FOCUS,#this!,"onItemNoFocus")
#itemData! = #panel!.addCEdit("")
#itemData!.setAttribute("label","Item Information")
#itemData!.setStyle("height","120px")
#qtyCounted! = #panel!.addInputN()
#qtyCounted!.setAttribute("label","Qty Counted")
#qtyCounted!.setCallback(BBjAPI.ON_INPUT_KEYPRESS,#this!,"onQtyCounted")
#save! = #panel!.addButton("Save")
#save!.setAttribute("expanse","xl")
#save!.setAttribute("theme","success")
#save!.setCallback(BBjAPI.ON_BUTTON_PUSH,#this!,"onSave")
#sqlchan = SQLUNT()
sqlopen (#sqlchan)"CDStore"
#showData(0)
methodend
rem disable default constructor
method private InventoryCountingPanel()
methodend
method public void focus()
#itemNo!.focus()
methodend
method public void onItemNo(BBjInputKeypressEvent ev!)
if ev!.getKeyCode() = 13 then
inp$ = #itemNo!.getText()
sql$="SELECT * FROM CDINVENTORY WHERE CDNUMBER=?"
sqlprep (#sqlchan)sql$
sqlexec (#sqlchan)inp$
dim rec$:sqltmpl(#sqlchan)
rec$=sqlfetch(#sqlchan,err=no_data)
#itemData!.setText(rec.TITLE$+$0d$+rec.ARTIST$+$0d$+"On Hand: "+rec.ONHAND$)
#qtyCounted!.focus()
#currItem$ = rec.CDNUMBER$
#showData(1)
#itemNo!.setAttribute("invalid","false")
fi
methodret
no_data:
#itemNo!.focus()
#itemNo!.selectAll()
#itemNo!.setAttribute("invalid","true")
methodend
method public void onQtyCounted(BBjInputKeypressEvent ev!)
if ev!.getKeyCode() = 13 then
#onSave(null())
fi
methodend
method public void onSave(BBjButtonPushEvent ev!)
qty! = #qtyCounted!.getValue()
item! = #currItem$
rem save the counted quantity for the item
sql$="UPDATE CDINVENTORY SET ONHAND=? WHERE CDNUMBER=?"
sqlprep (#sqlchan) sql$
sqlexec (#sqlchan) qty!,item!
#itemNo!.setText("")
#itemData!.setText("")
#qtyCounted!.setValue(0)
#showData(0)
#itemNo!.focus()
methodend
method private void showData(Boolean fShow!)
#save!.setVisible(fShow!)
#qtyCounted!.setVisible(fShow!)
#itemData!.setVisible(fShow!)
methodend
method public void onItemNoFocus(BBjGainedFocusEvent ev!)
#showData(0)
methodend
classend