B
Brad Pears
Hi guys!!! Thanks for all your input on previous OO posts. I know it will
be all the same people responding again and I really appreciate your insight
etc.. as you all appear to know what you are doing - each having your own
flare but that is what makes us individuals right?? Anyway, here is a quick
question... (or maybe not so quick)
In my business "Contract" class I have many properties.
When I set these "contract" properties in the GUI layer front end (i.e
populating the Contract business class) when the 'Save' button is clicked, I
want to pass the values to the "data" class for update/insert etc...
Do I create the same "properties" on the data class as I have on the
business class and populate the data class from the properties of the
business class? OR should I pass all the variables as a parameter list
from teh business class to the method I am invoking on the data class to do
the update/insert etc .. ?
I guess the biggest question is should data classes use the same
properties - as in the associated business class(s)? What is the best way to
get the data from teh business class to the data class?
I have been doing the following... (used only 2 properties for demonstration
sake)
The front end would set and call the update method on the business class
"clsContract" as follows
public sub btmSave_click (bunch of aprameters)
' Save the Contract data
dim oCB as new clsContract
' Set class properites
oCB.ContractNo = me.txtContractNo.text
oCB.CustID = me.txtCustID.text
' Call update method to update/insert the data
oCB.Update(oCB.ContractNo)
' clean up
oCB = nothing
end sub
public class clsContract
private sContractNo as string
private iCustID as integer
public property ContractNo as string
get
return sContractNo
end get
set (byval value as string)
sContractNo = value
end set
public property CustID as integer
get
return iCustID
end get
set (byval value as integer)
iCustID = value
end set
public sub new
mybase.new
...some code
end sub
Public sub Update(byval sContractNo as string)
' Call dataclass update method
dim oCD as new clsContract_Data
' Set data class property then update
oCD.CustID = me.CustID
oCD.update(sContractNo)
' Clean up
oCD = nothing
end sub
public class clsContract_Data
private sContractNo as string
private iCustID as integer
public property ContractNo as string
get
return sContractNo
end get
set (byval value as string)
sContractNo = value
end set
public property CustID as integer
get
return iCustID
end get
set (byval value as integer)
iCustID = value
end set
public sub new(sContractNo as string)
mybase.new
me.ContractNo = sContractNo
end sub
Public sub Update(sContractNo as string)
' Call stored procedure to do updatemethod
dim bRet as boolean = false
' Call stored procedure with appropriate parameters
bRet is RunSP("spname", me.ContractNo, me.CustID)
if not bret then
msgbox("Error")
endif
return bret
end sub
Thanks, Brad
be all the same people responding again and I really appreciate your insight
etc.. as you all appear to know what you are doing - each having your own
flare but that is what makes us individuals right?? Anyway, here is a quick
question... (or maybe not so quick)
In my business "Contract" class I have many properties.
When I set these "contract" properties in the GUI layer front end (i.e
populating the Contract business class) when the 'Save' button is clicked, I
want to pass the values to the "data" class for update/insert etc...
Do I create the same "properties" on the data class as I have on the
business class and populate the data class from the properties of the
business class? OR should I pass all the variables as a parameter list
from teh business class to the method I am invoking on the data class to do
the update/insert etc .. ?
I guess the biggest question is should data classes use the same
properties - as in the associated business class(s)? What is the best way to
get the data from teh business class to the data class?
I have been doing the following... (used only 2 properties for demonstration
sake)
The front end would set and call the update method on the business class
"clsContract" as follows
public sub btmSave_click (bunch of aprameters)
' Save the Contract data
dim oCB as new clsContract
' Set class properites
oCB.ContractNo = me.txtContractNo.text
oCB.CustID = me.txtCustID.text
' Call update method to update/insert the data
oCB.Update(oCB.ContractNo)
' clean up
oCB = nothing
end sub
public class clsContract
private sContractNo as string
private iCustID as integer
public property ContractNo as string
get
return sContractNo
end get
set (byval value as string)
sContractNo = value
end set
public property CustID as integer
get
return iCustID
end get
set (byval value as integer)
iCustID = value
end set
public sub new
mybase.new
...some code
end sub
Public sub Update(byval sContractNo as string)
' Call dataclass update method
dim oCD as new clsContract_Data
' Set data class property then update
oCD.CustID = me.CustID
oCD.update(sContractNo)
' Clean up
oCD = nothing
end sub
public class clsContract_Data
private sContractNo as string
private iCustID as integer
public property ContractNo as string
get
return sContractNo
end get
set (byval value as string)
sContractNo = value
end set
public property CustID as integer
get
return iCustID
end get
set (byval value as integer)
iCustID = value
end set
public sub new(sContractNo as string)
mybase.new
me.ContractNo = sContractNo
end sub
Public sub Update(sContractNo as string)
' Call stored procedure to do updatemethod
dim bRet as boolean = false
' Call stored procedure with appropriate parameters
bRet is RunSP("spname", me.ContractNo, me.CustID)
if not bret then
msgbox("Error")
endif
return bret
end sub
Thanks, Brad