473,386 Members | 1,754 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Windows Form Application : Save the Contents then close

Hello,
i make some changes in my windows form applications and commit to save it in my database. However if the commit has not yet taken place.i would like to have an alert box with states if the user wants to quit without saving "yes" or "no".
however i do not know how to implement this. espiacially to check if the commit has taken place or no?

would be gratefull for any suggestion
Jul 29 '08 #1
6 2029
Plater
7,872 Expert 4TB
If anything on the form has been changed since the last time the data was saved, set a boolean to false.
Then check for it on exit?
Jul 29 '08 #2
r035198x
13,262 8TB
If anything on the form has been changed since the last time the data was saved, set a boolean to false.
Then check for it on exit?
That would require a check for every keypress e.t.c on the windows. I'd rather do the check against the database just before exit only. If there is anything on the window that is different from what's in the database then ask for confirmation.
Jul 29 '08 #3
TTCEric
26
That would require a check for every keypress e.t.c on the windows. I'd rather do the check against the database just before exit only. If there is anything on the window that is different from what's in the database then ask for confirmation.
This would be my approach (it avoids the back/forth trips to the database).

1. Create a function that creates a string containing the values in your controls. For example, it creates one huge string of control values.

2. Get the result of the function just after loading the database values. Throw it in a global variable.

3. Before exiting, make another call to the function but this time do a string comparison against the functions returned value and your global string variable. If they dont match, they haven't saved.

Of course, this assumes no one changes database values besides the user using your app. It wont be ideal if you also need to check changes other users may have made.
Jul 29 '08 #4
r035198x
13,262 8TB
More or less what I suggested above without representing all the values as one string though.
Jul 29 '08 #5
TTCEric
26
More or less what I suggested above without representing all the values as one string though.
I find string comparisons very fast so I try to do alot of operations with them.
Jul 29 '08 #6
thank u ..i solved it with the help of boolean values.. thanx a lot
Aug 8 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: KK | last post by:
Windows Forms Inheritance, Incomplete? I was playing around with Windows Forms and found out this Forms Inheritance feature. The moment I saw that, I felt this can be used effectively if the...
2
by: Ron L | last post by:
I have an MDI application which opens a number of child windows, each of which could have data in a state that needs to be saved. Each child window catches its Closing event and cancels it if the...
5
by: RAJ | last post by:
hi plz tell me how to know "how window is going to close"... i have to right code for X button of forms... plz telll me thanks bye
6
by: Ayende Rahien | last post by:
Excetremely annoying problem, I've an application with a long startup time. So I created another form with my logo in it to as a splash screen. The splash screen is run from another thread and is...
5
by: Dave | last post by:
How do I check in a Windows Forms app if any controls have changed? I have a form that collects data, and I want to prompt the user if they try to exit the app, or load a new file, without saving...
9
by: Rajat Tandon | last post by:
Hello there, I am relatively new to the newsgroups and C#. I have never been disappointed with the groups and always got the prompt replies to my queries.This is yet another strange issue, I am...
8
by: david.lindsay.green | last post by:
Hello all, I am quite new a web scripting and making web pages in general and I have stumbled across a problem I have as yet been unable to solve. I am trying to take the contents of a textarea box...
3
by: garyusenet | last post by:
Dear Professionals, I have recently been using the wonderful krypton toolkit and am trying to use them in my small hobby application. I include this bit of info as an aside really because i'm...
1
by: mirandacascade | last post by:
1) Module1 has the following delcaration: Public g_frmZZZ as Form Public g_txtForm2 as Variant 2) app has two forms: form1 and form2 3) a command button on form1 opens form2; it also has...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.