thread184-1777610
I hope mine is correct.
***********************************
* mvc sample
***********************************
oView = createobject('myform')
with oView
.addobject('controller1','myController1')
.addobject('controller2','myController2')
with .controller1
.be('sendEmail','button1','click')
endwith
with .controller2
.be('print' ,'button2','click')
.be('changeColor','button2','click')
.be('retrieveCustomer','button2','click')
endwith
.show()
endwith
read events
***********************************************
define class controller as custom
osource = ''
function be(action,src,eventname)
bindevent(this.parent.&src,m.eventname,this,m.action) && action = m.action
ENDFUNC
procedure osource_access
aevents(asrc,0)
return asrc(1)
ENDPROC
enddefine
***********************************************
***********************************************
define class myController1 as controller
procedure sendemail
messagebox(" I'll send an email! / Form Caption: "+this.parent.caption )
ENDPROC
enddefine
***********************************************
***********************************************
define class myController2 as controller
ADD OBJECT model as MyModel
procedure print
messagebox("I will print.. My Caption is : "+this.osource.caption)
ENDPROC
procedure changecolor
thisform.backcolor = rgb(26, 118, 209)
ENDPROC
PROCEDURE retrieveCustomer
this.model.retrieveCustomer()
thisform.showCustomerName(this.model)
ENDPROC
enddefine
***********************************************
*********************************************
define class myform as form
add object button1 as commandbutton ;
with caption= "I don't know what I do ",;
left = 10, height = 50 , visible = .t., width = 150
add object button2 as commandbutton ;
with caption= " me neither!",;
left = 10, top = 100,height = 50, width = 150, visible = .t.
add object customerLabel as label ;
with caption= "",;
left = 10, top = 180,height = 40, width = 150, visible = .t.
caption = 'MVC DEMO '
procedure destroy
clear events
ENDPROC
PROCEDURE showCustomerName(toModel as Object)
this.customerLabel.caption = toModel.cName
ENDPROC
enddefine
*********************************************
*********************************************
DEFINE CLASS MyModel as Custom
cName = ""
PROCEDURE retrieveCustomer
SELECT cs_Name FROM customer WHERE cs_tel='07891430852' INTO CURSOR lcCursor
this.cName = "Customer name is " + cs_name
USE IN lcCursor
ENDPROC
ENDDEFINE
*********************************************
I hope mine is correct.
***********************************
* mvc sample
***********************************
oView = createobject('myform')
with oView
.addobject('controller1','myController1')
.addobject('controller2','myController2')
with .controller1
.be('sendEmail','button1','click')
endwith
with .controller2
.be('print' ,'button2','click')
.be('changeColor','button2','click')
.be('retrieveCustomer','button2','click')
endwith
.show()
endwith
read events
***********************************************
define class controller as custom
osource = ''
function be(action,src,eventname)
bindevent(this.parent.&src,m.eventname,this,m.action) && action = m.action
ENDFUNC
procedure osource_access
aevents(asrc,0)
return asrc(1)
ENDPROC
enddefine
***********************************************
***********************************************
define class myController1 as controller
procedure sendemail
messagebox(" I'll send an email! / Form Caption: "+this.parent.caption )
ENDPROC
enddefine
***********************************************
***********************************************
define class myController2 as controller
ADD OBJECT model as MyModel
procedure print
messagebox("I will print.. My Caption is : "+this.osource.caption)
ENDPROC
procedure changecolor
thisform.backcolor = rgb(26, 118, 209)
ENDPROC
PROCEDURE retrieveCustomer
this.model.retrieveCustomer()
thisform.showCustomerName(this.model)
ENDPROC
enddefine
***********************************************
*********************************************
define class myform as form
add object button1 as commandbutton ;
with caption= "I don't know what I do ",;
left = 10, height = 50 , visible = .t., width = 150
add object button2 as commandbutton ;
with caption= " me neither!",;
left = 10, top = 100,height = 50, width = 150, visible = .t.
add object customerLabel as label ;
with caption= "",;
left = 10, top = 180,height = 40, width = 150, visible = .t.
caption = 'MVC DEMO '
procedure destroy
clear events
ENDPROC
PROCEDURE showCustomerName(toModel as Object)
this.customerLabel.caption = toModel.cName
ENDPROC
enddefine
*********************************************
*********************************************
DEFINE CLASS MyModel as Custom
cName = ""
PROCEDURE retrieveCustomer
SELECT cs_Name FROM customer WHERE cs_tel='07891430852' INTO CURSOR lcCursor
this.cName = "Customer name is " + cs_name
USE IN lcCursor
ENDPROC
ENDDEFINE
*********************************************