| Subject |
Print receipt on pos |
| From |
Emeka Ossai <megameks@yahoo.com> |
| Date |
Tue, 30 Aug 2022 15:42:02 -0400 |
| Newsgroups |
dbase.getting-started |
Hi all,
I am working on pos application, everything is working well except I cannot print receipt on clicking save button. I use dbase9 and mysql.
My problem is how can I code a routine such that when I click post button, it should print receipt based on my last update.
Below is my POST onclick event
function BTNPOST_onClick
// prep query to get next batch No
qGetBatchNo = new query()
qGetBatchNo.database = form.d
qGetBatchNo.requestLive = false
qGetBatchNo.sql = [SELECT nextBatchNo FROM SYSCONTROL]
qGetBatchNo.active = true
//rGetBatchNo= qSYSCONTROL.rowset
rGetBatchNo= qGetBatchNo.rowset
rGetBatchNo.first()
batchNo = rGetBatchNo.fields["nextbatchno"].value
qGetBatchNo.active = false
// prepare insert query
local qInsert
qInsert = new query()
qInsert.database = form.d
qInsert.requestLive = false
qInsert.sql = [INSERT INTO CASHIERBOOK (stockno, stockname, amount, amountb, unitofmeasure,oquantity, quantity, modeofpmt, entrydate, customername, userID, batchid, sysdate,;
systime,item,balance,grosstot, discountamt,netamt,cash,pos, price) ;
VALUES (:stockno,:stockname,:amount,:amountb,:unitofmeasure,:oquantity,:quantity,:modeofpmt,:entrydate,:customername,:userID,:batchid,:sysdate,;
:systime,:item,:balance,:grosstot, :discountamt,:netamt, :cash,:pos,:price)]
qInsert.active = false
// query for temp table
qTempTable = new query()
qTempTable.reuestLive = false
qTempTable.sql = [SELECT * FROM CASHIER_TEMP WHERE userID = :userID]
qTempTable.database = form.d
qTempTable.params["userID"] = _app.UserID
qTempTable.active = true
rTempTable = qTempTable.rowset
rTempTable.first()
// loop through temp table data and insert each row into real table
do while not rTempTable.endofset
qInsert.active = false
qInsert.params["batchid"] = rTempTable.fields["batchid"].value
qInsert.params["stockno"] = rTempTable.fields["stockno"].value
qInsert.params["stockname"] = rTempTable.fields["stockname"].value
qInsert.params["amount"] = rTempTable.fields["amount"].value
qInsert.params["amountb"] = rTempTable.fields["amountb"].value
qInsert.params["unitofmeasure"] = rTempTable.fields["unitofmeasure"].value
qInsert.params["oquantity"] = rTempTable.fields["quantity"].value
qInsert.params["quantity"] = 0.00
//qInsert.params["branch"] = rTempTable.fields["branch"].value
qInsert.params["modeofpmt"] = rTempTable.fields["modeofpmt"].value
// qInsert.params["bank"] = rTempTable.fields["bank"].value
qInsert.params["customername"] = rTempTable.fields["customername"].value
qInsert.params["userID"] = rTempTable.fields["userID"].value
qInsert.params["item"] = "STOCK OUT"
qInsert.params["balance"] = 0.00
qInsert.params["entrydate"] = rTempTable.fields["entrydate"].value
qInsert.params["grosstot"] = form.txtbatchtotal.text
// qInsert.params["discount"] = form.container1.discount.value
qInsert.params["discountamt"] = form.container1.discountamt.value
qInsert.params["netamt"] = form.container1.netamt.value
qInsert.params["cash"] = form.container1.cash.value
qInsert.params["pos"] = form.container1.pos.value
qInsert.params["price"] = rTempTable.fields["buyprice"].value
qInsert.params["sysdate"] = date()
qInsert.params["systime"] = time()
local wSearch
wSearch = new query()
wSearch.database = form.d
wSearch.requestLive = false
wSearch.sql = [SELECT * FROM CASHIERPOOL WHERE stockno = :stockno AND stockname <> "SERVICES"]
wSearch.params["stockno"] = rTempTable.fields["stockno"].value
wSearch.params["stockname"] = rTempTable.fields["stockname"].value
wSearch.active = true
if wSearch.rowset.count() = 1 // if found
local wUpdate
wUpdate = new query()
wUpdate.database = form.d
wUpdate.requestLive = false
// General Tab
wUpdate.sql = [UPDATE CASHIERPOOL SET quantity = :quantity where stockno =:stockno]
wUpdate.params["stockno"] = rTempTable.fields["stockno"].value
wUpdate.params["quantity"] = wSearch.rowset.fields['quantity'].value-rTempTable.fields["quantity"].value
wUpdate.requery()
wUpdate.active = false
endif
// General Tab
// increment batch NO
qInc = new query()
qInc.database = form.d
qInc.requestLive = false
qInc.sql = [UPDATE SYSCONTROL SET nextBatchNo = :nextBatchNo]
qInc.params["nextBatchNo"] = batchNo + 1
qInc.requery()
qInc.active = false
qinsert = null
// show next number in Spin Control
form.spnBatchNo.value = batchNo + 1
// Delete transactions from temp table
qDelete = new query()
qDelete.requestLive = false
qDelete.database = form.d
qDelete.sql = [DELETE FROM CASHIER_TEMP WHERE userID = :userID]
qDelete.params["userID"] = _app.UserID // or what ever user ID it is
qDelete.requery()
// clear grid of updated transactions
form.setGrid()
form.checkBatchTotal()
form.entquantity.value = 0
form.buyprice.value = 0.00
form.entamount.value = 0.00
form.cmbaccount.value = ""
form.container1.entaccountcode.value = ""
form.stockno.value = ""
form.entsubcode.value = 0.00
form.container1.cash.value = 0.00
form.container1.pos.value = 0.00
form.custno.value = ""
form.stockbalance.value = ""
form.customername.value = ""
form.container1.discountamt.value = 0.00
form.container1.netamt.value = 0.00
form.stockno.enabled = true
form.btnSave.enabled = true
form.btnPost.enabled = true
form.stockno.setfocus()
do reprintreceipt.wfm
return
Thank you all.
Emeka
|
|