Exemple #1
0
        private void button_login_Click(object sender, EventArgs e)
        {
            string username = textBox_username.Text;
            //Server_Connection get_server = new Server_Connection();
            Socket client_socket = Server_Connection.Connect_Server();
            string search_text   = "Select username from user_table where username="******"Select password from user_table where username="******"该用户还未注册", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (result2.ToString() != textBox_password.Text)
            {
                MessageBox.Show(this, "密码错误", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                string info;
                info = Server_Connection.Loginto_Server(username, client_socket);
                if (info == "lol")
                {
                    MessageBox.Show(this, "登录成功", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    //登陆成功,打开主窗口界面
                    Main_Window main_window = new Main_Window(username, client_socket);
                    main_window.Show();
                    connection.Close();
                    this.Hide();
                }
                else if (info == "Incorrect login No.")
                {
                    MessageBox.Show(this, "该用户名不规范", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }
Exemple #2
0
        private void button_register_Click(object sender, EventArgs e)
        {
            string username  = textBox_username.Text;
            string password  = textBox_password.Text;
            string password2 = textBox_password2.Text;

            //密码输入不一致
            if (password != password2)
            {
                MessageBox.Show(this, "密码输入不一致", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                string info = Server_Connection.Loginto_Server(username, client_socket);
                if (info == "Incorrect login No.")
                {
                    MessageBox.Show(this, "用户名不符合规范", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    string search_text = "Select username from user_table where username="******"该用户已被注册", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    //注册成功
                    else
                    {
                        string insert_text  = "insert into user_table(username,password) values(" + username + "," + password + ")";
                        string insert_text2 = "insert into friend_table(username,friend_list) values(" + username + "," + username + ")";

                        /*
                         * using (SqlCommand cmd = connection.CreateCommand())
                         * {
                         *  cmd.CommandText = insert_text;
                         *  cmd.ExecuteNonQuery();
                         *  cmd.CommandText = insert_text2;
                         *  cmd.ExecuteNonQuery();
                         * }
                         */
                        My_Database.SQLite_Insert(insert_text, connection);
                        My_Database.SQLite_Insert(insert_text2, connection);
                        MessageBox.Show(this, "注册成功", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        connection.Close();
                        this.Close();
                    }
                }
            }
            textBox_username.Clear();
            textBox_password.Clear();
            textBox_password2.Clear();
        }