diff --git a/StockManMVC/Controllers/MagStatusController.cs b/StockManMVC/Controllers/MagStatusController.cs index f899139..d4e18f4 100644 --- a/StockManMVC/Controllers/MagStatusController.cs +++ b/StockManMVC/Controllers/MagStatusController.cs @@ -52,37 +52,16 @@ namespace StockManMVC.Controllers // GET: MagStatus/MoveConfirm public ActionResult MoveConfirm(int ID, string LocationID, string LocationIDTo) { - var CurrStock = db.ItemStock - .Where(s => s.ID == ID) - .Include(v => v.Location) - .Include(s => s.Item); - + ItemStock itemStock = db.ItemStock.Find(ID); ViewBag.LocationID = LocationID; ViewBag.LocationIDTo = LocationIDTo; - return PartialView("_confirmMove", CurrStock.ToList()); + return PartialView("_confirmMove", itemStock); } - - - // GET: MagStatus/StockByLocationAjax - [HttpGet] - public ActionResult StockByLocationAjax(string LocationID, string LocationIDTo, bool? ShowMove) - { - var CurrStock = db.ItemStock - .Where(s => s.QtyConf > 0 && s.LocationID == LocationID) - .Include(v => v.Location) - .Include(s => s.Item); - - if (ShowMove == null) ShowMove = false; - - ViewBag.LocationID = LocationID; - ViewBag.LocationIDTo = LocationIDTo; - ViewBag.ShowMove = ShowMove; - return PartialView("_StockByLocation", CurrStock.ToList()); - } - - public ActionResult Move(int ID, string LocationID, string LocationIDTo, int QtyConf) + [HttpPost] + [ValidateAntiForgeryToken] + public ActionResult MoveConfirm(int ID, string LocationID, string LocationIDTo, [Bind(Include = "QtyConf")] ItemStock itemSt) { // recupero operatore... IEnumerable listOper = OperatorsController.Select(User.Identity.Name); @@ -93,10 +72,22 @@ namespace StockManMVC.Controllers } // chiamo la stored x il move + int rowMod = 0; using (var ctx = new StockManEntities()) { - // esegue stored procedure come function, SE id == 0 processa TUTTI... - int rowMod = ctx.stp_ItemStockMove(ID, LocationID, LocationIDTo, currOperID); + // recupero itemStock riferimento + ItemStock itmStock = ctx.ItemStock.Find(ID); + // se ho quantità != completa --> uso altra stored... + if (itemSt.QtyConf != itmStock.QtyConf) + { + // esegue stored procedure come function che cambia e sposta qta paziali + rowMod = ctx.stp_ItemStockMove_New(ID, LocationID, LocationIDTo, currOperID, itemSt.QtyConf); + } + else + { + // esegue stored procedure come function, sposta TUTTO + rowMod = ctx.stp_ItemStockMove(ID, LocationID, LocationIDTo, currOperID); + } } // appoggio variabili diff --git a/StockManMVC/Models/Item.cs b/StockManMVC/Models/Item.cs index ff9ad3a..dd5f2a3 100644 --- a/StockManMVC/Models/Item.cs +++ b/StockManMVC/Models/Item.cs @@ -1,9 +1,9 @@ //------------------------------------------------------------------------------ // -// Codice generato da un modello. +// This code was generated from a template. // -// Le modifiche manuali a questo file potrebbero causare un comportamento imprevisto dell'applicazione. -// Se il codice viene rigenerato, le modifiche manuali al file verranno sovrascritte. +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. // //------------------------------------------------------------------------------ diff --git a/StockManMVC/Models/ItemFamily.cs b/StockManMVC/Models/ItemFamily.cs index 9d7a97c..0eab266 100644 --- a/StockManMVC/Models/ItemFamily.cs +++ b/StockManMVC/Models/ItemFamily.cs @@ -1,9 +1,9 @@ //------------------------------------------------------------------------------ // -// Codice generato da un modello. +// This code was generated from a template. // -// Le modifiche manuali a questo file potrebbero causare un comportamento imprevisto dell'applicazione. -// Se il codice viene rigenerato, le modifiche manuali al file verranno sovrascritte. +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. // //------------------------------------------------------------------------------ diff --git a/StockManMVC/Models/ItemFlux.cs b/StockManMVC/Models/ItemFlux.cs index 41b0451..c7833d5 100644 --- a/StockManMVC/Models/ItemFlux.cs +++ b/StockManMVC/Models/ItemFlux.cs @@ -1,9 +1,9 @@ //------------------------------------------------------------------------------ // -// Codice generato da un modello. +// This code was generated from a template. // -// Le modifiche manuali a questo file potrebbero causare un comportamento imprevisto dell'applicazione. -// Se il codice viene rigenerato, le modifiche manuali al file verranno sovrascritte. +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. // //------------------------------------------------------------------------------ diff --git a/StockManMVC/Models/ItemStock.cs b/StockManMVC/Models/ItemStock.cs index 3fc7222..086c56e 100644 --- a/StockManMVC/Models/ItemStock.cs +++ b/StockManMVC/Models/ItemStock.cs @@ -1,9 +1,9 @@ //------------------------------------------------------------------------------ // -// Codice generato da un modello. +// This code was generated from a template. // -// Le modifiche manuali a questo file potrebbero causare un comportamento imprevisto dell'applicazione. -// Se il codice viene rigenerato, le modifiche manuali al file verranno sovrascritte. +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. // //------------------------------------------------------------------------------ diff --git a/StockManMVC/Models/LocType.cs b/StockManMVC/Models/LocType.cs index 52c076e..e2c13d7 100644 --- a/StockManMVC/Models/LocType.cs +++ b/StockManMVC/Models/LocType.cs @@ -1,9 +1,9 @@ //------------------------------------------------------------------------------ // -// Codice generato da un modello. +// This code was generated from a template. // -// Le modifiche manuali a questo file potrebbero causare un comportamento imprevisto dell'applicazione. -// Se il codice viene rigenerato, le modifiche manuali al file verranno sovrascritte. +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. // //------------------------------------------------------------------------------ diff --git a/StockManMVC/Models/Location.cs b/StockManMVC/Models/Location.cs index e8788ec..66f29d9 100644 --- a/StockManMVC/Models/Location.cs +++ b/StockManMVC/Models/Location.cs @@ -1,9 +1,9 @@ //------------------------------------------------------------------------------ // -// Codice generato da un modello. +// This code was generated from a template. // -// Le modifiche manuali a questo file potrebbero causare un comportamento imprevisto dell'applicazione. -// Se il codice viene rigenerato, le modifiche manuali al file verranno sovrascritte. +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. // //------------------------------------------------------------------------------ diff --git a/StockManMVC/Models/MovType.cs b/StockManMVC/Models/MovType.cs index c7d2b08..47f4e71 100644 --- a/StockManMVC/Models/MovType.cs +++ b/StockManMVC/Models/MovType.cs @@ -1,9 +1,9 @@ //------------------------------------------------------------------------------ // -// Codice generato da un modello. +// This code was generated from a template. // -// Le modifiche manuali a questo file potrebbero causare un comportamento imprevisto dell'applicazione. -// Se il codice viene rigenerato, le modifiche manuali al file verranno sovrascritte. +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. // //------------------------------------------------------------------------------ diff --git a/StockManMVC/Models/Operator.cs b/StockManMVC/Models/Operator.cs index 228454e..89bafd0 100644 --- a/StockManMVC/Models/Operator.cs +++ b/StockManMVC/Models/Operator.cs @@ -1,9 +1,9 @@ //------------------------------------------------------------------------------ // -// Codice generato da un modello. +// This code was generated from a template. // -// Le modifiche manuali a questo file potrebbero causare un comportamento imprevisto dell'applicazione. -// Se il codice viene rigenerato, le modifiche manuali al file verranno sovrascritte. +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. // //------------------------------------------------------------------------------ diff --git a/StockManMVC/Models/SMModel.Context.cs b/StockManMVC/Models/SMModel.Context.cs index 4fb87bc..171c762 100644 --- a/StockManMVC/Models/SMModel.Context.cs +++ b/StockManMVC/Models/SMModel.Context.cs @@ -1,9 +1,9 @@ //------------------------------------------------------------------------------ // -// Codice generato da un modello. +// This code was generated from a template. // -// Le modifiche manuali a questo file potrebbero causare un comportamento imprevisto dell'applicazione. -// Se il codice viene rigenerato, le modifiche manuali al file verranno sovrascritte. +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. // //------------------------------------------------------------------------------ @@ -85,5 +85,30 @@ namespace StockManMVC.Models return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("stp_ItemStockMove", stockIDParameter, locationID_FROMParameter, locationID_TOParameter, operatorIDParameter); } + + public virtual int stp_ItemStockMove_New(Nullable stockID, string locationID_FROM, string locationID_TO, string operatorID, Nullable qtyMov) + { + var stockIDParameter = stockID.HasValue ? + new ObjectParameter("StockID", stockID) : + new ObjectParameter("StockID", typeof(int)); + + var locationID_FROMParameter = locationID_FROM != null ? + new ObjectParameter("LocationID_FROM", locationID_FROM) : + new ObjectParameter("LocationID_FROM", typeof(string)); + + var locationID_TOParameter = locationID_TO != null ? + new ObjectParameter("LocationID_TO", locationID_TO) : + new ObjectParameter("LocationID_TO", typeof(string)); + + var operatorIDParameter = operatorID != null ? + new ObjectParameter("OperatorID", operatorID) : + new ObjectParameter("OperatorID", typeof(string)); + + var qtyMovParameter = qtyMov.HasValue ? + new ObjectParameter("QtyMov", qtyMov) : + new ObjectParameter("QtyMov", typeof(int)); + + return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("stp_ItemStockMove_New", stockIDParameter, locationID_FROMParameter, locationID_TOParameter, operatorIDParameter, qtyMovParameter); + } } } diff --git a/StockManMVC/Models/SMModel.Designer.cs b/StockManMVC/Models/SMModel.Designer.cs index 55e23f2..61b7291 100644 --- a/StockManMVC/Models/SMModel.Designer.cs +++ b/StockManMVC/Models/SMModel.Designer.cs @@ -1,10 +1,10 @@ -// Generazione del codice predefinita abilitata per il modello 'C:\Users\samuele.STEAMWAREWIN\Documents\VisualStudioProjects\StockMan\StockManMVC\Models\SMModel.edmx'. -// Per abilitare la generazione del codice legacy, modificare il valore della proprietà della finestra di progettazione 'Strategia di generazione del codice -// su 'Legacy ObjectContext'. Questa proprietà è disponibile nella finestra Proprietà quando il modello è -// aperto nella finestra di progettazione. +// T4 code generation is enabled for model 'C:\Users\samuele\Documents\Visual Studio 2015\Projects\StockMan\StockManMVC\Models\SMModel.edmx'. +// To enable legacy code generation, change the value of the 'Code Generation Strategy' designer +// property to 'Legacy ObjectContext'. This property is available in the Properties Window when the model +// is open in the designer. -// La mancata generazione di classi contesto ed entità può essere dovuta al fatto che è stato creato un modello vuoto, ma -// non è ancora stata scelta la versione di Entity Framework da utilizzare. Per generare una classe contesto e classi entità -// per il modello, aprire il modello nella finestra di progettazione, fare clic con il pulsante destro del mouse nell'area di progettazione e -// selezionare 'Aggiorna modello da database...', 'Genera database da modello...' o 'Aggiungi elemento di generazione -// codice...'. \ No newline at end of file +// If no context and entity classes have been generated, it may be because you created an empty model but +// have not yet chosen which version of Entity Framework to use. To generate a context class and entity +// classes for your model, open the model in the designer, right-click on the designer surface, and +// select 'Update Model from Database...', 'Generate Database from Model...', or 'Add Code Generation +// Item...'. \ No newline at end of file diff --git a/StockManMVC/Models/SMModel.cs b/StockManMVC/Models/SMModel.cs index d6f4df2..7cc0662 100644 --- a/StockManMVC/Models/SMModel.cs +++ b/StockManMVC/Models/SMModel.cs @@ -1,9 +1,9 @@ //------------------------------------------------------------------------------ // -// Codice generato da un modello. +// This code was generated from a template. // -// Le modifiche manuali a questo file potrebbero causare un comportamento imprevisto dell'applicazione. -// Se il codice viene rigenerato, le modifiche manuali al file verranno sovrascritte. +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. // //------------------------------------------------------------------------------ diff --git a/StockManMVC/Models/SMModel.edmx b/StockManMVC/Models/SMModel.edmx index 194f223..89d550a 100644 --- a/StockManMVC/Models/SMModel.edmx +++ b/StockManMVC/Models/SMModel.edmx @@ -92,8 +92,8 @@ - + @@ -104,8 +104,8 @@ avviso 6002: Nessuna chiave primaria definita per la tabella/visualizzazione 'St - + @@ -235,6 +235,13 @@ avviso 6002: Nessuna chiave primaria definita per la tabella/visualizzazione 'St + + + + + + + @@ -486,6 +493,13 @@ avviso 6002: Nessuna chiave primaria definita per la tabella/visualizzazione 'St + + + + + + + @@ -779,6 +793,7 @@ avviso 6002: Nessuna chiave primaria definita per la tabella/visualizzazione 'St + diff --git a/StockManMVC/Models/stp_ItemDuplicate1_Result.cs b/StockManMVC/Models/stp_ItemDuplicate1_Result.cs index f3d367c..a8b2082 100644 --- a/StockManMVC/Models/stp_ItemDuplicate1_Result.cs +++ b/StockManMVC/Models/stp_ItemDuplicate1_Result.cs @@ -1,9 +1,9 @@ //------------------------------------------------------------------------------ // -// Codice generato da un modello. +// This code was generated from a template. // -// Le modifiche manuali a questo file potrebbero causare un comportamento imprevisto dell'applicazione. -// Se il codice viene rigenerato, le modifiche manuali al file verranno sovrascritte. +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. // //------------------------------------------------------------------------------ diff --git a/StockManMVC/Models/stp_ItemStockMove_Result.cs b/StockManMVC/Models/stp_ItemStockMove_Result.cs index d1852b7..092871c 100644 --- a/StockManMVC/Models/stp_ItemStockMove_Result.cs +++ b/StockManMVC/Models/stp_ItemStockMove_Result.cs @@ -1,9 +1,9 @@ //------------------------------------------------------------------------------ // -// Codice generato da un modello. +// This code was generated from a template. // -// Le modifiche manuali a questo file potrebbero causare un comportamento imprevisto dell'applicazione. -// Se il codice viene rigenerato, le modifiche manuali al file verranno sovrascritte. +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. // //------------------------------------------------------------------------------ diff --git a/StockManMVC/Models/vItemFlux2Save.cs b/StockManMVC/Models/vItemFlux2Save.cs index a8e3436..d9c6c63 100644 --- a/StockManMVC/Models/vItemFlux2Save.cs +++ b/StockManMVC/Models/vItemFlux2Save.cs @@ -1,9 +1,9 @@ //------------------------------------------------------------------------------ // -// Codice generato da un modello. +// This code was generated from a template. // -// Le modifiche manuali a questo file potrebbero causare un comportamento imprevisto dell'applicazione. -// Se il codice viene rigenerato, le modifiche manuali al file verranno sovrascritte. +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. // //------------------------------------------------------------------------------ diff --git a/StockManMVC/Models/vLocationVal.cs b/StockManMVC/Models/vLocationVal.cs index 8fa1e77..6756374 100644 --- a/StockManMVC/Models/vLocationVal.cs +++ b/StockManMVC/Models/vLocationVal.cs @@ -1,9 +1,9 @@ //------------------------------------------------------------------------------ // -// Codice generato da un modello. +// This code was generated from a template. // -// Le modifiche manuali a questo file potrebbero causare un comportamento imprevisto dell'applicazione. -// Se il codice viene rigenerato, le modifiche manuali al file verranno sovrascritte. +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. // //------------------------------------------------------------------------------ diff --git a/StockManMVC/Views/MagStatus/Index.cshtml b/StockManMVC/Views/MagStatus/Index.cshtml index 418fd29..87fdfb1 100644 --- a/StockManMVC/Views/MagStatus/Index.cshtml +++ b/StockManMVC/Views/MagStatus/Index.cshtml @@ -114,8 +114,8 @@ function refreshSelectedData() { var LocationIdSx = $("#LocationID_SX").val(); var LocationIdDx = $("#LocationID_DX").val(); - $("#divLocationSX").load('@(Url.Action("StockByLocationAjax", "MagStatus",null, Request.Url.Scheme))?LocationId=' + LocationIdSx + '&LocationIdTo=' + LocationIdDx + '&ShowMove=true'); - $("#divLocationDX").load('@(Url.Action("StockByLocationAjax", "MagStatus",null, Request.Url.Scheme))?LocationId=' + LocationIdDx + '&LocationIdTo=' + LocationIdSx + '&ShowMove=false'); + $("#divLocationSX").load('@(Url.Action("StockByLocation", "MagStatus",null, Request.Url.Scheme))?LocationId=' + LocationIdSx + '&LocationIdTo=' + LocationIdDx + '&ShowMove=true'); + $("#divLocationDX").load('@(Url.Action("StockByLocation", "MagStatus",null, Request.Url.Scheme))?LocationId=' + LocationIdDx + '&LocationIdTo=' + LocationIdSx + '&ShowMove=false'); // modifico URL! history.replaceState('LocationID_SX=' + LocationIdSx + '&LocationID_DX=' + LocationIdDx, 'MagStatus', 'http://localhost:4539/MagStatus?LocationID_SX=' + LocationIdSx + '&LocationID_DX=' + LocationIdDx) diff --git a/StockManMVC/Views/MagStatus/_confirmMove.cshtml b/StockManMVC/Views/MagStatus/_confirmMove.cshtml index 84ff0ae..201140a 100644 --- a/StockManMVC/Views/MagStatus/_confirmMove.cshtml +++ b/StockManMVC/Views/MagStatus/_confirmMove.cshtml @@ -1,28 +1,22 @@ -@model IEnumerable +@model StockManMVC.Models.ItemStock -
+@using (Html.BeginForm()) +{ + @Html.AntiForgeryToken()
- @foreach (var item in Model) - { -
- Da: - @Html.DisplayFor(modelItem => item.Location.Descr) - a: - @ViewBag.LocationIdTo -
-
- @Html.EditorFor(modelItem => item.QtyConf, new { htmlAttributes = new { min = 0, max = item.QtyConf } }) pz. -
-
- Salva -
- - - } - @**@ +
+ Converma spostamento di @Html.EditorFor(m => m.QtyConf, new { htmlAttributes = new { min = 0, max = Model.QtyConf } }) pz. + @Html.ValidationMessageFor(model => model.QtyConf, "", new { @class = "text-danger" }) +
+
+ +
+
-
\ No newline at end of file +} + +@section Scripts { + @Scripts.Render("~/bundles/jqueryval") +} diff --git a/StockManMVC/bin/StockManMVC.dll b/StockManMVC/bin/StockManMVC.dll index 46e9c3f..0ec501d 100644 Binary files a/StockManMVC/bin/StockManMVC.dll and b/StockManMVC/bin/StockManMVC.dll differ