存储过程错误 - '程序或功能'requisition_sp_setstatus0'需要参数'@ReqNumber',但未提供

时间:2017-11-17 11:20:03

标签: asp.net

当我点击批准时,我收到此错误:'过程或函数'requisition_sp_setstatus0'需要参数'@ReqNumber',这是未提供的。'一旦我删除了这行代码

@*<tr>
                        <td>@Html.CheckBoxFor(m => m[i].postTrnx, new { @class = "checkGroup1" })</td>
                        <td class="label">
                            @Html.DisplayFor(m => m[i].reqNumber)
                            @Html.DisplayFor(m => m[i].reqDate)


                        </td>
                    </tr> 

但我不想采用那种格式,而是在表格中展示。为什么函数不从表中提取请求编号,而是从显示中提取。我必须选择显示部分以便批准它。

public void SetRequisitionStatus0(List<string> docNumbers)
        {
            SqlConnection connection = new SqlConnection(connectionString);
            SqlCommand command = new SqlCommand();
            command.CommandText = "requisition_sp_setstatus0";
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@ReqNumber", SqlDbType.VarChar);
            command.Parameters.Add("@approve_date", SqlDbType.DateTime).Value = DateTime.Now;
            using (command.Connection = connection)
            {
                try
                {
                    connection.Open();
                    foreach (var item in docNumbers)
                    {
                        command.Parameters["@ReqNumber"].Value = item;
                        command.ExecuteNonQuery();
                    }

                }
                catch (Exception ex)
                {

                    throw ex;
                }
                finally
                {
                    connection.Close();
                }
            }
            return;

        }
@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()

    <div>

        <hr />

        </div>

        <div class="form-group">
            <div class="col-md-offset-2 col-md-10">
                @*<input type="submit" value="Issue" name="Issue" class="btn btn-default" />*@
                @*<input type="submit" value="Search" name="Search" class="btn btn-default" />*@

            </div>
        </div>



        <table id="data">

            <thead>

                <tr>
                    <th class="col-lg-1">@Html.CheckBox("TheOneCheckBoxToRuleThemAll")Select All</th>
                    <th class="col-lg-1 ">Date</th>
                    <th class="col-lg-1 ">Requisition Number</th>
                    <th class="col-lg-1 ">Expense Account</th>
                    <th class="col-lg-1">Requestor</th>
                    <th class="col-lg-1">Department</th>
                    <th class="col-lg-1">LoggedinAs</th>
                    <th class="col-lg-1 ">Item Number</th>
                    <th class="col-lg-1 ">Description</th>
                    <th class="col-sm-1">Quantity</th>
                    <th class="col-sm-1 ">UOM</th>

                    </tr>

            <tbody>
                @for (int i = 0; i < Model.Count; i++)
                {
                    @Html.HiddenFor(m => m[i].reqNumber)
                    @Html.HiddenFor(m => m[i].department)
                    @Html.HiddenFor(m => m[i].department)


                    @*<tr>
                        <td>@Html.CheckBoxFor(m => m[i].postTrnx, new { @class = "checkGroup1" })</td>
                        <td class="label">
                            @Html.DisplayFor(m => m[i].reqNumber)
                            @Html.DisplayFor(m => m[i].reqDate)


                        </td>
                    </tr>*@
                    foreach (var item in Model[i].items)
                    {
                        @Html.HiddenFor(m => item.description)
                            @Html.HiddenFor(m => item.expense_account)
                            @Html.HiddenFor(m => item.itemNumber)
                        <tr>
                            <td>@Html.CheckBoxFor(m => m[i].postTrnx, new { @class = "checkGroup1" })</td>
                            <td class="col-lg-1 tabledata" >@item.requisition.reqDate</td>
                            <td class="col-lg-1 tabledata" >@item.requisition.reqNumber</td>
                            <td class="col-lg-1 tabledata">@item.expense_account.account_desc</td>
                            <td class="col-lg-1 tabledata">@item.employeeDetails.employeeNum</td>
                            <td class="col-lg-1 tabledata">@item.employeeDetails.department</td>
                            <td class="col-lg-1 tabledata">@item.employeeDetails.LoggedInUserName</td>
                            <td class="col-lg-1 tabledata">@item.itemNumber</td>
                            <td class="col-lg-1 tabledata">@item.description</td>
                            <td class="col-sm-1 tabledata">@item.quantity</td>
                            <td class="col-sm-1 tabledata">@item.selecteduomtext </td>

                            @*<td>@Html.ActionLink("Edit", "Edit", new { id = @item.lineNum, name = Model[i].reqNumber })</td>*@
                        </tr>

                    }

                }
            </tbody>
        </table>

        <br /><br /><br />


    <div>
        <input type="submit" value="Approve" name="Approve" class="btn btn-default" onclick="return confirm('Click OK to continue or Cancel to abort');" />&nbsp;&nbsp;&nbsp;&nbsp;

        </div>

}

0 个答案:

没有答案