173 lines
5.9 KiB
C#
173 lines
5.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.Entity;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Web;
|
|
using System.Web.Mvc;
|
|
using StockManMVC.Models;
|
|
using X.PagedList;
|
|
|
|
namespace StockManMVC.Controllers
|
|
{
|
|
public class ItemStockStatusController : Controller
|
|
{
|
|
private StockManEntities db = new StockManEntities();
|
|
|
|
//// GET: ItemStockStatus
|
|
//public ActionResult Index()
|
|
//{
|
|
// return View(db.ItemStockStatus.ToList());
|
|
//}
|
|
|
|
// GET: ItemStockStatus
|
|
public ActionResult Index(string SearchVal)
|
|
{
|
|
var StockStatus = from s in db.ItemStockStatus
|
|
select s;
|
|
if (!String.IsNullOrEmpty(SearchVal))
|
|
{
|
|
StockStatus = StockStatus.Where(s => s.LocationID.Contains(SearchVal)
|
|
|| s.LocationDesc.Contains(SearchVal)
|
|
|| s.ItemFamilyID.Contains(SearchVal)
|
|
|| s.Descr.Contains(SearchVal)
|
|
|| s.DescrExt.Contains(SearchVal)
|
|
|| s.CodInt.Contains(SearchVal)
|
|
|| s.CodExt.Contains(SearchVal)
|
|
);
|
|
}
|
|
|
|
return View(StockStatus.ToList());
|
|
//return View(db.ItemStockStatus.ToList());
|
|
}
|
|
|
|
// GET: ItemStockStatus/Consolidate/5
|
|
public ActionResult Consolidate(int? id)
|
|
{
|
|
if (id == null)
|
|
{
|
|
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
|
|
}
|
|
// chiamo stored x consolidamento flussi (da movimenti a giacenza confermata)
|
|
using (var ctx = new StockManEntities())
|
|
{
|
|
//Execute stored procedure as a function
|
|
int rowMod = ctx.stp_consolidateItem(id);
|
|
}
|
|
//// restituisco riga post update...
|
|
//ItemStockStatus itemStockStatus = db.ItemStockStatus.Find(id);
|
|
//if (itemStockStatus == null)
|
|
//{
|
|
// return HttpNotFound();
|
|
//}
|
|
//return View(itemStockStatus);
|
|
return View(db.ItemStockStatus.ToList());
|
|
}
|
|
|
|
// GET: ItemStockStatus/Details/5
|
|
public ActionResult Details(int? id)
|
|
{
|
|
if (id == null)
|
|
{
|
|
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
|
|
}
|
|
ItemStockStatus itemStockStatus = db.ItemStockStatus.Find(id);
|
|
if (itemStockStatus == null)
|
|
{
|
|
return HttpNotFound();
|
|
}
|
|
return View(itemStockStatus);
|
|
}
|
|
|
|
// GET: ItemStockStatus/Create
|
|
public ActionResult Create()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
// POST: ItemStockStatus/Create
|
|
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
|
|
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
|
|
[HttpPost]
|
|
[ValidateAntiForgeryToken]
|
|
public ActionResult Create([Bind(Include = "ID,LocationID,LocationDesc,ItemID,Descr,CodInt,ItemFamilyID,CodExt,DescrExt,QtaMin,QtaBatch,QtyConf,ValConf,QtaPend,ValPend,QtaNew,ValNew")] ItemStockStatus itemStockStatus)
|
|
{
|
|
if (ModelState.IsValid)
|
|
{
|
|
db.ItemStockStatus.Add(itemStockStatus);
|
|
db.SaveChanges();
|
|
return RedirectToAction("Index");
|
|
}
|
|
|
|
return View(itemStockStatus);
|
|
}
|
|
|
|
// GET: ItemStockStatus/Edit/5
|
|
public ActionResult Edit(int? id)
|
|
{
|
|
if (id == null)
|
|
{
|
|
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
|
|
}
|
|
ItemStockStatus itemStockStatus = db.ItemStockStatus.Find(id);
|
|
if (itemStockStatus == null)
|
|
{
|
|
return HttpNotFound();
|
|
}
|
|
return View(itemStockStatus);
|
|
}
|
|
|
|
// POST: ItemStockStatus/Edit/5
|
|
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
|
|
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
|
|
[HttpPost]
|
|
[ValidateAntiForgeryToken]
|
|
public ActionResult Edit([Bind(Include = "ID,LocationID,LocationDesc,ItemID,Descr,CodInt,ItemFamilyID,CodExt,DescrExt,QtaMin,QtaBatch,QtyConf,ValConf,QtaPend,ValPend,QtaNew,ValNew")] ItemStockStatus itemStockStatus)
|
|
{
|
|
if (ModelState.IsValid)
|
|
{
|
|
db.Entry(itemStockStatus).State = EntityState.Modified;
|
|
db.SaveChanges();
|
|
return RedirectToAction("Index");
|
|
}
|
|
return View(itemStockStatus);
|
|
}
|
|
|
|
// GET: ItemStockStatus/Delete/5
|
|
public ActionResult Delete(int? id)
|
|
{
|
|
if (id == null)
|
|
{
|
|
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
|
|
}
|
|
ItemStockStatus itemStockStatus = db.ItemStockStatus.Find(id);
|
|
if (itemStockStatus == null)
|
|
{
|
|
return HttpNotFound();
|
|
}
|
|
return View(itemStockStatus);
|
|
}
|
|
|
|
// POST: ItemStockStatus/Delete/5
|
|
[HttpPost, ActionName("Delete")]
|
|
[ValidateAntiForgeryToken]
|
|
public ActionResult DeleteConfirmed(int id)
|
|
{
|
|
ItemStockStatus itemStockStatus = db.ItemStockStatus.Find(id);
|
|
db.ItemStockStatus.Remove(itemStockStatus);
|
|
db.SaveChanges();
|
|
return RedirectToAction("Index");
|
|
}
|
|
|
|
protected override void Dispose(bool disposing)
|
|
{
|
|
if (disposing)
|
|
{
|
|
db.Dispose();
|
|
}
|
|
base.Dispose(disposing);
|
|
}
|
|
}
|
|
}
|