Thursday, February 1, 2018

Razor

@model Ism.ShoppingCart.Domain.ItemListViewModel

@{
    ViewBag.Title = "Index";
}

<h2>Items</h2>
<br />
@using (Html.BeginForm())
{
<div class="form-horizontal">
    <h4>Item</h4>
    <hr />
    @Html.ValidationSummary(true, "", new { @class = "text-danger" })
    <div class="form-group">
        @Html.Label("CategoryID", htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-4">
            @Html.DropDownList("CategoryID", null, htmlAttributes: new { @class = "form-control" })
        </div>
        <div class="col-md-4">
            <input type="submit" id="btnsearch" value="Search" class="btn btn-default" />
        </div>
    </div>
</div>
}
<table class="table">
    <tr>
        <th>
            @Html.DisplayNameFor(model => model.ItemModel[0].ItemName)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.ItemModel[0].Price)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.ItemModel[0].Qty)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.ItemModel[0].CategoryID)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.ItemModel[0].Active)
        </th>
        <th></th>
    </tr>

@foreach (var item in Model.ItemModel) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.ItemName)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Price)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Qty)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.CategoryID)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Active)
        </td>
        <td>
            @Html.ActionLink("AddtoCart", "AddtoCart", "Cart", new { id=item.ID },null)
        </td>
    </tr>
}

</table>



@model Ism.ShoppingCart.Domain.ItemModel

@{
    ViewBag.Title = "Edit";
}

<h2>Add to Cart</h2>


@using (Html.BeginForm("AddtoCart","Cart"))
{
    @Html.AntiForgeryToken()

    <div class="form-horizontal">
        <h4></h4>
        <hr />
        @Html.ValidationSummary(true, "", new { @class = "text-danger" })
        @Html.HiddenFor(model => model.ID)

        <div class="form-group">
            @Html.LabelFor(model => model.ItemName, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.ItemName, new { htmlAttributes = new { @class = "form-control", @readonly = "readonly" } })
                @Html.ValidationMessageFor(model => model.ItemName, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Price, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Price, new { htmlAttributes = new { @class = "form-control", @readonly = "readonly" } })
                @Html.ValidationMessageFor(model => model.Price, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Qty, htmlAttributes: new { @class = "control-label col-md-2"})
            <div class="col-md-10">
                @Html.EditorFor(model => model.Qty, new { htmlAttributes = new { @class = "form-control", @readonly = "readonly" } })
                @Html.ValidationMessageFor(model => model.Qty, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.OrderQty, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.OrderQty, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.OrderQty, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            <div class="col-md-offset-2 col-md-10">
                <input type="submit" value="Save" class="btn btn-default" />
            </div>
        </div>
    </div>
}

<div>
    @Html.ActionLink("Back to Item List", "Index", "Item", null, new { @class = "btn btn-success" })
</div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}


@model IEnumerable<Ism.ShoppingCart.Domain.CartViewModel>

@{
    ViewBag.Title = "Index";
}

<h2>My Cart Items</h2>
<br />
<table class="table">
    <tr>
        <th>
            @Html.DisplayNameFor(model => model.ItemID)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.ItemName)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Qty)
        </th>
        <th></th>
    </tr>

@foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.ItemID)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.ItemName)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Qty)
        </td>
        <td>
            @Html.ActionLink("Delete", "Delete", new { id=item.ID },new { onclick="return confirm('Are you sure you want to delete this?');"})
        </td>
    </tr>
}
    <tfoot>
        <tr>
            <td>Total Value : </td>
            <td>@ViewBag.Total</td>
        </tr>
    </tfoot>
</table>

<div class="row">
    <div class="col-sm-2">
        @Html.ActionLink("Continue Shopping", "Index", "Item", null, new { @class = "btn btn-success" })
        </div>
        <div class="col-sm-2">
            @using (Html.BeginForm("CancelOrder", "Cart", FormMethod.Post))
            { @Html.AntiForgeryToken()  <input type="submit" value="Cancel Order" class="btn btn-danger" />
            }
            <br />
        </div>
        <div class="col-sm-2">
            @using (Html.BeginForm("ConfirmOrder", "Cart", FormMethod.Post))
            {
                @Html.AntiForgeryToken()
                <input type="submit" value="Confirm Order" class="btn btn-success" />
            }
        </div>
    </div>


    @if (ViewBag.Message != null)
    {
        <script>
        window.onload = function() {
            alert("@ViewBag.Message");
        };
        </script>
    }

No comments:

Post a Comment

BulkInsert

public void InsertCaller()         {             DataSet ds = new DataSet();             ds.ReadXml("D:\\Sample\\Items");     ...