Edit Method on table methods:-
We have 2 methods which we used to access another table data in our form in which we don't have that table as data source.Those are display and edit methods.
Edit method example:
Suppose take 2 tables cartable and rental table
cartable fields-->1)carid as edt and primary index
2)Milege as edt
Rental Table Fields-->1)Carid
2)Custid
steps:
make a relation between cartable and rental table (normal relation in rental table with carid)
create a find method in cartable as
public static cartable find(carid _carid )
{
cartable car;
;
select car where car.carid==_carid;
return car;
}
now create an edit method in rental table to edit milege of carid in cartable ,the method looks like
edit milege editmilege(boolean set,milege value)
{
cartable cartable;
milege ret;
;
cartable=cartable::find(this.carid);
if(set)
{
cartable.selectForUpdate(true);
ttsbegin;
cartable.milege=value;
cartable.update();
ttscommit;
return value;
}
else
{
ret=cartable.milege;
}
return ret;
}
now to test this create a form with rental table as data source and create a grid in design .Drag this edit method into grid it creates a column mileage .
open form and change the milege value it reflects in cartable .this is possible in case of edit method .if we use display method we cannot have a chance to change value .
We have 2 methods which we used to access another table data in our form in which we don't have that table as data source.Those are display and edit methods.
Edit method example:
cartable fields-->1)carid as edt and primary index
2)Milege as edt
Rental Table Fields-->1)Carid
2)Custid
steps:
make a relation between cartable and rental table (normal relation in rental table with carid)
create a find method in cartable as
public static cartable find(carid _carid )
{
cartable car;
;
select car where car.carid==_carid;
return car;
}
now create an edit method in rental table to edit milege of carid in cartable ,the method looks like
edit milege editmilege(boolean set,milege value)
{
cartable cartable;
milege ret;
;
cartable=cartable::find(this.carid);
if(set)
{
cartable.selectForUpdate(true);
ttsbegin;
cartable.milege=value;
cartable.update();
ttscommit;
return value;
}
else
{
ret=cartable.milege;
}
return ret;
}
now to test this create a form with rental table as data source and create a grid in design .Drag this edit method into grid it creates a column mileage .
open form and change the milege value it reflects in cartable .this is possible in case of edit method .if we use display method we cannot have a chance to change value .
No comments:
Post a Comment