Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public ActionResult RequestItem(Requisition requisition)
- {
- IssueDAO dbdata = new IssueDAO();
- dbdata.connectionString = ConfigurationManager.ConnectionStrings["TWCL_OPERATIONSConnectionString"].ConnectionString;
- getRequisition.reqDate = DateTime.Now; //Sets the transaction date to current date
- getRequisition.status = -1;
- ViewBag.ReceivedbyReps = dbdata.SelectEmployeesByDept(requisition.department);
- Item item = new Item();
- try
- {
- dbdata.createRequisition(getRequisition, item);//Creates the issue in the database
- }
- catch (Exception ex)
- {
- LogWrite logWriter = new LogWrite(ex.ToString());
- ViewBag.errorMessage = "Unable to complete the Issue. Please see Log file for more Information";
- return View("RequisitionItem", getRequisition);
- }
- ViewBag.error = "Sucessfull";
- return View("RequisitionItem", getRequisition);
- }
- <script type="text/javascript">
- function onFinishClick() {
- var rowCount = $('#myTable >tbody >tr').length;
- //window.alert(rowCount);
- if (rowCount === 1) {
- alert("Please add an item");
- }
- else {
- window.alert("You're item was successfully requested")
- window.location.replace("../Home/Index")
- }
- }
- </script>
- @using (Html.BeginForm())
- {
- @Html.AntiForgeryToken()
- <div class="form-horizontal">
- <h4>Request Item</h4>
- <hr />
- @Html.ValidationSummary(true, "", new { @class = "text-danger" })
- <div class="form-group">
- @Html.LabelFor(model => model.reqDate, htmlAttributes: new { @class = "col-md-2" })
- @Html.EditorFor(model => model.reqDate, new { htmlAttributes = new { @readonly = "readonly", @id = "reqDate", @class = "form-control" } })
- @Html.ValidationMessageFor(model => model.reqDate, "", new { @class = "text-danger" })
- </div>
- <div class="form-group">
- @Html.LabelFor(model => model.count, htmlAttributes: new { @class = "col-md-2" })
- <text> @Html.Encode(Model.items.Count()) </text>
- </div>
- <div class="form-group">
- @Html.LabelFor(model => model.reqNumber, htmlAttributes: new { @class = "col-md-2" })
- @Html.EditorFor(model => model.reqNumber, new { htmlAttributes = new { @readonly = "readonly", @id = "reqnum", @class = "form-control" } })
- @Html.ValidationMessageFor(model => model.reqNumber, "", new { @class = "text-danger" })
- </div>
- <div class="form-group">
- @Html.LabelFor(model => model.department, htmlAttributes: new { @class = "col-md-2" })
- @*@Html.EditorFor(model => model.department, new { htmlAttributes = new { @class = "form-control" } })*@
- @Html.DropDownListFor(model => model.department, new SelectList(Model.departmentsList, "Text", "Value"), new { @id = "department", @class = "form-control" })
- @Html.ValidationMessageFor(model => model.department, "", new { @class = "text-danger" })
- </div>
- <div class="form-group">
- @Html.LabelFor(model => model.employeeDetails, htmlAttributes: new { @class = "col-md-2" })
- @*@Html.Label("Requested by:", htmlAttributes: new { @class = "col-md-2" })*@
- @if (Model.department == null)
- {
- @Html.DropDownListFor(model => model.employeeDetails.employeeNum, new SelectList(string.Empty, "Value", "Text"), new { @id = "empname", @class = "form-control" })
- }
- else
- {
- @Html.DropDownListFor(model => model.employeeDetails.employeeNum, new SelectList(ViewBag.ReceivedByReps, "Value", "Text"), "select", new { @id = "empname", @class = "form-control" })
- }
- @*@Html.EditorFor(model => model.employeeName, new { htmlAttributes = new { @class = "form-control" } })*@
- @Html.ValidationMessageFor(model => model.employeeDetails.employeeNum, "", new { @class = "text-danger" })
- </div>
- @*@Html.DropDownListFor(model => model.employeeDetails.employeeNum, new SelectList((System.Collections.IEnumerable)TempData["company_dd3"], "Value", "Text"), "select", new { @class = "form-control" })*@
- @Html.HiddenFor(m => m.employeeDetails.firstName)
- @Html.HiddenFor(m => m.employeeDetails.lastName)
- @Html.HiddenFor(m => m.employeeDetails.Name)
- <fieldset class="form-group">
- <div class="form-horizontal">
- <h4>Enter Requested Item(s)</h4>
- <hr />
- <div class="Row form-group">
- <div class="col-md-5">
- @Html.LabelFor(model => model.item.itemNumber, htmlAttributes: new { @class = "col-md-3" })
- @Html.TextBoxFor(model => model.item.itemNumber, null, new { @readonly = "readonly", @id = "itemNumber", @class = "form-control" })
- @Html.ValidationMessageFor(model => model.item.itemNumber, "", new { @class = "text-danger" })
- </div>
- <div class="col-md-5">
- @Html.LabelFor(model => model.item.description, htmlAttributes: new { @class = "col-md-3" })
- @Html.TextBoxFor(model => model.item.description, null, new { @id = "description", @class = "form-control" })
- @*<font color="blue">Please use your keyboard arrow keys to select items</font>*@
- @* @Html.EditorFor(model => model.item.description, new { @class = "control-label col-md-2", @id = "txtItem" })*@
- @Html.ValidationMessageFor(model => model.item.description, "", new { @class = "text-danger" })
- <font color="red">@ViewBag.errorMessage</font>
- </div>
- </div>
- @Html.HiddenFor(m => m.item.lineNum)
- <div class="Row form-group">
- <div class="col-md-5">
- @Html.LabelFor(model => model.item.price, htmlAttributes: new { @class = "col-md-3" })
- @Html.TextBoxFor(model => model.item.price, new { @readonly = "readonly", @id = "price", @class = "form-control" })
- @Html.ValidationMessageFor(model => model.item.price, "", new { @class = "text-danger" })
- </div>
- <div class="col-md-5">
- @Html.LabelFor(model => model.item.expense_account, htmlAttributes: new { @class = "col-md-3" })
- @Html.DropDownListFor(model => model.item.expense_account.index, new SelectList(Model.accountlist, "Value", "Text"), new { @class = "form-control" })
- @Html.ValidationMessageFor(model => model.item.expense_account, "", new { @class = "text-danger" })
- </div>
- @Html.HiddenFor(model => model.item.selecteduomtext, new { @id = "selecteduomtext" })
- @Html.HiddenFor(model => model.item.lineNum)
- @Html.HiddenFor(model => model.items)
- <div class="col-md-5">
- @Html.LabelFor(model => model.item.quantity, htmlAttributes: new { @class = "col-md-3" })
- @Html.EditorFor(model => model.item.quantity, new { htmlAttributes = new { @class = "form-control" } })
- @Html.ValidationMessageFor(model => model.item.quantity, "", new { @class = "text-danger" })
- </div>
- @Html.HiddenFor(model => model.inventory_account, new { htmlAttributes = new { @class = "form-control" } })
- <div class="col-md-5">
- @Html.LabelFor(model => model.item.UofM, htmlAttributes: new { @class = "col-md-3" })
- @Html.DropDownListFor(model => model.item.UofM, new SelectList(string.Empty, "Text", "Value"), new { @id = "uofm", @class = "form-control" })
- @Html.ValidationMessageFor(model => model.item.UofM, "", new { @class = "text-danger" })
- </div>
- </div>
- <div class="form-group">
- <div class="col-md-offset-4 col-md-12">
- @*<input type="button" id="AddItems" value="Add" name="Submit" class="btn btn-default" />*@
- <button type="submit" class="btn btn-default" formaction="@Url.Action("AddItems")">Add</button>
-
- <input type="button" value="Cancel" name="Cancel" margin="50px" onclick="location.href='@Url.Action("Cancel", "Requisition")' " class="btn btn-default" />
- </div>
- </div>
- <div class="form-group">
- <table id="myTable">
- <tr>
- <th class="col-md-2">Item Number</th>
- <th class="col-md-2">Item Description</th>
- <th class="col-md-3">Expense Account</th>
- <th class="col-sm-1">Quantity</th>
- <th class="col-sm-1">UOM</th>
- <th class="col-sm-1">Item Price</th>
- <th></th>
- </tr>
- @{
- if (@Model.items.Count > 0)
- {
- foreach (var item in @Model.items)
- {
- <tr>
- <td class="col-md-3">@item.itemNumber</td>
- <td class="col-md-2">@item.description</td>
- <td class="col-md-3">@item.expense_account.getDescription</td>
- <td class="col-sm-1">@item.quantity.ToString()</td>
- <td class="col-sm-1">@item.selecteduomtext</td>
- <td class="col-sm-1">@item.price.ToString()</td>
- <td>
- @Html.ActionLink("Edit", "Edit", new { id = item.lineNum }) |
- @Html.ActionLink("Remove", "Remove", new { id = item.lineNum }, new { onclick = "return confirm('Are you sure you would like to remove this item?'); " })
- </td>
- </tr>
- }
- }
- }
- </table>
- </div>
- <div class="form-group">
- <div class="col-md-offset-4 col-md-12">
-
- @*<input type="button" value="Finish" name="Issue" margin="50px" onclick="location.href='/Requisition/ViewRequisition' " class="btn btn-default" />*@
- <button type="submit" class="btn btn-default" onclick="onFinishClick()" formaction="@Url.Action("RequestItem")">Request</button>
- @*<input type="button" id="ReceiptPrint" value="Print/Issue" name="Print/Issue" class="btn btn-default col-md-4" />*@
- </div>
- </div>
- </div>
Add Comment
Please, Sign In to add comment