Example #1
0
        private void txtLogin_Click(object sender, EventArgs e)
        {
            sqlConnection = new SqlConnection(appsetting);
            sqlConnection.Open();
            SqlCommand cmd = new SqlCommand();

            cmd.Connection = sqlConnection;
            //Here I am definied command type is Stored Procedure.
            cmd.CommandType = CommandType.StoredProcedure;
            //Here I mentioned the Stored Procedure Name.
            cmd.CommandText = "SPUserLogin";
            //Here I fix the variable values to Stored Procedure Parameters. You can easily understand if you can see the Stored Procedure Code.
            cmd.Parameters.Add(new SqlParameter("@userid", SqlDbType.NVarChar)).Value = txtUsername.Text;
            cmd.Parameters.Add(new SqlParameter("@pwd", SqlDbType.NVarChar)).Value    = txtPassword.Text;
            int usercount = (Int32)cmd.ExecuteScalar(); // for taking single value

            if (usercount == 1)                         // comparing users from table
            {
                this.Hide();
                RentalVideos _tabs = new RentalVideos();
                _tabs.ShowDialog();
            }
            else
            {
                txtUsername.Text = "";
                txtPassword.Text = "";
                MessageBox.Show("Login ID and Password is incorrect.");
            }

            cmd.ExecuteNonQuery();
            cmd.Dispose();
            sqlConnection.Close();
        }
Example #2
0
        private void btnBack_Click(object sender, EventArgs e)
        {
            this.Hide();
            RentalVideos _tabs = new RentalVideos();

            _tabs.ShowDialog();
        }