Move Wip, working through the BO's

foreach(var x in ttResults.Where(r => r.Updated()))
{
	using (var txscope = IceDataContext.CreateDefaultTransactionScope()) 
	{
		var pwip = (from pw in Db.PartWip where pw.Company == callContextClient.CurrentCompany && pw.SysRowID == x.PartWip_SysRowID select pw).FirstOrDefault();
		var whseBin = (from wb in Db.WhseBin where wb.Company == pwip.Company && wb.BinNum == x.PartWip_BinNum && wb.WarehouseCode == x.PartWip_WareHouseCode select wb).FirstOrDefault();
		if(whseBin !=null)
		{
			pwip.WareHouseCode = x.PartWip_WareHouseCode;
			pwip.BinNum = x.PartWip_BinNum;
			pwip.Quantity = x.PartWip_Quantity;
			Db.Validate();
		}
		else
		{
			throw new Ice.BLException("Dude, this isn't a valid Bin location for the warehouse you have choosen.");
		}
		txscope.Complete();
	}
}
1 Like