Parameter question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I have a class that have a Login Method that opens a Login Form
The client that calls the Login Method should receive the User_ID if logins succed
Is it possible to return from the Login form to the method the UserID and from the method to the client

//THIS IS THE LOGIN METHOD THAT WILL CALL THE LOGIN FOR
public string GUILogin(string sDBUser, string sDBPassw, string sDBDsn

Form oform=new dlgLogin(sDBUser, sDBPassw, sDBDsn, ref ID_Util)
oform.ShowDialog()
// CAN I CATCH HERE THE USERID STORED IN A FORM VARIABLE OR SOMETHING LIKE THAT


Thanks for your help
Bernardo Piano
 
Bernardo said:
Hi,

I have a class that have a Login Method that opens a Login Form.
The client that calls the Login Method should receive the User_ID if logins succed.
Is it possible to return from the Login form to the method the UserID and from the method to the client?

//THIS IS THE LOGIN METHOD THAT WILL CALL THE LOGIN FORM
public string GUILogin(string sDBUser, string sDBPassw, string sDBDsn)
{
Form oform=new dlgLogin(sDBUser, sDBPassw, sDBDsn, ref ID_Util);
oform.ShowDialog();
// CAN I CATCH HERE THE USERID STORED IN A FORM VARIABLE OR SOMETHING LIKE THAT?
}

Thanks for your help,
Bernardo Piano

If dlgLogin is your own class, just implement a property containing the user
ID as entered by the user.
So in the dlgLogin form something like,
public string UserID
{
get
{
return (UserIDInputControl).Text;
}
}

Then in the login method, read it like
userID = oform.UserID;

Is that what you're looking for?

Eric
 
Hi,

You can declare a property in the dlgLogin class that contain the userID ,
you will have to check if the login was not succesful and something about
it.

Cheers,
 
Hi, Bernardo!
I have a class that have a Login Method that opens a Login Form.
The client that calls the Login Method should receive the User_ID if logins succed.
Is it possible to return from the Login form to the method the UserID and from the method to the client?

//THIS IS THE LOGIN METHOD THAT WILL CALL THE LOGIN FORM
public string GUILogin(string sDBUser, string sDBPassw, string sDBDsn)
{
Form oform=new dlgLogin(sDBUser, sDBPassw, sDBDsn, ref ID_Util);
oform.ShowDialog();
// CAN I CATCH HERE THE USERID STORED IN A FORM VARIABLE OR SOMETHING LIKE THAT?
}



Use this sample code:


namespace App.UI
{
public class FormLogin : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button_Accept;
private System.Windows.Forms.Button button_Cancel;
private System.Windows.Forms.TextBox UserID;
private System.Windows.Forms.TextBox Password;

#region Windows Form Designer generated code
...
#endregion

public static DialogResult ShowDialog(out string UserID, out string
Password, IWin32Window owner)
{
DialogResult ret;
FormLogin frm = new FormLogin();
ret = frm.ShowDialog(owner);
UserID = frm.UserID.Text;
Password = frm.Password.Text;
return ret;
}

public static DialogResult ShowDialog(out string UserID, out string
Password)
{
DialogResult ret;
FormLogin frm = new FormLogin();
ret = frm.ShowDialog();
UserID = frm.UserID.Text;
Password = frm.Password.Text;
return ret;
}
}
}
 
Back
Top