aggiunta possibilità reset storia movimenti (+ cancellazione stock...)

This commit is contained in:
Samuele E. Locatelli
2017-01-03 10:59:24 +01:00
parent be4a111b7e
commit 9333844a7f
7 changed files with 64 additions and 4 deletions
+35 -2
View File
@@ -239,7 +239,7 @@ namespace StockManMVC.Controllers
}
// GET: Items/Details/5
public ActionResult Details(int? id, int? page, int? pageSize)
public ActionResult Details(int? id, int? page, int? pageSize, string enabFR)
{
if (page == null) page = 1;
if (pageSize == null) pageSize = 10;
@@ -254,6 +254,14 @@ namespace StockManMVC.Controllers
{
return HttpNotFound();
}
// 2017.01.03 aggiunto controllo x permesso a resettare INTERA catena flussi + stock... SE in URL si trova comando enabFR=enabFR_key (da webconfig)...
ViewBag.DisplFR = "disabled invisible zeroWidth";
if (enabFR != null)
{
string enabFR_key = System.Web.Configuration.WebConfigurationManager.AppSettings["enabFR_key"];
if (enabFR == enabFR_key) ViewBag.DisplFR = "";
}
// restituisco vista parziale
return View(item);
}
@@ -273,6 +281,31 @@ namespace StockManMVC.Controllers
return PartialView("_ItemDetail", item);
}
// GET: Items/ResetAll/5
public ActionResult ResetAll(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Item item = db.Item.Find(id);
if (item == null)
{
return HttpNotFound();
}
// se ha trovato l'item ORA RESETTA TUTTO sia in stock che in flussi (toglie registrazione di tutti i movimenti)
// chiamo stored x consolidamento flussi (da movimenti a giacenza confermata)
using (var ctx = new StockManEntities())
{
// esegue stored procedure come function...
ctx.stp_ItemResetAll(id);
}
// restituisco view!
//return PartialView("_ItemDetail", item);
return RedirectToAction("Details", "Items", new { ID = id, StockItemID = id });
}
// GET: Items/Create (mode=std|full, opzionale)
public ActionResult Create(string mode)
@@ -362,7 +395,7 @@ namespace StockManMVC.Controllers
return View("Edit", item);
}
}
// POST: Items/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.
+9
View File
@@ -156,5 +156,14 @@ namespace StockManMVC.Models
return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<ItemFlux>("stp_ItemFluxDuplicate", mergeOption, original_IDParameter);
}
public virtual int stp_ItemResetAll(Nullable<int> itemID)
{
var itemIDParameter = itemID.HasValue ?
new ObjectParameter("ItemID", itemID) :
new ObjectParameter("ItemID", typeof(int));
return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("stp_ItemResetAll", itemIDParameter);
}
}
}
+7
View File
@@ -259,6 +259,9 @@ warning 6002: The table/view 'StockMan.dbo.vLocationVal' does not have a primary
<Function Name="stp_ItemFluxDuplicate" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="false" ParameterTypeSemantics="AllowImplicitConversion" Schema="dbo">
<Parameter Name="Original_ID" Type="int" Mode="In" />
</Function>
<Function Name="stp_ItemResetAll" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="false" ParameterTypeSemantics="AllowImplicitConversion" Schema="dbo">
<Parameter Name="ItemID" Type="int" Mode="In" />
</Function>
<Function Name="stp_ItemShrinkHist" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="false" ParameterTypeSemantics="AllowImplicitConversion" Schema="dbo">
<Parameter Name="ItemID" Type="int" Mode="In" />
</Function>
@@ -557,6 +560,9 @@ warning 6002: The table/view 'StockMan.dbo.vLocationVal' does not have a primary
<FunctionImport Name="stp_ItemFluxDuplicate" EntitySet="ItemFlux" ReturnType="Collection(StockManModel.ItemFlux)">
<Parameter Name="Original_ID" Mode="In" Type="Int32" />
</FunctionImport>
<FunctionImport Name="stp_ItemResetAll">
<Parameter Name="ItemID" Mode="In" Type="Int32" />
</FunctionImport>
</EntityContainer>
<EntityType Name="ItemFamily">
<Key>
@@ -911,6 +917,7 @@ warning 6002: The table/view 'StockMan.dbo.vLocationVal' does not have a primary
</FunctionImportMapping>
<FunctionImportMapping FunctionImportName="stp_ItemFluxDuplicate" FunctionName="StockManModel.Store.stp_ItemFluxDuplicate">
</FunctionImportMapping>
<FunctionImportMapping FunctionImportName="stp_ItemResetAll" FunctionName="StockManModel.Store.stp_ItemResetAll" />
</EntityContainerMapping>
</Mapping>
</edmx:Mappings>
+11 -2
View File
@@ -80,7 +80,16 @@
<div class="col-sm-5">
<div class="panel panel-default">
<div class="panel-heading">
<strong>Movimenti</strong> (data indica movimenti <del>confermati</del> o <span class="text-warning mark">da registrare</span>)
<div class="row">
<div class="col-xs-10">
<strong>Movimenti</strong> (data indica movimenti <del>confermati</del> o <span class="text-warning mark">da registrare</span>)
</div>
<div class="col-xs-2 ">
<a href="@Url.Action("ResetAll", "Items", new { id = Model.ID, caller="Items" })" class="btn btn-sm btn-danger text-right @ViewBag.DisplFR" onClick="return confirm('Sicuro di voler resettare tutta la storia dei movimenti?')" title="Reset ALL">
<i class="glyphicon glyphicon-alert" aria-hidden="true"></i>
</a>
</div>
</div>
</div>
<div class="panel-body small">
@Html.Action("ListByItem", "ItemFluxes", new { ItemID = @Model.ID, page = ViewBag.page, pageSize = ViewBag.pageSize })
@@ -93,7 +102,7 @@
function CreateNewMov(ItemID, MovTypeID) {
$("#divCreateMov").load('@(Url.Action("CreatePrecompiled", "ItemFluxes", null, Request.Url.Scheme))?ItemID=' + ItemID + '&MovTypeID=' + MovTypeID);
}
function LoadItemDetail(ItemID) {
$("#itemPartialView").load('@(Url.Action("CurrItemDetail", "Items", null, Request.Url.Scheme))?ID=' + ItemID);
$("#divButtons").show();
+1
View File
@@ -15,6 +15,7 @@
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
<add key="Environment" value="Dev" />
<add key="enabFR_key" value="@tt1v@t0"/>
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.6.2" />
Binary file not shown.
+1
View File
@@ -15,6 +15,7 @@
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
<add key="Environment" value="Dev" />
<add key="enabFR_key" value="@tt1v@t0"/>
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.6.2" />