Hi Guys,
I have tried to update and insert the row using a button click. When I write any value in the cell and go to the next cell or button click then automatically deleted newValue. and insert new row Null and does update newValue.
Any idea for how to set a new value and insert, and update a row using a button click?
- Below script in button action performed for insert row:
table = event.source.parent.getComponent('tbl')
> row = table.selectedRow
> if system.gui.confirm("insert?"):
> Nummer = event.source.parent.parent.Nummer
> col1 = table.data.getValueAt(row, "col1")
> col2 = table.data.getValueAt(row, "col2")
> col3 = table.data.getValueAt(row, "col3")
>
> args = [Nummer, col1,col2,col3]
>
> insertRecord = system.db.runPrepUpdate("insert into Test (Nummer, col1,col2,col3) values (?,?,?,?)", args)
> if insertRecord > 0:
> system.db.refresh(table, "data")
- Below script to update a row in the button action performed:
table = event.source.parent.getComponent('tbl')
data = event.source.parent.getComponent('tbl').data
row = event.source.parent.getComponent('tbl').selectedRow
ValueOne = data.getValueAt(row, "col1")
ValueTwo = data.getValueAt(row, "col2")
ValueThree = data.getValueAt(row, "col3")
ValueFour = data.getValueAt(row, "ID")
args = [ValueOne,ValueTwo,ValueThree,ValueFour]
if system.gui.confirm("are you sure?"):
UpdateRecord = system.db.runPrepUpdate("UPDATE Test SET col1 = ?, col2=?,col3=? where ID = ? ", args)
system.db.refresh(table, "data")
if UpdateRecord > 0:
system.gui.messageBox("updated.")
Thanks in advance
Priyanka