0

我已经有一些存储过程可以将信息添加到数据库中。现在我正在创建一个网页,允许用户查看数据库中的某些项目。当用户查看页面时,他或她可以选择编辑/更新或添加新商家。我在控制器中遇到困难,我的方法没有接受我给它的参数。如果您有任何线索或知道答案,请分享..谢谢

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”?因为 MercerTypeRefId 是第一行读取的内容,并且在调用 Model 时需要传递相同的值。如果这不起作用,您可以尝试使用“FormCollection”吗?

于 2012-07-05T17:49:34.620 回答