473,499 Members | 1,765 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

password form to perform operation from main form

Hi Everybody!

I have the following problem:
from the application mainForm the user can do several operation
Some of them are password protected
(the password is a code that change everytime on the basis of a
reference code)

so when the user click on a menu in the main form, the passwordForm is
displayed
the user enter the password and click the OK button

now I have a function in the passwordForm that verify the inserted
password against the reference code
if it's correct I can continue to execute the code in the mainForm
else I stop, to perform this my form should return the result to
mainForm and then close...

I can't figure out how to proceed on this, I mean the logic, I don't
want to use the inputbox from vb.dll, only pure C#.

thanks in advance!

marco
Jan 10 '08 #1
2 3051
Hi Marco,

If you display your password form using ShowDialog() you can check either
properties on the form directly, or have passwordForm set a DialogResult
before it closes.

//passwordForm
override OnClosing(... ,...)
{
if(ValidateUser)
this.DialogResult = DialogResult.Yes;
else
this.DialogResult = DialogResult.No;
}

//mainForm

if(passwordForm.ShowDialog() == DialogResult.Yes)
{
//User is valid, execute code
}

--
Happy Coding!
Morten Wennevik [C# MVP]
"ma*******@gmail.com" wrote:
Hi Everybody!

I have the following problem:
from the application mainForm the user can do several operation
Some of them are password protected
(the password is a code that change everytime on the basis of a
reference code)

so when the user click on a menu in the main form, the passwordForm is
displayed
the user enter the password and click the OK button

now I have a function in the passwordForm that verify the inserted
password against the reference code
if it's correct I can continue to execute the code in the mainForm
else I stop, to perform this my form should return the result to
mainForm and then close...

I can't figure out how to proceed on this, I mean the logic, I don't
want to use the inputbox from vb.dll, only pure C#.

thanks in advance!

marco
Jan 10 '08 #2
Many thanks! it works perfectly

On 10 Gen, 13:23, Morten Wennevik [C# MVP]
<MortenWenne...@hotmail.comwrote:
Hi Marco,

If you display your password form using ShowDialog() you can check either
properties on the form directly, or have passwordForm set a DialogResult
before it closes.

//passwordForm
override OnClosing(... ,...)
{
* * *if(ValidateUser)
* * * * this.DialogResult = DialogResult.Yes;
* * *else
* * * * this.DialogResult = DialogResult.No;

}

//mainForm

if(passwordForm.ShowDialog() == DialogResult.Yes)
{
* * *//User is valid, execute code

}

--
Happy Coding!
Morten Wennevik [C# MVP]

"ma.gio...@gmail.com" wrote:
Hi Everybody!
I have the following problem:
from the application mainForm the user can do several operation
Some of them are password protected
(the password is a code that change everytime on the basis of a
reference code)
so when the user click on a menu in the main form, the passwordForm is
displayed
the user enter the password and click the OK button
now I have a function in the passwordForm that verify the inserted
password against the reference code
if it's correct I can continue to execute the code in the mainForm
else I stop, to perform this my form should return the result to
mainForm and then close...
I can't figure out how to proceed on this, I mean the logic, I don't
want to use the inputbox from vb.dll, only pure C#.
thanks in advance!
marco- Nascondi testo tra virgolette -

- Mostra testo tra virgolette -
Jan 10 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
6600
by: HB | last post by:
Please Help In my application I need the user to type their password everytime they perform a certain task. I am using the inputbox function for this but anyone looking over their shoulder can...
0
1345
by: lila | last post by:
I have 'Password to view project properties' in MSAccess 2000, and try to use action in another database -> 'DoCmd.TransferDatabase acExport, "Microsoft Access", P, acModule,…..' but I receive...
3
1771
by: Funky | last post by:
Hi, I have developed an ASP.NET application which has been running in production for around 3 months without any major glitches. Recently, a user was attempting to upload a rather large CSV file...
6
1598
by: Jozef | last post by:
Hello, I've set up VS2003 on my laptop which is running Win XP pro in a stand alone situation, no domain or dc. When I try and "Create a blank solution", I use the Laptop IP address since...
7
3205
by: Roemer | last post by:
Hi all I stumbled over a new problem: I have a programm with just a class that is asynchronous listening for network connections. As soon as someone connected, a new form needs to be created....
6
11863
by: Oleg Konovalov | last post by:
Hi, I have a Java/JavaScript GUI application where I perform a lot of long DB operations , which takes 5-60 secs to perform. Sometimes user double-clicks the button or just gets impatient and...
3
2696
by: Noel S Pamfree | last post by:
Problem 1 ======= I need to create a page for a friend who operates a school website. She needs to set up a page so that only the Governors can access it. I thought I'd try to use JavaScript to...
9
15477
by: webrod | last post by:
Hi all, how can I check a user/password in a LDAP ? I don't want to connect with this user, I would like to connect to LDAP with a ADMIN_LOG/ADMIN_PWD, then do a query to find the user and...
8
2376
by: Rico | last post by:
Hello, I have a form that seems to corrupt over and over again. I can't open it in design view, usually getting a message like "There isn't enough memory to perform this operation. Close...
0
7128
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
7169
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7215
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7385
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5467
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4917
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4597
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3088
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
294
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.