Here I have am creating a small application. Where I have this HTML page where I enter the data. On clicking Submit button the data should get stored in the database through a stored procedure. I have written insert statement in stored procedure.
html code:
@model USTGlobal.WorkBench.UI.Models.FloorPlanViewModel
@{
ViewBag.Title = "RequestForm";
}
<div>
<div class="row">
<div class="col-lg-12">
<h2 class="page-header">Request Form</h2>
</div>
</div>
<div class="row">
<div class="col-lg-8">
<div class="form-horizontal">
<div class="form-group">
<label class="control-label col-lg-4">Period:</label>
<div class="col-lg-8">
@Html.DropDownList("Quarter", new SelectListItem[] { (new SelectListItem() { Text = "Q1", Value = "1"}), (new SelectListItem() { Text = "Q2", Value = "2" }), (new SelectListItem() { Text = "Q3", Value = "3" }), (new SelectListItem() { Text = "Q4", Value = "4"}) }, "-- Select Quarter --", new { @class = "form-control" })
<br />
@Html.DropDownList("Year", new SelectListItem[] { (new SelectListItem() { Text = "2016", Value = "2016" }), (new SelectListItem() { Text = "2017", Value = "2017" }) }, "-- Select Year --", new { @class = "form-control" })
</div>
</div>
</div>
<div class="form-horizontal">
<div class="form-group">
<label class="control-label col-lg-4">Line ID:</label>
<div class="col-lg-8">
@Html.TextBoxFor(model => model.floorConfig.LineID, new { onkeypress = "return isNumberKey(event)", @class = "form-control" })
</div>
</div>
</div>
<div class="form-horizontal">
<div class="form-group">
<label class="control-label col-lg-4">Project:</label>
<div class="col-lg-8">
@Html.TextBoxFor(model => model.floorConfig.Project, new { onkeypress = "return isNumberKey(event)", @class = "form-control" })
</div>
</div>
</div>
<div class="form-horizontal">
<div class="form-group">
<label class="control-label col-lg-4">Budget:</label>
<div class="col-lg-8">
@Html.TextBoxFor(model => model.floorConfig.Budget, new { onkeypress = "return isNumberKey(event)", @class = "form-control" })
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-offset-4" style="padding: 10px 0px 0px 0px;">
<input type="submit" id="btnSubmit" value="Submit" class="btn btn-lg btn-success" />
<input type="button" id="btnCancel" value="Clear" class="btn btn-lg btn-success" />
</div>
</div>
</div>
FloorPlanviewmodel: public FloorConfirguration floorConfig { get; set; }
Repository code:
public class FloorConfirguration
{
public string Quarter { get; set; }
public int Year { get; set; }
public string LineID { get; set; }
public string Project { get; set; }
public decimal Budget { get; set; }
}
How to move forward from here? Should I make the call to the stored procedure in controller?
SqlConnectionor ORM like EF)?