c# - Pass a value from login form to main form -


I have a login screen and I need to pass the username in my main form (to get permission etc.) ). Here is my code:

  // Login Private Zero button 1_Click (object sender, EventArgs e) {if (string.IsNullOrEmptE (txtUser.Text)) {// show warning} and if ( Using string IISNullOrEmpty (txtPass.Text)) (// Show Warning) (DataTable dt = LookupUser (txtUser.Text)) // See the username and password for the SQL data table {if (dt.ows.Count = = 0) {// show warning} other {string dbPassword = Convert.ToString (dt.Rows [0] ["pass"]); String app password = encrypt (txtPass.Text); If (string.Compare (dbPassword, appPassword) == 0) {// I need to pass my form to myForm ... DialogResult = DialogResult.OK; } Else {// Show Warning}}}} Program Program CST Static Wide Men () {Application.EnableVisualStyles (); Application.SetCompatibleTextRenderingDefault (wrong); Dialog result result; Usage (var loginForm = new login ()) Results = loginForm.ShowDialog (); If (result == DialogResult.OK) {application.Run (new myForm ()); }}  

What would be the best way to price from login.cf and program from myForm?

in the login form

  public string username {get; Private set;} if (string .computer (DB password, app password) == 0) {username = TSTUser. Text; // I have to give the username to my form ... DialogResult = DialogResult.OK; } Other {// show warning}  

in the main

  dialog result result; Usage (var loginForm = new login ()) Results = loginForm.ShowDialog (); If (result == DialogResult.OK) {var username = loginForm.UserName; Application.Run (new MyForm (user name)); }  

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -