Home > Net >  Object-oriented log in c # winform window procedure what do you mean?
Object-oriented log in c # winform window procedure what do you mean?

Time:02-23

Led by VS and c # design a registered login window procedure, I'm done,
And say this is still a registered login winform window procedure, "bring up the user as a class" "object-oriented"
What is the meaning of this sentence? The following is my first design code
The namespace APP
{
Public partial class Form1: Form//Form1 is inherited Form a class
{
Public _click ()//constructor can't private
{
InitializeComponent ();//initialize the form
}

Private void Form1_Load (object sender, EventArgs e)
{

}

Private void button1_Click (object sender, EventArgs e)//trigger event for the button1_Click
{
If (string. IsNullOrEmpty (textBox1. Text + textBox2. Text))//determine whether null value
MessageBox. Show (" enter the user name and password ", "warning");
The else
{
SqlConnection conn=new SqlConnection (" Data source=(local); Initial Catalog=log; Integrated Security=True ");//instantiate the conn variable, specifies the database connection parameters, do not need the user name and password, namely the Windows authentication mode
Conn. The Open ();//open the conn connection database
SqlCommand CMD=new SqlCommand (" select * from the log where user name='" + textBox1. Text. The Trim () + "' and password='" + textBox2. Text. The Trim () + "' ", conn);//the sqlcommand object allows you to specify on the database to add and delete, database connection object, the execution of database statements
SqlDataReader SDR=CMD. ExecuteReader ();//ExecuteReader method is used to create SqlDataReader object type
The SDR. The Read (); Read data from the database//
If (SDR) HasRows)//use HasRows attribute judgment whether there is data in the results
MessageBox. Show (" landing successful ", "prompt");
The else
MessageBox. Show (" the user name or password is wrong ", "warning");
Conn. Close ();
}
}

Private void textBox1_TextChanged (object sender, EventArgs e)
{

}

Private void label1_Click (object sender, EventArgs e)
{

}

Private void checkBox1_CheckedChanged (object sender, EventArgs e)
{
If (checkBox1. Checked)//default to true
{
TextBox2. PasswordChar='\ 0';
}
The else
{
TextBox2. PasswordChar='*';
}
}

Private void textBox2_TextChanged (object sender, EventArgs e)
{

}

Private void button2_Click (object sender, EventArgs e)
{
Strings str1=textBox1. Text;//read the user name and password
String str2=textBox2. Text;
Int a=0;//check the user name, password complexity
int b=0;
Int c=0;
Int x=0;
Int y=0;
Int z=0;
Int I=textBox1. Text. Length;
Int j=textBox2 Text. Length;
For (int m=0; M & lt; Str1. Length; M++)
{
Char cha1=str1 [m].
If (char. IsLetter (cha1))//whether for letter
{
a++;
}
The else
{
If (char. IsDigit (cha1))//whether to digital
{
B++;
}
The else
If (char. IsPunctuation (cha1))//for punctuation
{
c++;
}
}
}
For (int n=0; N & lt; Str2. Length; N++)
{
Char cha2=str2 [n].
If (char. IsLetter (cha2))
{
x++;
}
The else
If (char. IsDigit (cha2))
{
Y++;
}
The else
If (char. IsPunctuation (cha2))
{
Z++;
}
}
If (a==0 | |==0 b | | c==0 | |==0 x | | y==0 | | z==0 | | I & lt; 6 | | I & gt; 15 | | j & lt; 10 | | j & gt; 15 | | Regex. IsMatch (str1 + str2, "[^ a zA - Z0-9 _]"))//regular expression used to check whether the string and the specified expression match
{
MessageBox. Show (" user name length in 6-15, password length in 10-15, \ n only Numbers, letters, underline, \ n the user name and password must contain Numbers, letters, underline, ", "warning");
}
The else
{
SqlConnection conn=new SqlConnection (" Data Source=(local); Initial Catalog=log; Integrated Security=True ");
Conn. The Open ();
SqlCommand CMD=new SqlCommand (" select * from the log where user name='" + textBox1. Text. The Trim () + "' ", conn);
SqlDataReader SDR=CMD. ExecuteReader ();
The SDR. The Read ();
If (SDR) HasRows)
{
MessageBox. Show (" the user name already exists ", "warning");
}
The else
{
The SDR. The Close ();
String myInsert="insert into the log (username, password) values ('" + textBox1. Text + "', '" + textBox2. Text +") ";
SqlCommand myCom=new SqlCommand (myInsert, conn);//create a SqlCommand object type
MyCom. ExecuteNonQuery ();
Conn. Close ();
Conn. The Dispose ();//shut down and release the object, the next call to recreate the conn
MessageBox. Show (" registration ");
}
}
}
Private void button3_Click (object sender, EventArgs e)//close program
{
Close ();
}
}

}
Also please bosses detailed answer, I am not really familiar with c #, best code instructions, thank you

CodePudding user response:

Have you made object is called

CodePudding user response:

reference 1/f, nan peony reply:
have you made object is called

Object-oriented description I've seen enough to back down, but still confused about, now, let me have input code into separate areas, and then direct call?
I don't know how to say

CodePudding user response:

"Bring up the user as a kind of" the meaning of "object-oriented" this doesn't mean you go with the user object,

Consider:
1. Your Class a EndClient Class,
2. The user name, password, sex, age and so on all kinds of information as a class member function,
3. The login or some other columns as a class of basic operation method,

CodePudding user response:

Abstract
How to make a specific things, abstract

For example, zhang SAN
Abstracted into a person
People have the properties of the name, gender...
Men's event has run, say...

CodePudding user response:

refer to the second floor through passers-by response:
Quote: refer to 1st floor nan peony reply:
have you made object is called

Object-oriented description I've seen enough to back down, but still confused about, now, let me have input code into separate areas, and then direct call?
I don't know how to say


Is the packaging, will give users all kinds of information (database field) to encapsulate, next time your queries directly to the new one user and then fill, pass from hand to hand and then you can use,
nullnullnullnullnullnullnullnullnullnullnullnullnull
  •  Tags:  
  • C#
  • Related