Recording system
Warcraft Login System
1: Create three forms: frmlogin,frmmain,frmregist (Omit step ...)
2: Create an array of objects with a length of 10
Public userinfo[] user = new USERINFO[10];
3: Initialize the array and assign values .
public void Fanfa ()
{
initializing an array
User[0] = new UserInfo ();
User[0].id = 1;
User[0].mail = "1";
User[0].pwd = "1";
}
4: Verify that the mailbox and password are correct in the click time of the login button, and use the value in the text box to iterate through the array to see if there is a value that matches it.
foreach (UserInfo item in user)
{
if (item! = NULL)
{
if (Item.mail = = Mail && item.pwd = = password)
{
Flag = true;
}
}
}
5: If the data matches , implement the jump of the form .
6: Pass the text information of the entered mailbox to the frmmain form . Create a static variable in the Frmmain form , Assign the input text to a static variable in the Frmmain form in the Frmlogin. The label control is displayed .
form2.str = mail;
public static string str;
private void Form2_load (object sender, EventArgs e)
{
Label1. Text = " welcome " +STR;
}
7: Complete the registration function, implement the form jump, create a variable in frmregist,
The Frmlogin Form object is assigned to this variable in the Register button time in Frmlogin, which allows the form to jump after the registration is complete
Frmregist in :p ublic Form1 login;
Frmlogin : Form3 frm = new Form3 ();
Frm.login = this;
8: Implement the Registration function, create an object of the UserInfo class, assign the property of the class, and bind the object in the array, find an empty location to hold the data to be registered
UserInfo user = new UserInfo ();
User.ID = Convert.ToInt32 (TextBox1.Text);
User.mail = TextBox2.Text;
User.pwd = TextBox3.Text;
for (int i = 0; i<login.user.length; i++)
{
if (login.user[i] = = null)
{
Login.user[i] = user;
}
}
Warcraft Login System