| Subject |
Re: Invoice number |
| From |
Akshat Kapoor <akshat.kapoor@kapoorsons.in> |
| Date |
Mon, 7 Sep 2020 22:49:07 +0530 |
| Newsgroups |
dbase.getting-started |
| Attachment(s) |
invoice.dbf, invoice.wfm |
On 07.09.2020 19:29, Bami Onwu wrote:
> Thanks to everyone of you.
>
> Akshat please can you attach a brief example of this in a form?. I will quite appreciate.
Good Evening Bami,
I had posted the form I am using but then I realised without trying to
make it function you will not be able to understand it.
So before I go to bed I have designed a quick and dirty form.
It is lacking in a lot of aspects but since it is just for demo hence it
should work.
Try appending rows with new invoice.
They will be allotted invoice_no at the time of saving and saved
immediately.
Chances of 2 users being allotted the same number are extremely slim.
To replicate network you can open 2 instances of this form.
Regards
Akshat
| ** END HEADER -- do not remove this line
//
// Generated on 07-09-2020
//
parameter bModal
local f
f = new invoiceForm()
if (bModal)
f.mdi = false // ensure not MDI
f.readModal()
else
f.open()
endif
class invoiceForm of FORM
with (this)
height = 22.3636
left = 12.5714
top = 0.0
width = 116.8571
text = ""
endwith
this.INVOICE2 = new QUERY(this)
with (this.INVOICE2)
left = 56.0
top = 5.0
width = 6.0
height = 1.0
sql = "select max(invoice_no) from invoice"
active = true
endwith
this.INVOICE1 = new QUERY(this)
with (this.INVOICE1)
left = 40.0
top = 2.0
width = 6.0
height = 1.0
sql = "select * from invoice where invoice_no = :inv"
params["inv"] = -1
active = true
endwith
with (this.INVOICE1.rowset)
canSave = class::ROWSET_CANSAVE
endwith
this.GRID1 = new GRID(this)
with (this.GRID1)
dataLink = form.invoice1.rowset
allowEditing = false
height = 12.0
left = 2.0
top = 9.0
width = 111.0
endwith
this.TEXTTEXT1 = new TEXT(this)
with (this.TEXTTEXT1)
height = 1.0
left = 6.0
top = 6.5
width = 4.1429
wrap = false
alignVertical = 2 // Bottom
text = "text"
endwith
this.ENTRYFIELDTEXT1 = new ENTRYFIELD(this)
with (this.ENTRYFIELDTEXT1)
dataLink = form.invoice1.rowset.fields["text"]
height = 1.0
left = 18.0
top = 6.5
width = 18.0
endwith
this.TL_INVOICE = new TEXTLABEL(this)
with (this.TL_INVOICE)
height = 1.0
left = 10.0
top = 1.0
width = 25.0
text = "Current Invoice No."
endwith
this.PLUS1 = new PUSHBUTTON(this)
with (this.PLUS1)
onClick = class::PLUS1_ONCLICK
height = 1.0909
left = 89.0
top = 1.5
width = 15.2857
text = "Plus 1"
endwith
this.MINUS1 = new PUSHBUTTON(this)
with (this.MINUS1)
onClick = class::MINUS1_ONCLICK
height = 1.0909
left = 89.0
top = 3.0
width = 15.2857
text = "Minus 1"
endwith
this.NEW = new PUSHBUTTON(this)
with (this.NEW)
onClick = class::NEW_ONCLICK
height = 1.0909
left = 89.0
top = 4.5
width = 15.2857
text = "New Invoice"
endwith
this.CL_OSE = new PUSHBUTTON(this)
with (this.CL_OSE)
onClick = {;form.close()}
height = 1.0909
left = 89.0
top = 6.0
width = 15.2857
text = "Close"
endwith
this.APPEND = new PUSHBUTTON(this)
with (this.APPEND)
onClick = class::APPEND_ONCLICK
height = 1.0909
left = 89.0
top = 7.5
width = 15.2857
text = "Append row"
endwith
this.rowset = this.invoice1.rowset
function APPEND_onClick()
form.rowset.beginappend()
return
function MINUS1_onClick()
form.invoice1.params["inv"] = max(form.invoice1.params["inv"]-1,1)
form.invoice1.requery()
form.tl_invoice.text = "Current Invoice No." + iif(form.invoice1.params["inv"] <1,"new",form.invoice1.params["inv"])
return
function NEW_onClick()
form.invoice1.params["inv"] = -1
form.invoice1.requery()
form.tl_invoice.text = "Current Invoice No." + iif(form.invoice1.params["inv"] <1,"new",form.invoice1.params["inv"])
return
function PLUS1_onClick()
form.invoice1.params["inv"] = max(form.invoice1.params["inv"]+1,1)
form.invoice2.requery()
if form.invoice1.params["inv"] > form.invoice2.rowset.fields[1].value or form.invoice2.rowset.fields[1].value = null
form.invoice1.params["inv"] = -1
endif
form.invoice1.requery()
form.tl_invoice.text = "Current Invoice No." + iif(form.invoice1.params["inv"] <1,"new",form.invoice1.params["inv"])
return
function rowset_canSave()
if this.parent.params["inv"] <1
this.parent.parent.invoice2.requery()
if this.parent.parent.invoice2.rowset.fields[1].value = null
this.parent.params["inv"] =1
else
this.parent.params["inv"] =this.parent.parent.invoice2.rowset.fields[1].value+1
endif
endif
this.parent.parent.tl_invoice.text = "Current Invoice No." + iif(this.parent.params["inv"] <1,"new",this.parent.params["inv"])
if not this.endofset
this.fields["Invoice_no"].value = this.parent.params["inv"]
endif
return true
endclass
|
|