Hier habe ich eine kleine Anwendung erstellen. Wo ich diese HTML-Seite habe, wo ich die Daten eintrage. Wenn Sie auf die Schaltfläche Senden klicken, sollten die Daten in der Datenbank über eine gespeicherte Prozedur gespeichert werden. Ich habe Insert-Anweisung in gespeicherte Prozedur geschrieben.Speichern eingegebener Daten in SqlServer nach dem Senden
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; }
}
Wie uns darauf, von hier bewegen? Soll ich die gespeicherte Prozedur in controller
aufrufen?
Welche Art von gespeicherter Prozedur haben Sie und welche Methode möchten Sie sie nennen (durch grundlegende 'SqlConnection' oder ORM wie EF)? –