Subject |
Re: String question |
From |
Akshat Kapoor <akshat.kapoor@kapoorsons.in> |
Date |
Thu, 16 Nov 2023 18:31:50 +0530 |
Newsgroups |
dbase.getting-started |
Attachment(s) |
inve.dmd |
Good Evening Mervyn,
> Here we go again. As soon as I say "can't be done" someone, Akshat in
> this case, proves me wrong. :-)
>
> I was fixated on inserting commas into the "numeric" strings Charlie is
> using. This is easily done in a function but, even if it is possible,
> it would need a monster codeblock as the calculated field's
> beforeGetValue event handler.
>
Apart from adding field in sql there is another option. Add a calculated
field to the rowset using addfield().
Attached code was fully functional till I switched over to ADO and
started using sql to add fields.
Since I had opted in for Quick and dirty so did not revisit the attached
piece of code.
Regards
Akshat
|
** END HEADER -- do not remove this line
//
// Generated on 25.02.2017
//
class inveDATAMODULE of DATAMODULE
this.VATRATE = new QUERY(this)
with (this.VATRATE)
left = 138.0
top = 19.0
database = mcompany.db
sql = 'select recno,tax,vat,sat from "vatrate.dbf"'
requestlive = true
active = true
endwith
with (this.VATRATE.rowset)
indexName = "TAX"
autoNullFields = false
endwith
/*this.INV = new QUERY(this)
with (this.INV)
left = 446.0
top = 23.0
sql = 'Select * from "'+mcompany.direct+'\inv'+mcompany.fyear+'.dbf"'
requestlive = true
active = true
endwith
with (this.INV.rowset)
indexName = "RECNO"
autoNullFields = false
endwith*/
this.INVE = new QUERY(this)
with (this.INVE)
onOpen = class::INVE_ONOPEN
left = 291.0
top = 22.0
database = mcompany.db
sql = 'Select * from "inve'+mcompany.fyear+'.dbf"'
//requestlive = false
active = true
endwith
with (this.INVE.rowset)
indexName = "RECNO"
with (fields["tax"])
lookupRowset = form.vatrate.rowset
endwith
with (fields["full"])
beforeGetValue = {||iif(this.parent["company"].value#null ,ltrim(this.parent["company"].value),"1") ;
+iif(this.parent["item"].value#null , ltrim(this.parent["item"].value), "1" ) ;
+iif(this.parent["descrip"].value#null , ltrim(this.parent["descrip"].value), "1" );
+iif(this.parent["bcode"].value#null , ltrim(this.parent["bcode"].value), "1" )}
endwith
with (fields["nett"])
beforegetvalue = {||iif(this.parent["offerp"].value >0,this.parent["offerp"].value ,round(this.parent["mrp"].value*(1-this.parent["disc"].value/100),0))}
endwith
autoNullFields = false
endwith
this.rapid = new QUERY(this)
with (this.rapid)
left = 251.0
top = 22.0
database = mcompany.db
sql = 'SELECT rapid.key_st, rapid.company, rapid.item , rapid.descrip , inve.recno FROM "rapid" INNER JOIN "inve'+mcompany.fyear+'" inve ON (rapid.company=inve.Company AND rapid.item=inve.item AND rapid.descrip=inve.descrip)'
requestlive = false
//?sql
active = true
endwith
with (this.rapid.rowset)
autoNullFields = false
endwith
function inve_onOpen()
g = new field()
g.fieldname = "full"
this.rowset.fields.add(g)
g.beforegetvalue = {||iif(this.parent["company"].value#null ,ltrim(this.parent["company"].value),"1") ;
+iif(this.parent["item"].value#null , ltrim(this.parent["item"].value), "1" ) ;
+iif(this.parent["descrip"].value#null , ltrim(this.parent["descrip"].value), "1" );
+iif(this.parent["bcode"].value#null , ltrim(this.parent["bcode"].value), "1" )}
h = new field()
h.fieldname = "nett"
this.rowset.fields.add(h)
h.beforegetvalue = {||iif(this.parent["offerp"].value >0,this.parent["offerp"].value ,round(this.parent["mrp"].value*(1-this.parent["disc"].value/100),0))}
return
endclass
|
|