How to edit or freeze only selected record on a grid through Edit/Freeze button on form.

I have created a form called ‘abc_budget’ and data source associated with this form is ‘abc_budget’ table which is containing following three fields :

(a) Date

(b) Amount

(c) Freezed (checkbox)

I took a grid on the form having these 3 fields and two buttons (Edit & Freeze) to edit or freeze the particular selected record.

As if we freeze any record , the ‘Freezed’ checkbox associated with that record should be automatically checked, and if we make any record editable by clicking on ‘Edit’ button ,the ‘Freezed’ checkbox should be automatically unchecked.

I have attached screen shot of the form.

Kindly help me out of this problem.4786.edit_freeze.jpg

Issue resolved.

Step 1 :

On Data source, write ‘Active’ method as below :

public int active()
{
int ret;

ret = super();

if(abc_budget.Isfreezed == noyes::Yes)
{
abc_budget_DS.allowEdit(false);
Freeze.enabled(false);
Edit.enabled(true);
}
else
{
abc_budget_DS.allowEdit(true);
Freeze.enabled(true);
Edita.enabled(true);
}
return ret;
}

Step 2 :

On ‘Edit’ Button , write clicked method as below :

void clicked()
{
super();

if(Box::yesNo(“Are you sure you want to edit the selected record ?”,DialogButton::Yes) == DialogButton::Yes)

{

abc_budget.Isfreezed = NoYes::No;
abc_budget.write();
Freeze.enabled(true);
abc_budget_DS.allowEdit(True);
abc_budget_DS.reread();

}

}

Step 3 :

On ‘Freeze’ Button , write clicked method as below :

void clicked()
{
super();
if(abc_budget.Isfreezed == NoYes::Yes)
info(“Selected record is already freezed.”);

else
{
if(Box::yesNo(“Are you sure you want to Freeze selected record ?”,DialogButton::Yes) == DialogButton::Yes)
{

abc_budget.Isfreezed = NoYes::Yes;
abc_budget.write();
abc_budget_DS.allowEdit(False);
Freeze.enabled(false);

info(“Selected record is now freezed.”);
}
}
abc_budget_DS.reread();

}

Now form will work properly.

Regard,

Deepankar Sharma