0

データベースに情報を追加するためのストアド プロシージャが既にいくつかあります。現在、ユーザーがデータベース内の特定のアイテムを表示できる Web ページを作成しています。ユーザーがページを表示すると、編集/更新または新しいマーチャントを追加するオプションが表示されます。私のメソッドが与えられたパラメーターを取り込んでいないコントローラーで問題が発生しています。手がかりがある場合、または答えを知っている場合は、共有してください..ありがとう

PS追加機能にカーソルを合わせると、bool MerchantTypeRef.addMerchantTypeRef(MerchantAdminProductionServices.MerchantTypeRef MerchantTypeRef)と表示されます

エラー: 'MerchantAdministrator.Models.MerchantAdminProduction.MerchatTypeRef.addMerchantTypeRef(MerchantAdministrator.MerchantAdminProductionServices.MerchantTypeRef)' に最適なオーバーロードされたメソッド マッチには無効な引数が含まれています

コントローラ

 [MerchantAuthorizeAttribute(AdminRoles = "AddMerchantTypeRef")]
    public ActionResult AddMerchantTypeRef()
    {
        try
        {
            Guid merchantTypeRefId = Request["merchantTypeRefId"] != null ? new Guid(Request["merchantTypeRefId"]) : Guid.Empty;
               string name = Request["name"]?? string.Empty;
            string description = Request["description"]?? string.Empty;
            string xMerchantType = Request["xMerchantTypeRefCode"]??string.Empty;
            DarkstarAdministrator.DarkstarAdminProductionServices.MerchantTypeRef merchantTypeRef = new DarkstarAdministrator.DarkstarAdminProductionServices.MerchantTypeRef();

            merchantTypeRef.name = name;
            merchantTypeRef.description = description;
            merchantTypeRef.xMerchantTypeCode = xMerchantType;
           ViewBag.addMerchantTypeRef = MerchantAdministrator.Models.MerchantAdminProduction.MerchantTypeRef.addMerchantTypeRef(merchantTypeRef);  <------This where I have the Trouble . not reading parameter
        }
        catch (Exception e)
        {
            Commons.ErrorHandling.ReportError("MerchantAdministrator.Controllers.ProdController AddMerchantTypeRef()", e);
        }
        return View();

    }

モデル

  public static bool addMerchantTypeRef(DarkstarAdminProductionServices.MerchantTypeRef merchantTypeRef)
    {
        try
        {
            DarkstarAdminProductionServices.DarkstarAdminProductionServicesSoapClient client = new DarkstarAdminProductionServices.DarkstarAdminProductionServicesSoapClient();
            return client.addMerchantTypeRef(merchantTypeRef);
        }
        catch (Exception e)
        {
            Commons.ErrorHandling.ReportError("MerchantTypeRef.addMerchantTypeRef()", e);

        }
        return false;
    }

参照

 [System.Runtime.Serialization.DataMemberAttribute(IsRequired=true)]
    public System.Guid merchantTypeRefId {
        get {
            return this.merchantTypeRefIdField;
        }
        set {
            if ((this.merchantTypeRefIdField.Equals(value) != true)) {
                this.merchantTypeRefIdField = value;
                this.RaisePropertyChanged("merchantTypeRefId");
            }
        }
    }

    [System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue=false)]
    public string name {
        get {
            return this.nameField;
        }
        set {
            if ((object.ReferenceEquals(this.nameField, value) != true)) {
                this.nameField = value;
                this.RaisePropertyChanged("name");
            }
        }
    }

    [System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue=false, Order=2)]
    public string description {
        get {
            return this.descriptionField;
        }
        set {
            if ((object.ReferenceEquals(this.descriptionField, value) != true)) {
                this.descriptionField = value;
                this.RaisePropertyChanged("description");
            }
        }
    }

    [System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue=false, Order=3)]
    public string xMerchantTypeCode
    {
        get {
            return this.xMerchantTypeCodeField;
        }
        set {
            if ((object.ReferenceEquals(this.xMerchantTypeCodeField, value) != true)) {
                this.xMerchantTypeCodeField = value;
                this.RaisePropertyChanged("xMerchantTypeCode");
            }
        }
    }

意見

<script type="text/javascript">
$(document).ready(function () {
    $("#merchantTypeUpdateButton").click(function () {
        $("#updateMerchantType").submit();
    });
});

販売者タイプの編集

<%MerchantAdministrator.MerchantAdminProductionServices.MerchantTypeRef     EditMerchantType = ViewBag.MerchantTypeRefEdit !=null ? ViewBag.MerchantTypeRefEdit: new    MerchantAdministrator.DarkstarAdminProductionServices.MerchantTypeRef(); %>
<form id="updateMerchantType" action="<%=Url.Action("EditMerchantTypePost","Prod") %>?    merchantTypeRefId"=<%=EditMerchantType.merchantTypeRefId %>" method="post">
    <table>
        <tr>
            <td colspan="3" class="tableHeader">Merchant Type Ref Details</td>
        </tr>
        <tr>
            <td colspan="2" class="label">Name:</td>
            <td class="content">
                <input type="text" maxlength="100" name="Name" value="  <%=EditMerchantType.name %>" />
        </td>
    </tr>
     <tr>
        <td colspan="2" class="label">Description:</td>
        <td class="content">
            <input type="text" maxlength="2000" name="Description" value="<%=EditMerchantType.description %>" />
        </td>
    </tr>
     <tr>
        <td colspan="2" class="label">Merchant Type Code:</td>
        <td class="content">
            <input type="text" maxlength="5" name="XMerchantTypeCode" value="<%=EditMerchantType.xMerchantTypeCode %>" />
        </td>
    </tr>
    <tr>
        <td colspan="3" class="tableFooter">
                <br />
                <a id="merchantTypeUpdateButton" href="#" class="regularButton">Save</a>
                <a href="javascript:history.back()" class="regularButton">Cancel</a>
        </td>
    </tr>
</table>

4

1 に答える 1

1
bool ViewBag.addMerchantTypeRef = MerchantAdministrator.Models.MerchantAdminProduction.MerchantTypeRef.addMerchantTypeRef(merchantTypeRef);

これが「merchantTypeRef」または「merchantTypeRefId」であることを教えてください。MerchantTypeRefId は最初の行で読み取られるものであり、Model を呼び出すときに同じ値を渡す必要があるためです。うまくいかない場合は「FormCollection」で試してみてはいかがでしょうか。

于 2012-07-05T17:49:34.620 に答える