C#_ member Management System: Development Five (user registration)

Source: Internet
Author: User

Create a new user registration form (VIPRegistration.cs):

The user registration Form (VIPRegistration.cs) detailed code is as follows:

1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.ComponentModel;4 usingSystem.Data;5 usingSystem.Drawing;6 usingSystem.Linq;7 usingSystem.Text;8 usingSystem.Threading.Tasks;9 usingSystem.Windows.Forms;Ten usingSystem.Data.SqlClient; One usingSystem.Configuration; A  - namespacemember Management System - { the      Public Partial classVipregistration:form -     { -          Publicvipregistration () -         { + InitializeComponent (); -         } +  A  at         //Submit Button -         Private voidBtnok_click (Objectsender, EventArgs e) -         { -              -             stringConnStr = configurationmanager.connectionstrings["Str"]. ConnectionString; -SqlConnection conn =NewSqlConnection (CONNSTR); in             stringsql =string. Format ("Select vUserName from Vipaccount where Vusername= ' {0} '", txtName.Text); -SqlCommand cmd =NewSqlCommand (SQL, conn); to Conn. Open (); +SqlDataReader sda=cmd. ExecuteReader (); -  the             if(TxtName.Text.Trim () = ="") *             { $lblname.text="user name cannot be empty";Panax Notoginseng                 return; -             } the             Else if(TxtPwd.Text.Trim () = =""|| TxtPwdConfirm.Text.Trim () = ="") +             { ALblpwd.text ="The password cannot be empty"; the                 return; +             } -             Else if(TxtPwdConfirm.Text.Trim ()! =TxtPwd.Text.Trim ()) $             { $Lblpwdconfirm.text ="two times the password input is different, please confirm and then lose"; -                 return; -             } the             Else if(SDA. Read ()) -             {WuyiLblname.text ="user name already exists, please re-enter"; the                 return; -             } Wu             Else -             { About Conn. Close (); $SqlConnection Conninsert =NewSqlConnection (CONNSTR); -                 stringInsertsql =string. Format ("INSERT INTO Vipaccount (VUSERNAME,VUSERPWD) VALUES (' {0} ', ' {1} ')", txtname.text,txtpwd.text); -SqlCommand Cmdinsert =NewSqlCommand (Insertsql, conninsert); - Conninsert. Open (); A                 intn =Cmdinsert. ExecuteNonQuery (); +                 if(n = =0) the                 { -MessageBox.Show ("registration failed, please re-enter"); $                 } the                 Else the                 { theMessageBox.Show ("Registration Successful"); the                 } - Conninsert. Close (); in  the             } the             //Conn. Close (); About         } the  the         //back to main menu the         Private voidBtnback_click (Objectsender, EventArgs e) +         { -Vipmain VM =NewVipmain (); the VMs. Show ();Bayi              This. Hide (); the         } the  -         Private voidVipregistration_load (Objectsender, EventArgs e) -         { theLblname.text =""; theLblpwd.text =""; theLblpwdconfirm.text =""; the         } -          the     } the}

The main interface form (VIPMain.cs) adds a new button:

User Registration Button Code:

1         Private void Btnregistration_click (object  sender, EventArgs e)2        {3              New  vipregistration (); 4             Vrn. Show (); 5              This . Hide (); 6         }

C#_ member Management System: Development Five (user registration)

Related Article

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.