QQ Basic code

Source: Internet
Author: User
Using System;
Using System.Collections.Generic;
Using System.ComponentModel;
Using System.Data;
Using System.Drawing;
Using System.Linq;
Using System.Text;
Using System.Threading.Tasks;
Using System.Windows.Forms;
Using System.Data.SqlClient;
Using Myqq; namespace QQ {Public ' partial class Loginfrm:form {public loginfrm () {Initializeco
        Mponent (); }//The form is loaded with private void Loginfrm_load (object sender, EventArgs e) {this.picFace.Image
        = This.imageface.images[0]; }//The form that occurs when the text box is changed private void Txtnum_textchanged (object sender, EventArgs e) {if (this . TxtNum.Text.Trim ().
                Length = = 5) {this.txtPwd.Focus (); String sql = string.
                Format ("Select FaceId from Users where Id = {0}", This.txtNum.Text);
                SqlCommand cmd = new SqlCommand (sql, dbhelper.conn); try {DBHelper. OPENDB (); This.picFace.Image = This.imageface.images[convert.toint32 (cmd.
                ExecuteScalar ())]; } catch (Exception ex) {MessageBox.Show (ex.
                ToString ());
                } finally {dbhelper.closedb ();
            }} else {this.picFace.Image = this.imageface.images[0];
            }}//Determine if the QQ number password is filled with public bool ValidateInput () {if (This.txtNum.Text = = "") {MessageBox.Show ("QQ number must be filled in.
                "," Login Prompt ", messageboxbuttons.ok,messageboxicon.asterisk);
                This.txtNum.Focus ();
            return false; } if (This.txtPwd.Text = = "") {MessageBox.Show ("password required.
                "," Login Prompt ", MessageBoxButtons.OK, Messageboxicon.asterisk);
                This.txtPwd.Focus (); Return FALse
        } return true;
            }//Determine login status public int getloginstate () {int loginstate = 0;
            String sql = "";
            SqlCommand cmd = new SqlCommand ();
            SqlDataReader reader = null;
                try {dbhelper.opendb (); sql = string.
                Format ("Select Loginstate from users where id = {0}", This.txtNum.Text);
                Cmd.commandtext = SQL; Cmd.
                Connection = Dbhelper.conn; reader = cmd.
                ExecuteReader (); if (reader.
                Read ()) {loginstate = Convert.ToInt32 (reader[0]); } reader.
            Close (); } catch (Exception ex) {MessageBox.Show (ex.
            ToString ());
            } finally {dbhelper.closedb ();
        } return loginstate;
 }//Click the login button on the main form       private void Btnlogin_click (object sender, EventArgs e) {if (ValidateInput ()) { String sql = string.
                Format ("Select COUNT (*) from users where Id = {0} and loginpwd = ' {1} '", This.txtNum.Text, This.txtPwd.Text);
                SqlCommand cmd = new SqlCommand (sql, dbhelper.conn); try {if (getloginstate () = = 0) {DBHelper
                        . OPENDB (); if (Convert.ToInt32 (cmd). ExecuteScalar ()) = = 1) {//Save login QQ Logi
                            NHELPER.FROMQQ = Convert.ToInt32 (This.txtNum.Text); sql = string.
                            Format ("Update users set loginstate=1 where id = {0}", Txtnum.text);
                            Cmd.commandtext = SQL; Cmd.
                            Connection = Dbhelper.conn; Cmd.
                      ExecuteNonQuery ();      MainFrm ma = new mainfrm (); Ma.
                            Show (); This.
                        Hide (); } else {MessageBox.Show ("Account or password is incorrect.
                            "," Login Prompt ", MessageBoxButtons.OK, Messageboxicon.asterisk);
                            This.txtNum.Text = "";
                            This.txtPwd.Text = "";
                        This.txtNum.Focus (); }} else {MessageBox.Show ("account already logged in this computer"
                        , "Login Prompt", MessageBoxButtons.OK, Messageboxicon.asterisk);
                        This.txtNum.Text = "";
                        This.txtPwd.Text = "";
                        This.txtNum.Focus ();
                    Return }} catch (Exception ex) {MessageBox.Show (ex).
                ToString ());
 }               finally {dbhelper.closedb ();
            }}}//Can only enter the number private void Btncancel_click (object sender, EventArgs e) {
        Application.exit (); The private void Txtnum_keypress (object sender, KeyPressEventArgs e) {if (Convert.ToInt32 (E.key Char) < 48 | |
            Convert.ToInt32 (E.keychar) >) {e.handled = true;
            } if (Convert.ToInt32 (e.keychar) = = 8) {e.handled = false;
                }}//Prevent comment attack private void Txtpwd_keypress (object sender, KeyPressEventArgs e) {
                if (Convert.ToInt32 (e.keychar) = =) {e.handled = true;
                } if (Convert.ToInt32 (e.keychar) = =) {e.handled = true; }}//to the noteVolume form private void linkwangjimima_linkclicked (object sender, LinkLabelLinkClickedEventArgs e) {
             REGISTERFRM F2 = new Registerfrm (); F2.
         ShowDialog (); }//Exit program private void Loginfrm_formclosed (object sender, Formclosedeventargs e) {A Pplication.
         Exit ();
         }//To the forgot password form private void Linklabel1_linkclicked (object sender, LinkLabelLinkClickedEventArgs e)
             {resetpwdfrm WJ = new Resetpwdfrm (); Wj.
         ShowDialog (); }
    }
}

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.