Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @{
- ViewBag.Title = "Index";
- }
- <ul class="nav nav-tabs">
- <li class="active"><a data-toggle="tab" href="#firstTab">View All
- Vendors</a></li>
- <li><a data-toggle="tab" href="#secondTab">Add New</a></li>
- <li><a data-toggle="tab" href="#thirdTab">Remove</a></li>
- </ul>
- <div class="tab-content">
- <div id="firstTab" class="tab-pane fade in active">@Html.Action("ViewAll")</div>
- <div id="secondTab" class="tab-pane fade in">@Html.Action("AddOrEdit")</div>
- <div id="thirdTab" class="tab-pane fade in">tab 3 content</div>
- </div>
- @section scripts
- {
- @Scripts.Render("~/bundles/jqueryval")
- }
- @model VendorApp.Models.VENDOR
- @{
- ViewBag.Title = "AddOrEdit";
- }
- @using (Html.BeginForm("AddOrEdit","Vendor",FormMethod.Post, new { enctype = "multipart/form-data", onSubmit = "return jQueryAjaxPost(this);" }))
- {
- @Html.AntiForgeryToken()
- <div class="row">
- <div class="form-horizontal">
- <h4>Add Vendor</h4>
- @Html.ValidationSummary(true, "", new { @class = "text-danger" })
- @Html.HiddenFor(model => model.VENDOR_NUM)
- <div class="col-md-6">
- <div class="form-group">
- @Html.LabelFor(model => model.VENDOR_NAME, htmlAttributes: new { @class = "control-label col-md-2" })
- <div class="col-md-10">
- @Html.EditorFor(model => model.VENDOR_NAME, new { htmlAttributes = new { @class = "form-control" } })
- @Html.ValidationMessageFor(model => model.VENDOR_NAME, "", new { @class = "text-danger" })
- </div>
- </div>
- <div class="form-group">
- @Html.LabelFor(model => model.STREET, htmlAttributes: new { @class = "control-label col-md-2" })
- <div class="col-md-10">
- @Html.EditorFor(model => model.STREET, new { htmlAttributes = new { @class = "form-control" } })
- @Html.ValidationMessageFor(model => model.STREET, "", new { @class = "text-danger" })
- </div>
- </div>
- <div class="form-group">
- @Html.LabelFor(model => model.CITY, htmlAttributes: new { @class = "control-label col-md-2" })
- <div class="col-md-10">
- @Html.EditorFor(model => model.CITY, new { htmlAttributes = new { @class = "form-control" } })
- @Html.ValidationMessageFor(model => model.CITY, "", new { @class = "text-danger" })
- </div>
- </div>
- <div class="form-group">
- @Html.LabelFor(model => model.STATE, htmlAttributes: new { @class = "control-label col-md-2" })
- <div class="col-md-10">
- @Html.EditorFor(model => model.STATE, new { htmlAttributes = new { @class = "form-control" } })
- @Html.ValidationMessageFor(model => model.STATE, "", new { @class = "text-danger" })
- </div>
- </div>
- <div class="form-group">
- <div class="col-md-offset-2 col-md-10">
- <input type="submit" value="Update" class="btn btn-default" />
- </div>
- </div>
- </div>
- <div class="col-md-6">
- <div class="form-group">
- @Html.LabelFor(model => model.ZIP, htmlAttributes: new { @class = "control-label col-md-2" })
- <div class="col-md-10">
- @Html.EditorFor(model => model.ZIP, new { htmlAttributes = new { @class = "form-control" } })
- @Html.ValidationMessageFor(model => model.ZIP, "", new { @class = "text-danger" })
- </div>
- </div>
- <div class="form-group">
- @Html.LabelFor(model => model.PHONE, htmlAttributes: new { @class = "control-label col-md-2" })
- <div class="col-md-10">
- @Html.EditorFor(model => model.PHONE, new { htmlAttributes = new { @class = "form-control" } })
- @Html.ValidationMessageFor(model => model.PHONE, "", new { @class = "text-danger" })
- </div>
- </div>
- <div class="form-group">
- @Html.LabelFor(model => model.EMAIL, htmlAttributes: new { @class = "control-label col-md-2" })
- <div class="col-md-10">
- @Html.EditorFor(model => model.EMAIL, new { htmlAttributes = new { @class = "form-control" } })
- @Html.ValidationMessageFor(model => model.EMAIL, "", new { @class = "text-danger" })
- </div>
- </div>
- <div class="form-group">
- @Html.LabelFor(model => model.SERVICE, htmlAttributes: new { @class = "control-label col-md-2" })
- <div class="col-md-10">
- @Html.EditorFor(model => model.SERVICE, new { htmlAttributes = new { @class = "form-control" } })
- @Html.ValidationMessageFor(model => model.SERVICE, "", new { @class = "text-danger" })
- </div>
- </div>
- <div class="form-group">
- @Html.LabelFor(model => model.NOTE, htmlAttributes: new { @class = "control-label col-md-2" })
- <div class="col-md-10">
- @Html.EditorFor(model => model.NOTE, new { htmlAttributes = new { @class = "form-control" } })
- @Html.ValidationMessageFor(model => model.NOTE, "", new { @class = "text-danger" })
- </div>
- </div>
- </div>
- </div>
- </div>
- }
- using System;
- using System.Collections.Generic;
- using System.Data.Entity.Infrastructure;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using VendorApp.Models;
- namespace VendorApp.Controllers
- {
- public class VendorController : Controller
- {
- // GET: Vendor
- public ActionResult Index()
- {
- return View();
- }
- //get all Vendors
- public ActionResult ViewAll()
- {
- return View(GetAllVendor());
- }
- //numerate the vendors
- IEnumerable<VENDOR>GetAllVendor()
- {
- using (Pref_VendorEntities db = new Pref_VendorEntities())
- {
- return db.VENDORs.ToList<VENDOR>();
- }
- }
- /// <summary>
- /// HTTP GET by DEFAULT
- /// </summary>
- /// <returns></returns>
- public ActionResult AddOrEdit()
- {
- VENDOR vendor = new VENDOR();
- return View(vendor);
- }
- /// <summary>
- /// HTTP Post
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public ActionResult AddOrEdit(VENDOR vend)
- {
- using (Pref_VendorEntities db = new Pref_VendorEntities())
- {
- db.VENDORs.Add(vend);
- db.SaveChanges();
- }
- return RedirectToAction("ViewAll");
- }
- }
- }
Add Comment
Please, Sign In to add comment