I am trying to create a dashboard that transfers material from one warehouse to another. The customer allows negative inventory (yeah, I know but when the CEO says “do it”, I politely ensure I send an email to the PM with the direction we are heading and what was warned). Later they see that leaves a mess in inventory (and “surprise!”, unaccounted for losses). I’ve created a dashboard that shows where inventory has gone negative and am able to transfer the correct quantity from one warehouse to another. However, I thought I would be able to update the dashboard results from the BPM code. I would like to either remove the record (not likely) or show the new On Hand Qty.
I have the user check a checkbox and save (for each row for now). Then I ask them to refresh to see the change.
Here is my code:
string LegalNumberMessage;
string partTranPKs;
using (var hInvTran = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.InvTransferSvcContract>(Db))
{
foreach (ResultsUbaqRow tt in ttResults.Where(tt => !string.IsNullOrEmpty(tt.RowMod) && tt.Calculated_Replenish && tt.PartBin_OnhandQty < 0))
{
Erp.Tablesets.InvTransferTableset dsIT = hInvTran.GetTransferRecord(tt.PartBin_PartNum, "");
var row = dsIT.InvTrans[0];
row.FromWarehouseCode = "DUTY";
row.ToWarehouseCode = "LOOSE";
row.FromLotNumber = "1";
row.ToLotNumber = "1";
row.FromBinNum = tt.PartBinForLoose_BinNum;
row.ToBinNum = tt.PartBin_BinNum;
row.TransferQty = Math.Ceiling(Math.Abs(tt.PartBin_OnhandQty)/Convert.ToDecimal(tt.Part_PartsPerContainer));
row.TransferQtyUOM = "CASE";
row.RowMod = "A";
hInvTran.CommitTransfer(ref dsIT, out LegalNumberMessage, out partTranPKs);
//Sure would be awesome if this last part worked...
tt.PartBin_OnhandQty = Db.PartBin.Where(B => B.Company == Session.CompanyID && B.PartNum == tt.PartBin_PartNum && B.WarehouseCode == tt.PartBin_WarehouseCode && B.BinNum == tt.PartBin_BinNum).Select(B => B.OnhandQty).FirstOrDefault();
tt.Calculated_Cases = Convert.ToInt32(Math.Floor(tt.PartBin_OnhandQty / Convert.ToDecimal(tt.Part_PartsPerContainer)));
tt.RowMod = "";
tt.Calculated_Replenish = false;
}
}
PublishInfoMessage("Transfer complete. Please refresh the dashboard.",0,0,"","");