示例#1
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            passar = txtregno.Text;

            connection.Open();
            SqlCommand check = new SqlCommand(
                "select * from StudentPassword where RegNo='" + txtregno.Text + "' and Password='******';", connection
                );
            SqlDataReader readcheck = check.ExecuteReader();

            if (readcheck.Read())
            {
                connection.Close();
                StudentLogedForm stu = new StudentLogedForm();
                stu.Visible = true;
                this.Hide();
            }
            else
            {
                connection.Close();
                MessageBox.Show("Check your RegNo and Password...");
                txtregno.Text    = "";
                txtpassword.Text = "";
            }
        }
示例#2
0
        private void login_Click(object sender, EventArgs e)
        {
            if (password.Text == confirmpassword.Text)
            {
                connection.Open();

                SqlCommand readNIC = new SqlCommand(
                    "select * from StudentTable where RegNo='" + txtpassword.Text + "';", connection
                    );
                SqlDataReader read = readNIC.ExecuteReader();
                if (read.Read())
                {
                    connection.Close();
                    connection.Open();
                    SqlCommand readNIC2 = new SqlCommand(
                        "select * from StudentPassword where RegNo='" + txtpassword.Text + "';", connection
                        );
                    SqlDataReader read2 = readNIC2.ExecuteReader();
                    if (read2.Read())
                    {
                        connection.Close();
                        MessageBox.Show("Already You have an Student account...");
                        txtpassword.Text     = "";
                        password.Text        = "";
                        confirmpassword.Text = "";
                    }
                    else
                    {
                        connection.Close();
                        connection.Open();
                        SqlCommand insert = new SqlCommand(
                            "insert into StudentPassword values('" + txtpassword.Text + "','" + password.Text + "');", connection
                            );
                        insert.ExecuteNonQuery();
                        connection.Close();
                        StudentLogedForm stu = new StudentLogedForm();
                        stu.Visible = true;
                        this.Hide();
                    }
                }
                else
                {
                    connection.Close();
                    MessageBox.Show("There is no any RegNo insert by admin.......");
                    txtadmin.Text        = "";
                    password.Text        = "";
                    confirmpassword.Text = "";
                }
            }
            else
            {
                MessageBox.Show("confirm password != password");
            }
        }