C # study notes (a) - Form

Examples login window (receive and process data) 

            String Lusername = the this .usernameDL.Text;                                            // get content and stored inside the control 
            String = Lpassword the this .passwordDL.Text;
             IF (Lusername.Equals ( "" ) || Lpassword.Equals ( "" ))                                   // determine whether the input is empty 
                MessageBox.Show ( " user name or password can not be blank " );
             the else  iF (Lusername.Equals (BL.username) && Lpassword.Equals (BL.password))            // determining whether the input data coincides with the form specified by the value of the already registered form by the same
                MessageBox.Show ( " Login successful " );
             the else 
                MessageBox.Show ( " user name or password is incorrect, please re-enter " );                                // error handling 
================== ================================================== ================================================== ==== 
registration window (for data transfer and input value) 

            BL.username = the this .textBox1.Text;                  // pass through a common variable value is defined 
            BL.password = the this .textBox2.Text; 
            BL.phone = the this . textBox3.Text; 
            BL.email= The this .textBox4.Text; 
            MessageBox.Show ( " registered successfully " );
             the this .Close ();                                      // close the current window

 
===================== ================================================== ================================================== ======== 

defined in the main variable Program.cs public class (value transfer between a form, the data transfer exaggerated form) 

the using the System;
 the using the System.Collections.Generic;
 the using the System.Linq;
 the using the System. the Text; 

namespace WindowsFormsApplication1 
{ 
    class BL 
    { 
        public  static  Stringusername; / * for the convenience of traditional values between different bed, a purpose-built storage common class (static variables) referred to by the common name of the variable class the CLASS. * / 
        public  static  String password;
         public  static  String Phone;
         public  static  String In Email; 
    } 
}


 ------------------------------------------------ -------------------------------------------------- ------------------------- 

display (pop-up) a new window 
method. 1 
FormMain FM = new new FormMain ();                   
fm.ShowDialog ();    

method 2 
new new Form_zc () the Show ();.                                            // eject subform modeless
new new Form_zc () the ShowDialog ();.                                      // eject Subform modal
   
--------------------------------- -------------------------------------------------- ----------------------------------------- 
Show other (verification displayed before the main window ) and the data processing form front 
the Program.cs 

Application.EnableVisualStyles ();                          // the MAIN function source code, without modifying 
Application.SetCompatibleTextRenderingDefault ( to false );      // the MAIN function source code, without modifying 

Form_login Login = new new Form_login () ;              // display window - login 
login.ShowDialog ();                               // display window - login 
if(login.DialogResult == DialogResult.OK) // Analyzing the front window returns
the Application.Run ( new new FormMain ()); // start the main window (FormMain) the else return ; supporting the front window codes the this .DialogResult = DialogResult.OK ; // returns to a main function of login authentication dialog state by the this .Close (); // Close the current (login) form

 

Guess you like

Origin www.cnblogs.com/gougouwang/p/11669554.html
Recommended