Exemplo n.º 1
0
        private void signup_bt_Click(object sender, EventArgs e)
        {
            con.Open();
            if (con.State == System.Data.ConnectionState.Open)
            {
                SqlDataAdapter sda1 = new SqlDataAdapter("select count(*) from thongtindangnhap where username='******'", con);
                DataTable      dt   = new DataTable();
                sda1.Fill(dt);
                if (dt.Rows[0][0].ToString() == "1")
                {
                    MessageBox.Show("The username has already existed , connecting to roomchat....");
                    giaodien_roomchat n = new giaodien_roomchat();
                    n.Show();
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("Incorrect username or password");
                }
                SqlDataAdapter sda = new SqlDataAdapter("INSERT INTO thongtindangnhap(username,password,firstname,lastname,email)values('" + username_tb.Text + "','" + password_tb.Text + "','" + firstname_tb.Text + "','" + lastname_tb.Text + "','" + phonenb_tb.Text + "')", con);
                sda.SelectCommand.ExecuteNonQuery();

                con.Close();
                MessageBox.Show("Signing in successfully, connecting roomchat......");
                giaodien_roomchat gdrc = new giaodien_roomchat();
                gdrc.Show();
                this.Hide();
                con.Close();
            }
        }
Exemplo n.º 2
0
        private void login_bt_Click(object sender, EventArgs e)
        {
            string user = username_tb.Text;
            string pass = password_tb.Text;

            con.Open();
            SqlDataAdapter sda = new SqlDataAdapter("select count(*) from thongtindangnhap where username='******'and password='******'", con);
            DataTable      dt  = new DataTable();

            sda.Fill(dt);
            if (dt.Rows[0][0].ToString() == "1")
            {
                MessageBox.Show("Login successfully, connecting to roomchat....");
                giaodien_roomchat n = new giaodien_roomchat();
                n.Show();
                this.Hide();
            }
            else
            {
                MessageBox.Show("Incorrect username or password");
            }
            con.Close();
        }