C # form (Login interface)

Source: Internet
Author: User

First drag a lable (write user name) followed by a Textbox

Then lable( write password ) followed by a TextBox (need to set properties - behavior -Usesystempasswordchar( The default password is black ))

Plus button (text login)

Such as:

1, Properties--Miscellaneous (AcceptButton set to Button1) can press ENTER to display the next page

2, the value: login.cs[design] to main.cs[design] a value in the construction method: 1, in the main.cs[design] Drag a lable to prepare to receive

And then reload a method in the Main.cs:

Again in the Login.cs to receive:--Build the main form object when main m=new main (UID)

Double-click Login plus an event:

The data manipulation classes are as follows:

public partial class Login:form
{
public string Username;
Public Login ()
{
InitializeComponent ();
}

private void Button1_Click (object sender, EventArgs e)
{
First remove the username and password
Define variables to take to user name, password
String uid= textuid. Text;
String pwd= textpwd. Text;
And then judge if the UID is empty.
if (uid! = "" && pwd! = "")
{
Don't judge if the UID pwd is a match.
Manipulating databases to do three of classes

Loginda da = new Loginda (); create an object before calling the method
Da.                      Denglu (UID,PWD); call the method in the third class and pass two arguments.
if (DA. Denglu (UID, pwd)) judgment
{

After logging in, close the login page, display only the main page, main becomes the main form
Assigning a user name to a member variable username
Username = UID;
change the return value of the form to OK three steps
This. DialogResult = DialogResult.OK;
Close the form
This. Close ();
}
Else
{
MessageBox.Show ("User name or password is wrong! ");
}

}


Else
{
If it is empty
MessageBox.Show ("User name and password cannot be empty!") ");
}

}

Changes required: Program.cs

Drop-down list:

public partial class Main:form
{

Private Zgda CDA;
Public Main ()
{
InitializeComponent ();
}
Public main (string username)//overloaded with a Main method
{

InitializeComponent ();

CDA = new Zgda ();

}

private void Label1_click (object sender, EventArgs e)
{

}

private void Main_load (object sender, EventArgs e)
{

Populate the province's drop-down list
Fillsheng ();
Fill City drop-down list
Fillshi ();
Drop-down list of populated areas
Fillqu ();
}

private void Cmbsheng_selectedindexchanged (object sender, EventArgs e)

{
Fill City drop-down list
Fillshi ();

}

private void Cmbshi_selectedindexchanged (object sender, EventArgs e)
{
Drop-down list of populated areas
Fillqu ();
}
public void Fillsheng ()//method of filling Province
{
list<zg> list= cda.select ("0001");A collection of all the subsets under that parent that are traced to the parent code
Cmbsheng. DataSource = List;Give the found collection to the province's dropdown as a data source
Cmbsheng. DisplayMember = "Name";Show national Names
Cmbsheng. ValueMember = "Code";background values are national codes .
}
public void Fillshi ()methods of filling the city
{
list<zg> List = Cda.select (Cmbsheng. Selectedvalue.tostring ());Select which province to take the code of which province
Cmbshi. DataSource = List;send the found collection to the city's dropdown as a data source
Cmbshi. DisplayMember = "Name";Show national Names
Cmbshi. ValueMember = "Code";background values are national codes .
}
public void Fillqu ()//method of filling the city
{
list<zg> List = Cda.select (Cmbshi. Selectedvalue.tostring ());Select which province to take the code of which province
Cmbqu. DataSource = List;send the found collection to the city's dropdown as a data source
Cmbqu. DisplayMember = "Name";Show national Names
Cmbqu. ValueMember = "Code";background values are national codes .
}
}
}

C # form (Login interface)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.