Aggiunta nuova chiamata x shrink movimenti duplicati inutilmente...

This commit is contained in:
Samuele E. Locatelli (WEB DEV)
2016-09-29 23:47:10 +02:00
parent 7ba4cfda07
commit d92ae46dde
6 changed files with 155 additions and 35 deletions
+71
View File
@@ -0,0 +1,71 @@
USE [StockMan]
GO
/****** Object: StoredProcedure [dbo].[stp_ItemShrinkHist] Script Date: 29/09/2016 23:44:55 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: S.E.L.
-- Create date: 2016.09.21
-- Description: Riduce i movimenti per una data locazione-item (nulli, oppure a somma nulla a pari giorno)
-- =============================================
CREATE PROCEDURE [dbo].[stp_ItemShrinkHist]
(
@ItemID INT = 0
)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
BEGIN tran
-- elimino in primis i movimenti nulli...
DELETE
FROM ItemFlux
WHERE Qta = 0
AND ItemID = @ItemID
-- cerco movimenti di un item solo positivi o solo negativi
;WITH cteAdd AS
(
SELECT *
FROM ItemFlux
WHERE Qta > 0
AND ItemID = @ItemID
), cteRem AS
(
SELECT *
FROM ItemFlux
WHERE Qta < 0
AND ItemID = @ItemID
)
-- li incrocio e se si annullano..
, cteNull AS
(
SELECT a.*
FROM cteAdd a INNER JOIN cteRem r
ON a.LocationID=r.LocationID
AND a.dtMov = r.dtMov
AND ABS(a.Qta) = ABS(r.Qta)
)
--select * from cteNull
-- ora che li ho selezionati li elimino...
DELETE iflx
FROM ItemFlux iflx INNER JOIN cteNull cte
ON iflx.LocationID = cte.LocationID
AND iflx.ItemID = cte.ItemID
AND iflx.dtMov = cte.dtMov
WHERE ABS(iflx.Qta) = ABS(cte.Qta)
COMMIT tran
END
GO
@@ -170,6 +170,33 @@ namespace StockManMVC.Controllers
}
}
// GET: Items/ShrinkHistory/5?caller=callingController
public ActionResult ShrinkHistory(int? id, string caller)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
// chiamo stored x consolidamento flussi (da movimenti a giacenza confermata)
using (var ctx = new StockManEntities())
{
// esegue stored procedure come function, SE id == 0 processa TUTTI...
int rowMod = ctx.stp_ItemShrinkHist(id);
}
// se non specificati rimando a /Items/Details
if (caller == "") caller = "Items";
// rimanda alla view principale da cui è stata fatta la chiamata...
if (caller == "Items")
{
return RedirectToAction("Details", "Items", new { ID = id, StockItemID = id, FluxItemID = id });
}
else
{
return RedirectToAction("Index", "vItemFlux2Save");
}
}
/// <summary>
/// calcolo num risultati
+9
View File
@@ -110,5 +110,14 @@ namespace StockManMVC.Models
return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("stp_ItemStockMove_New", stockIDParameter, locationID_FROMParameter, locationID_TOParameter, operatorIDParameter, qtyMovParameter);
}
public virtual int stp_ItemShrinkHist(Nullable<int> itemID)
{
var itemIDParameter = itemID.HasValue ?
new ObjectParameter("ItemID", itemID) :
new ObjectParameter("ItemID", typeof(int));
return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("stp_ItemShrinkHist", itemIDParameter);
}
}
}
+7
View File
@@ -229,6 +229,9 @@ warning 6002: The table/view 'StockMan.dbo.vLocationVal' does not have a primary
<Function Name="stp_ItemDuplicate" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="false" ParameterTypeSemantics="AllowImplicitConversion" Schema="dbo">
<Parameter Name="Original_ID" 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>
<Function Name="stp_ItemStockMove" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="false" ParameterTypeSemantics="AllowImplicitConversion" Schema="dbo">
<Parameter Name="StockID" Type="int" Mode="In" />
<Parameter Name="LocationID_FROM" Type="nvarchar" Mode="In" />
@@ -500,6 +503,9 @@ warning 6002: The table/view 'StockMan.dbo.vLocationVal' does not have a primary
<Parameter Name="OperatorID" Mode="In" Type="String" />
<Parameter Name="QtyMov" Mode="In" Type="Int32" />
</FunctionImport>
<FunctionImport Name="stp_ItemShrinkHist">
<Parameter Name="ItemID" Mode="In" Type="Int32" />
</FunctionImport>
</EntityContainer>
<EntityType Name="ItemFamily">
<Key>
@@ -794,6 +800,7 @@ warning 6002: The table/view 'StockMan.dbo.vLocationVal' does not have a primary
<FunctionImportMapping FunctionImportName="stp_ItemStockMove" FunctionName="StockManModel.Store.stp_ItemStockMove">
</FunctionImportMapping>
<FunctionImportMapping FunctionImportName="stp_ItemStockMove_New" FunctionName="StockManModel.Store.stp_ItemStockMove_New" />
<FunctionImportMapping FunctionImportName="stp_ItemShrinkHist" FunctionName="StockManModel.Store.stp_ItemShrinkHist" />
</EntityContainerMapping>
</Mapping>
</edmx:Mappings>
+41 -35
View File
@@ -95,10 +95,21 @@
</div>
<div class="panel-body small">
@Html.MVCGrid("StockItemsGrid")
<a href="@Url.Action("Consolidate", "Items", new { id = Model.ID, caller="Items" })" class="btn btn-success">
<i class="glyphicon glyphicon-save" aria-hidden="true"></i>
Registra movimenti
</a>
<div class="row">
<div class="col-xs-6 padZR">
<a href="@Url.Action("Consolidate", "Items", new { id = Model.ID, caller="Items" })" class="btn btn-primary">
<i class="glyphicon glyphicon-save" aria-hidden="true"></i>
Registra movimenti
</a>
</div>
<div class="col-xs-6 padZL">
<a href="@Url.Action("ShrinkHistory", "Items", new { id = Model.ID, caller="Items" })" class="btn btn-primary">
Riduzione movimenti
<i class="glyphicon glyphicon-compressed" aria-hidden="true"></i>
</a>
</div>
</div>
<hr />
<div class="row">
<div class="col-xs-4 padZR">
@@ -130,40 +141,35 @@
</div>
<div class="panel-body small">
@*<div class="btn-group" data-toggle="buttons">
<label class="btn btn-default active">
<input type="checkbox" autocomplete="off" checked>CAR
</label>
<label class="btn btn-default">
<input type="checkbox" autocomplete="off">MOV
</label>
<label class="btn btn-default">
<input type="checkbox" autocomplete="off">RET
</label>
<label class="btn btn-default active">
<input type="checkbox" autocomplete="off" checked>SCA
</label>
</div>*@
<label class="btn btn-default active">
<input type="checkbox" autocomplete="off" checked>CAR
</label>
<label class="btn btn-default">
<input type="checkbox" autocomplete="off">MOV
</label>
<label class="btn btn-default">
<input type="checkbox" autocomplete="off">RET
</label>
<label class="btn btn-default active">
<input type="checkbox" autocomplete="off" checked>SCA
</label>
</div>*@
@*<a href="@Url.Action("Details", "Items", new { id = Model.ID, StockItemID=Model.ID, FluxItemID= Model.ID })" class="btn btn-primary">
<i class="glyphicon glyphicon-check" aria-hidden="true"></i>
ALL/none
</a>*@
<i class="glyphicon glyphicon-check" aria-hidden="true"></i>
ALL/none
</a>*@
@Html.Partial("_MVCGridToolbar", new StockManMVC.Models.MVCGridToolbarModel()
{
MVCGridName = "FluxItemsGrid",
PageSize = true,
ColumnVisibility = true,
Export = false,
GlobalSearch = true
})
@Html.MVCGrid("FluxItemsGrid")
</div>
@Html.Partial("_MVCGridToolbar", new StockManMVC.Models.MVCGridToolbarModel()
{
MVCGridName = "FluxItemsGrid",
PageSize = true,
ColumnVisibility = true,
Export = false,
GlobalSearch = true
})
@Html.MVCGrid("FluxItemsGrid")
</div>
</div>
</div>
</div>
Binary file not shown.