Below is the script I have on a button. After all the checks to make sure things are as they should be and the query or query’s are performed I want to reset certain fields on the screen as you see at end. Is there a way to label that group and then call that label in the script so there is only one place things need changed? I hope that makes sense…
[code]IDEMP = event.source.parent.IDEMP
IDLOCATION = event.source.parent.IDLOCATION
IDMATERIAL = event.source.parent.IDMATERIAL
IDTRANSTYPE = event.source.parent.IDTRANSTYPE
QUANTITY = event.source.parent.getComponent(‘QTY Box’).intValue
REASON = event.source.parent.getComponent(‘ReasonDropdown’).selectedValue
COMPANY = event.source.parent.getComponent(‘CompanyDropdown’).selectedValue
MACHINE = event.source.parent.getComponent(‘MachineDropdown’).selectedValue
Query to insert a addition or hard count into inventory
QRY = “INSERT INTO tbl_invtransactions (id_employee, id_invtranstype, id_ourmaterial, id_location, qty, date) VALUES (%d,%d,%d,%d,%d,CURRENT_TIMESTAMP)” % (IDEMP, IDTRANSTYPE, IDMATERIAL, IDLOCATION, QUANTITY)
#print QRY
if event.source.parent.getComponent(‘TransTypeDropdown’).selectedStringValue == “Out”:
if REASON != -1:
print “step 1”
if COMPANY != -1:
print “Step 2”
if MACHINE != -1:
print “step 3”
NEWID = system.db.runUpdateQuery (“INSERT INTO tbl_invtransactions (id_employee, id_invtranstype, id_ourmaterial, id_location, qty, date) VALUES (%d,%d,%d,%d,%d,CURRENT_TIMESTAMP)” % (IDEMP, IDTRANSTYPE, IDMATERIAL, IDLOCATION, QUANTITY), getKey=1)
#print NEWID
system.db.runUpdateQuery (“INSERT INTO tbl_invtransdetails (id_invtransaction, id_invreason, id_machine, id_company) VALUES (%d,%d,%d,%d)” % (NEWID, REASON, MACHINE, COMPANY))
#
# Insert screen reset call here
#
else:
#print “Bad Step 3”
system.gui.messageBox(“Need to Select a Machine”)
else:
#print “Bad Step 2”
system.gui.messageBox(“Need to Select a Company”)
else:
#print “Bad step 1”
system.gui.messageBox(“Need to Select a Reason Code”)
Do a inventory IN or a HARD COUNT
else:
NEWID = system.db.runUpdateQuery (“INSERT INTO tbl_invtransactions (id_employee, id_invtranstype, id_ourmaterial, id_location, qty, date) VALUES (%d,%d,%d,%d,%d,CURRENT_TIMESTAMP)” % (IDEMP, IDTRANSTYPE, IDMATERIAL, IDLOCATION, QUANTITY), getKey=1)
#print NEWID
#
# Insert screen reset call here
#
Reset these fields on screen for selection of next input
event.source.parent.getComponent(‘QTY Box’).intValue = 0
event.source.parent.getComponent(‘Table 2’).selectedRow = -1
event.source.parent.getComponent(‘Table 1’).selectedRow = -1
event.source.parent.getComponent(‘LocationBox’).text =""
event.source.parent.getComponent(‘LocationBox’).MyString = “”
event.source.parent.getComponent(‘ReasonDropdown’).selectedValue = -1
event.source.parent.getComponent(‘CompanyDropdown’).selectedValue = -1
event.source.parent.getComponent(‘MachineDropdown’).selectedValue = -1
fpmi.db.refresh(event.source.parent.getComponent(“Table 2”),“data”)[/code]