Guest User

Untitled

a guest
Nov 11th, 2017
370
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.02 KB | None | 0 0
  1. public ActionResult RequestItem(Requisition requisition)
  2. {
  3.  
  4. IssueDAO dbdata = new IssueDAO();
  5. dbdata.connectionString = ConfigurationManager.ConnectionStrings["TWCL_OPERATIONSConnectionString"].ConnectionString;
  6. getRequisition.reqDate = DateTime.Now; //Sets the transaction date to current date
  7. getRequisition.status = -1;
  8. ViewBag.ReceivedbyReps = dbdata.SelectEmployeesByDept(requisition.department);
  9.  
  10. Item item = new Item();
  11. try
  12. {
  13. dbdata.createRequisition(getRequisition, item);//Creates the issue in the database
  14. }
  15. catch (Exception ex)
  16. {
  17. LogWrite logWriter = new LogWrite(ex.ToString());
  18. ViewBag.errorMessage = "Unable to complete the Issue. Please see Log file for more Information";
  19. return View("RequisitionItem", getRequisition);
  20.  
  21.  
  22. }
  23. ViewBag.error = "Sucessfull";
  24. return View("RequisitionItem", getRequisition);
  25.  
  26.  
  27. }
  28.  
  29. <script type="text/javascript">
  30.  
  31.  
  32.  
  33.  
  34. function onFinishClick() {
  35. var rowCount = $('#myTable >tbody >tr').length;
  36. //window.alert(rowCount);
  37. if (rowCount === 1) {
  38. alert("Please add an item");
  39. }
  40.  
  41.  
  42. else {
  43. window.alert("You're item was successfully requested")
  44. window.location.replace("../Home/Index")
  45. }
  46. }
  47.  
  48. </script>
  49.  
  50. @using (Html.BeginForm())
  51. {
  52. @Html.AntiForgeryToken()
  53.  
  54. <div class="form-horizontal">
  55. <h4>Request Item</h4>
  56. <hr />
  57. @Html.ValidationSummary(true, "", new { @class = "text-danger" })
  58.  
  59. <div class="form-group">
  60. @Html.LabelFor(model => model.reqDate, htmlAttributes: new { @class = "col-md-2" })
  61.  
  62. @Html.EditorFor(model => model.reqDate, new { htmlAttributes = new { @readonly = "readonly", @id = "reqDate", @class = "form-control" } })
  63. @Html.ValidationMessageFor(model => model.reqDate, "", new { @class = "text-danger" })
  64.  
  65. </div>
  66.  
  67.  
  68. <div class="form-group">
  69. @Html.LabelFor(model => model.count, htmlAttributes: new { @class = "col-md-2" })
  70. <text> @Html.Encode(Model.items.Count()) </text>
  71. </div>
  72.  
  73.  
  74. <div class="form-group">
  75. @Html.LabelFor(model => model.reqNumber, htmlAttributes: new { @class = "col-md-2" })
  76.  
  77. @Html.EditorFor(model => model.reqNumber, new { htmlAttributes = new { @readonly = "readonly", @id = "reqnum", @class = "form-control" } })
  78. @Html.ValidationMessageFor(model => model.reqNumber, "", new { @class = "text-danger" })
  79.  
  80. </div>
  81.  
  82. <div class="form-group">
  83. @Html.LabelFor(model => model.department, htmlAttributes: new { @class = "col-md-2" })
  84.  
  85. @*@Html.EditorFor(model => model.department, new { htmlAttributes = new { @class = "form-control" } })*@
  86. @Html.DropDownListFor(model => model.department, new SelectList(Model.departmentsList, "Text", "Value"), new { @id = "department", @class = "form-control" })
  87. @Html.ValidationMessageFor(model => model.department, "", new { @class = "text-danger" })
  88.  
  89. </div>
  90.  
  91.  
  92. <div class="form-group">
  93. @Html.LabelFor(model => model.employeeDetails, htmlAttributes: new { @class = "col-md-2" })
  94. @*@Html.Label("Requested by:", htmlAttributes: new { @class = "col-md-2" })*@
  95. @if (Model.department == null)
  96. {
  97. @Html.DropDownListFor(model => model.employeeDetails.employeeNum, new SelectList(string.Empty, "Value", "Text"), new { @id = "empname", @class = "form-control" })
  98. }
  99. else
  100. {
  101. @Html.DropDownListFor(model => model.employeeDetails.employeeNum, new SelectList(ViewBag.ReceivedByReps, "Value", "Text"), "select", new { @id = "empname", @class = "form-control" })
  102. }
  103.  
  104. @*@Html.EditorFor(model => model.employeeName, new { htmlAttributes = new { @class = "form-control" } })*@
  105. @Html.ValidationMessageFor(model => model.employeeDetails.employeeNum, "", new { @class = "text-danger" })
  106.  
  107.  
  108. </div>
  109.  
  110.  
  111. @*@Html.DropDownListFor(model => model.employeeDetails.employeeNum, new SelectList((System.Collections.IEnumerable)TempData["company_dd3"], "Value", "Text"), "select", new { @class = "form-control" })*@
  112.  
  113. @Html.HiddenFor(m => m.employeeDetails.firstName)
  114. @Html.HiddenFor(m => m.employeeDetails.lastName)
  115. @Html.HiddenFor(m => m.employeeDetails.Name)
  116.  
  117.  
  118.  
  119.  
  120. <fieldset class="form-group">
  121. <div class="form-horizontal">
  122. <h4>Enter Requested Item(s)</h4>
  123.  
  124. <hr />
  125.  
  126. <div class="Row form-group">
  127. <div class="col-md-5">
  128. @Html.LabelFor(model => model.item.itemNumber, htmlAttributes: new { @class = "col-md-3" })
  129. @Html.TextBoxFor(model => model.item.itemNumber, null, new { @readonly = "readonly", @id = "itemNumber", @class = "form-control" })
  130. @Html.ValidationMessageFor(model => model.item.itemNumber, "", new { @class = "text-danger" })
  131. </div>
  132.  
  133. <div class="col-md-5">
  134. @Html.LabelFor(model => model.item.description, htmlAttributes: new { @class = "col-md-3" })
  135. @Html.TextBoxFor(model => model.item.description, null, new { @id = "description", @class = "form-control" })
  136. @*<font color="blue">Please use your keyboard arrow keys to select items</font>*@
  137. @* @Html.EditorFor(model => model.item.description, new { @class = "control-label col-md-2", @id = "txtItem" })*@
  138. @Html.ValidationMessageFor(model => model.item.description, "", new { @class = "text-danger" })
  139. <font color="red">@ViewBag.errorMessage</font>
  140. </div>
  141. </div>
  142.  
  143. @Html.HiddenFor(m => m.item.lineNum)
  144.  
  145.  
  146.  
  147.  
  148. <div class="Row form-group">
  149. <div class="col-md-5">
  150. @Html.LabelFor(model => model.item.price, htmlAttributes: new { @class = "col-md-3" })
  151. @Html.TextBoxFor(model => model.item.price, new { @readonly = "readonly", @id = "price", @class = "form-control" })
  152. @Html.ValidationMessageFor(model => model.item.price, "", new { @class = "text-danger" })
  153. </div>
  154.  
  155. <div class="col-md-5">
  156. @Html.LabelFor(model => model.item.expense_account, htmlAttributes: new { @class = "col-md-3" })
  157. @Html.DropDownListFor(model => model.item.expense_account.index, new SelectList(Model.accountlist, "Value", "Text"), new { @class = "form-control" })
  158. @Html.ValidationMessageFor(model => model.item.expense_account, "", new { @class = "text-danger" })
  159.  
  160. </div>
  161.  
  162.  
  163. @Html.HiddenFor(model => model.item.selecteduomtext, new { @id = "selecteduomtext" })
  164. @Html.HiddenFor(model => model.item.lineNum)
  165. @Html.HiddenFor(model => model.items)
  166.  
  167.  
  168. <div class="col-md-5">
  169. @Html.LabelFor(model => model.item.quantity, htmlAttributes: new { @class = "col-md-3" })
  170. @Html.EditorFor(model => model.item.quantity, new { htmlAttributes = new { @class = "form-control" } })
  171. @Html.ValidationMessageFor(model => model.item.quantity, "", new { @class = "text-danger" })
  172. </div>
  173.  
  174. @Html.HiddenFor(model => model.inventory_account, new { htmlAttributes = new { @class = "form-control" } })
  175.  
  176. <div class="col-md-5">
  177. @Html.LabelFor(model => model.item.UofM, htmlAttributes: new { @class = "col-md-3" })
  178. @Html.DropDownListFor(model => model.item.UofM, new SelectList(string.Empty, "Text", "Value"), new { @id = "uofm", @class = "form-control" })
  179. @Html.ValidationMessageFor(model => model.item.UofM, "", new { @class = "text-danger" })
  180. </div>
  181.  
  182.  
  183.  
  184. </div>
  185.  
  186.  
  187. <div class="form-group">
  188. <div class="col-md-offset-4 col-md-12">
  189.  
  190. @*<input type="button" id="AddItems" value="Add" name="Submit" class="btn btn-default" />*@
  191. <button type="submit" class="btn btn-default" formaction="@Url.Action("AddItems")">Add</button>
  192. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  193.  
  194. <input type="button" value="Cancel" name="Cancel" margin="50px" onclick="location.href='@Url.Action("Cancel", "Requisition")' " class="btn btn-default" />
  195.  
  196.  
  197. </div>
  198. </div>
  199.  
  200.  
  201. <div class="form-group">
  202. <table id="myTable">
  203. <tr>
  204. <th class="col-md-2">Item Number</th>
  205. <th class="col-md-2">Item Description</th>
  206. <th class="col-md-3">Expense Account</th>
  207. <th class="col-sm-1">Quantity</th>
  208. <th class="col-sm-1">UOM</th>
  209. <th class="col-sm-1">Item Price</th>
  210.  
  211.  
  212. <th></th>
  213. </tr>
  214. @{
  215.  
  216. if (@Model.items.Count > 0)
  217. {
  218. foreach (var item in @Model.items)
  219. {
  220. <tr>
  221. <td class="col-md-3">@item.itemNumber</td>
  222. <td class="col-md-2">@item.description</td>
  223. <td class="col-md-3">@item.expense_account.getDescription</td>
  224. <td class="col-sm-1">@item.quantity.ToString()</td>
  225. <td class="col-sm-1">@item.selecteduomtext</td>
  226. <td class="col-sm-1">@item.price.ToString()</td>
  227.  
  228.  
  229.  
  230. <td>
  231. @Html.ActionLink("Edit", "Edit", new { id = item.lineNum }) |
  232. @Html.ActionLink("Remove", "Remove", new { id = item.lineNum }, new { onclick = "return confirm('Are you sure you would like to remove this item?'); " })
  233. </td>
  234.  
  235. </tr>
  236.  
  237.  
  238. }
  239.  
  240. }
  241. }
  242.  
  243.  
  244. </table>
  245.  
  246.  
  247. </div>
  248.  
  249.  
  250.  
  251. <div class="form-group">
  252. <div class="col-md-offset-4 col-md-12">
  253.  
  254.  
  255. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  256. @*<input type="button" value="Finish" name="Issue" margin="50px" onclick="location.href='/Requisition/ViewRequisition' " class="btn btn-default" />*@
  257. <button type="submit" class="btn btn-default" onclick="onFinishClick()" formaction="@Url.Action("RequestItem")">Request</button>
  258.  
  259. @*<input type="button" id="ReceiptPrint" value="Print/Issue" name="Print/Issue" class="btn btn-default col-md-4" />*@
  260.  
  261. </div>
  262. </div>
  263. </div>
Add Comment
Please, Sign In to add comment