Beispiel #1
0
        private void UpdateWHTotal(WHTotal WHTotal)
        {
            if (WHTotal.PhysicalQty + WHQty < 0)
            {
                throw new Exception(string.Format("產品({0})倉存數({1})不足,  !!", Item.ItemNo, WHTotal.PhysicalQty));
            }

            WHTotal.PhysicalQty = WHTotal.PhysicalQty + WHQty;
            WHTotal.Save();
        }
Beispiel #2
0
        protected override void OnSaving()
        {
            if (base.IsNewRecord())
            {
                WHTotal WHTotal = Session.FindObject<WHTotal>(CriteriaOperator.Parse(string.Format("Item = '{0}' AND Warehouse = '{1}'", Item.Oid, Warehouse.Oid)));

                if (WHTotal == null)
                {
                    WHTotal = new WHTotal(Session);
                    WHTotal.Item = Item;
                    WHTotal.PhysicalQty = 0;
                    WHTotal.Warehouse = Warehouse;
                    WHTotal.Save();
                }

                UpdateWHQty(WHTotal);
                UpdateWHTotal(WHTotal);
            }

            base.OnSaving();
        }