title: calling a function returning boolean in another function
body: <p>I have the following function that I need to call in another function. I dont know how to do it?</p>
  
  <pre><code>private int IsValidUser()
  {            
      int result = 0;
      string strQuery = "Select Email From AUser Where Email = @Email And Password = @Password ";
      SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["ConnectionString"]);
  
      SqlCommand Cmd = new SqlCommand(strQuery, con);
      //Cmd.CommandType = CommandType.StoredProcedure;
  
      Cmd.Parameters.AddWithValue("@Email", txtEmail.Text);
      Cmd.Parameters.AddWithValue("@Password", txtPassword.Text);
      con.Open();
  
      result = (int)Cmd.ExecuteScalar();
  
      if (result &gt; 0)
      {
          //Session["SessionEmail"] = txtEmail.Text;
          Session[General.S_USEREMAIL] = txtEmail.Text;
          Response.Redirect("~/frmMyAccountMyProfile.aspx");
      }
      else
      {
          Literal1.Text = "Invalid Email/Password!";
      }
  }
  </code></pre>
  
  <p>I am trying to call it as below on button click event.</p>
  
  <pre><code>protected void btnSignIn_Click(object sender, EventArgs e)
  {
      // Authenticate User
      bool blnValidUser = false;
      IsValidUser();
      blnValidUser = Convert.ToBoolean(IsValidUser().result.Value);
      if (blnValidUser)
      {
          // on Success - If remember me &gt; Save to cookies
          //SaveUserDetailsToCookie();                       
      }
      else
      {
          // on Failure - Show error msg
      }
  }
  </code></pre>