1

ブランチを検索するメソッドがあります。パラメータは支店コードで、支店の詳細を返す必要があります

 public bool SearchBranch()
    {
        using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["DBReader"].ConnectionString))
        {

            using (SqlCommand com = new SqlCommand("Reader.usp_SearchBranch", con))
            {
                com.CommandType = CommandType.StoredProcedure;
                com.Parameters.Add("@BranchCode", SqlDbType.Int).Value = this.BranchCode;

                con.Open();

                SqlDataReader dr = com.ExecuteReader();
                if (dr.Read())
                {
                    this.BranchName = dr.GetValue(0).ToString();
                    this.AreaCode = dr.GetValue(1).ToString();
                    this.RegionCode = dr.GetValue(2).ToString();
                    this.CompanyCode = dr.GetValue(3).ToString();
                    this.CompanyName = dr.GetValue(4).ToString();
                    return true;
                }
                else
                {
                    return false;
                }


            }
        }
    }

Web サービスの Web メソッドのコードを次に示します (これが正しいかどうかはわかりません)。

    [WebMethod(Description = "Search Affected User from Database in Access Request")]
     public bool SearchBranchAccessRequest(AccessRequest accessrequest)
  {
      return accessrequest.SearchBranch();
  } 

そして、これが私のWebページでWebメソッドにアクセス/呼び出す方法です

  protected void SearchBranchButton_Click(object sender, EventArgs e)
    {
        try
        {
            accessrequest.BranchCode = Convert.ToInt32(BranchCodeTextBox.Text);
            iTicketWebService.SearchBranchAccessRequest(accessrequest);

            if (iTicketWebService.SearchBranchAccessRequest(accessrequest) == true)
            {
                BranchNameLabel.Text = accessrequest.BranchName;
                AreaLabel.Text = accessrequest.AreaCode;
                RegionLabel.Text = accessrequest.RegionCode;
                CompanyCodeLabel.Text = accessrequest.CompanyCode;
                CompanyLabel.Text = accessrequest.CompanyName;
                BranchEmailLabel.Text = accessrequest.BranchCode + "@pjlhuillier.com";
            }
            else
            {
                this.ClientScript.RegisterClientScriptBlock(this.GetType(), "clientScript", "<script type=\"text/javascript\">alert('Record not found. Please try again');</script>");
            }
        }
        catch (Exception)
        {
            this.ClientScript.RegisterClientScriptBlock(this.GetType(), "clientScript", "<script type=\"text/javascript\">alert('Wrong Input. Please try again');</script>");

        }
    }

ヘルプ!支店名、市外局番、地域コード、会社コード、会社名を返さないのですか?

4

1 に答える 1