powerbuilder , check datawindow status

suppose that we have a window that contains datawindow dw_1. suppose that the users starts entering data  and by mistake closes the window before save them. We want to send him a message indicating that the changes that he made will be lost.  we want deal with this issue in the following cases.

1) if the user enters data to store them in a new record (no retrieve has been done)
2) if the user retireves a record and correct some data in it

how can we do it?

basilhs_sAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gafoor78Commented:
You can use  modifiedcount, getitemstatus function of datawindow to achieve this..see PB help for syntax and all.

write those scripts in closequery event of the window,

if something modified or added or deleted then put a messagebox and ask do you want to save changes,
then based on response save the datawindow and close or stop closing by returning 1 from closequery event.

Thanks,
Gafooor
0
gafoor78Commented:
You can do something like below in the closequery event of your window,

dw_1.accepttext()
if dw_1.modifiedcount() > 0 and cb_save.enabled = true then // u can use getitemstatus fn also based on your requirement here
            li_i = MessageBox("title", "Do you want to save changes?",  &
                   question!, YesNocancel!, 2)
            choose case li_i
                  case 1
                        cb_save.triggerevent(clicked!)
                  case 2
                        return
                  case 3
                        dw_1.setfocus()
                        return 1
            end choose
end if
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sandeep_patelCommented:
To save the records that is deleted but not saved, you need to use deletedcount() also
If dw_1.modifiedcount() > 0 OR dw_1.deletedcount() > 0 Then
...........
..........
End If

Regards,
Sandeep
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

basilhs_sAuthor Commented:
thanks all for the reply. suppose that we do the save. will this event reset all the counters you mentioned ?
do we have to retrieve the data again?
0
sandeep_patelCommented:
yes it will reset the count. No need to retrieve the data again
0
sandeep_patelCommented:
to be more specific... there are two arguments in Update(). The second argument is to reset this flags. Default value is always TRUE and it will reset the counts. If it is FALSE then it won't reset.

see pb help for Update function, it's explained in detail there.

Regards,
Sandeep
0
basilhs_sAuthor Commented:
thans very much
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.