diff --git a/StockManMVC/Controllers/ItemFluxesController.cs b/StockManMVC/Controllers/ItemFluxesController.cs index 18b6a79..b33ca90 100644 --- a/StockManMVC/Controllers/ItemFluxesController.cs +++ b/StockManMVC/Controllers/ItemFluxesController.cs @@ -421,6 +421,31 @@ namespace StockManMVC.Controllers return RedirectToAction("Details", "Items", new { ID = itemFlux.ItemID, StockItemID = itemFlux.ItemID }); } + + // GET: Items/Duplicate/5 + public ActionResult Duplicate(int? id) + { + if (id == null) + { + return new HttpStatusCodeResult(HttpStatusCode.BadRequest); + } + int newId = 0; + int ItemID = 0; + // ora chiamo stored e recupero nuovo ID del record duplicato + using (var ctx = new StockManEntities()) + { + // esegue stored procedure come function, recuperando nuovo ID creato... + var newItemFlux = ctx.stp_ItemFluxDuplicate(id).ToList(); + newId = newItemFlux[0].ID; + ItemID = newItemFlux[0].ItemID; + } + + // rimando in editing! + return RedirectToAction("Edit", "ItemFluxes", new { ID = newId, mode = "std" }); + //return Edit(newId, "std"); + //return RedirectToAction("Details", "Items", new { ID = ItemID, StockItemID = ItemID }); + } + // GET: ItemFluxes/Edit/5 public ActionResult Edit(int? id, string mode) { diff --git a/StockManMVC/Controllers/ItemsController.cs b/StockManMVC/Controllers/ItemsController.cs index eb6cb97..2b5fd1a 100644 --- a/StockManMVC/Controllers/ItemsController.cs +++ b/StockManMVC/Controllers/ItemsController.cs @@ -326,7 +326,7 @@ namespace StockManMVC.Controllers using (var ctx = new StockManEntities()) { // esegue stored procedure come function, recuperando nuovo ID creato... - var newItem = ctx.stp_ItemDuplicate(id).ToList(); + var newItem = ctx.stp_ItemDuplicate(id).ToList(); newId = newItem[0].ID; } diff --git a/StockManMVC/Models/SMModel.Context.cs b/StockManMVC/Models/SMModel.Context.cs index c89ece6..e0a129e 100644 --- a/StockManMVC/Models/SMModel.Context.cs +++ b/StockManMVC/Models/SMModel.Context.cs @@ -138,5 +138,23 @@ namespace StockManMVC.Models return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("stp_Counters_getNext", mergeOption, iDParameter); } + + public virtual ObjectResult stp_ItemFluxDuplicate(Nullable original_ID) + { + var original_IDParameter = original_ID.HasValue ? + new ObjectParameter("Original_ID", original_ID) : + new ObjectParameter("Original_ID", typeof(int)); + + return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("stp_ItemFluxDuplicate", original_IDParameter); + } + + public virtual ObjectResult stp_ItemFluxDuplicate(Nullable original_ID, MergeOption mergeOption) + { + var original_IDParameter = original_ID.HasValue ? + new ObjectParameter("Original_ID", original_ID) : + new ObjectParameter("Original_ID", typeof(int)); + + return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("stp_ItemFluxDuplicate", mergeOption, original_IDParameter); + } } } diff --git a/StockManMVC/Models/SMModel.edmx b/StockManMVC/Models/SMModel.edmx index 6978685..c55913d 100644 --- a/StockManMVC/Models/SMModel.edmx +++ b/StockManMVC/Models/SMModel.edmx @@ -4,7 +4,7 @@ - + @@ -256,6 +256,9 @@ warning 6002: The table/view 'StockMan.dbo.vLocationVal' does not have a primary + + + @@ -551,6 +554,9 @@ warning 6002: The table/view 'StockMan.dbo.vLocationVal' does not have a primary + + + @@ -746,6 +752,20 @@ warning 6002: The table/view 'StockMan.dbo.vLocationVal' does not have a primary + + + + + + + + + + + + + + @@ -889,6 +909,8 @@ warning 6002: The table/view 'StockMan.dbo.vLocationVal' does not have a primary + + diff --git a/StockManMVC/Models/stp_ItemFluxDuplicate_Result.cs b/StockManMVC/Models/stp_ItemFluxDuplicate_Result.cs new file mode 100644 index 0000000..8432a75 --- /dev/null +++ b/StockManMVC/Models/stp_ItemFluxDuplicate_Result.cs @@ -0,0 +1,29 @@ +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// 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. +// +//------------------------------------------------------------------------------ + +namespace StockManMVC.Models +{ + using System; + + public partial class stp_ItemFluxDuplicate_Result + { + public int ID { get; set; } + public string Descr { get; set; } + public string CodInt { get; set; } + public string ItemFamilyID { get; set; } + public string CodExt { get; set; } + public string DescrExt { get; set; } + public int QtaMin { get; set; } + public int QtaBatch { get; set; } + public decimal CurrValue { get; set; } + public Nullable QtaCurr { get; set; } + public Nullable QtaPend { get; set; } + public string UM { get; set; } + } +} diff --git a/StockManMVC/StockManMVC.csproj b/StockManMVC/StockManMVC.csproj index 670d860..ebb741f 100644 --- a/StockManMVC/StockManMVC.csproj +++ b/StockManMVC/StockManMVC.csproj @@ -238,6 +238,9 @@ SMModel.tt + + SMModel.tt + SMModel.tt @@ -326,6 +329,8 @@ + + @@ -356,8 +361,6 @@ SMModel.edmx - - @@ -651,7 +654,9 @@ pdbonly AnyCPU prompt - MinimumRecommendedRules.ruleset + false + + bin\ @@ -660,7 +665,9 @@ pdbonly AnyCPU prompt - MinimumRecommendedRules.ruleset + false + + diff --git a/StockManMVC/Views/ItemFluxes/_ListByItem.cshtml b/StockManMVC/Views/ItemFluxes/_ListByItem.cshtml index dec8dd5..14c92d0 100644 --- a/StockManMVC/Views/ItemFluxes/_ListByItem.cshtml +++ b/StockManMVC/Views/ItemFluxes/_ListByItem.cshtml @@ -51,7 +51,8 @@ @Html.DisplayFor(modelItem => item.Location1.Descr) - + + @Html.ActionLink(" ", "ConvOrder", new { ID = item.ID }, new { @class = "btn btn-xs btn-info glyphicon glyphicon-flash " + @delStyle + " " + @convStyle }) diff --git a/StockManMVC/Views/Items/Details.cshtml b/StockManMVC/Views/Items/Details.cshtml index 3cef95a..9b29ee1 100644 --- a/StockManMVC/Views/Items/Details.cshtml +++ b/StockManMVC/Views/Items/Details.cshtml @@ -115,6 +115,11 @@ $("#divBtnIF").hide(); } + function LoadItemFluxDupl(ID) { + $("#divCreateMov").load('@(Url.Action("Duplicate", "ItemFluxes", null, Request.Url.Scheme))?ID=' + ID + '&mode=std'); + $("#divBtnIF").hide(); + } + function LoadItemFluxDelete(ID) { $("#divCreateMov").load('@(Url.Action("Delete", "ItemFluxes", null, Request.Url.Scheme))?ID=' + ID + '&mode=std'); $("#divBtnIF").hide(); diff --git a/StockManMVC/bin/StockManMVC.dll b/StockManMVC/bin/StockManMVC.dll index d6e6523..5b9c50f 100644 Binary files a/StockManMVC/bin/StockManMVC.dll and b/StockManMVC/bin/StockManMVC.dll differ