示例#1
0
文件: ItemBO.cs 项目: ewin66/dev
        public void DrillUpUpdateAllCoefficientsOfItem(UnitOfWork uow, Guid itemId, Guid currentItemUnitId)
        {
            NAS.DAL.Nomenclature.Item.ItemUnit currentItemUnit =
                uow.GetObjectByKey <NAS.DAL.Nomenclature.Item.ItemUnit>(currentItemUnitId);

            NAS.DAL.Nomenclature.Item.Item item =
                uow.GetObjectByKey <NAS.DAL.Nomenclature.Item.Item>(itemId);

            if (currentItemUnit == null)
            {
                throw new Exception("The ItemUnit is not exist in system");
            }

            if (item == null)
            {
                throw new Exception("The Item is not exist in system");
            }

            NAS.DAL.Nomenclature.Item.ItemUnit parent = currentItemUnit.ParentItemUnitId;

            if (parent == null)
            {
                return;
            }

            parent.Coefficient = currentItemUnit.Coefficient / currentItemUnit.NumRequired;
            parent.Save();
            uow.FlushChanges();
            DrillUpUpdateAllCoefficientsOfItem(uow, itemId, parent.ItemUnitId);
        }
示例#2
0
文件: ItemBO.cs 项目: ewin66/dev
        public void DrillDownDeleteLogicUnitOfItem(UnitOfWork uow, Guid itemId, Guid deletingItemUnitId)
        {
            NAS.DAL.Nomenclature.Item.ItemUnit currentItemUnit =
                uow.GetObjectByKey <NAS.DAL.Nomenclature.Item.ItemUnit>(deletingItemUnitId);

            NAS.DAL.Nomenclature.Item.Item item =
                uow.GetObjectByKey <NAS.DAL.Nomenclature.Item.Item>(itemId);

            if (currentItemUnit == null)
            {
                throw new Exception("The ItemUnit is not exist in system");
            }

            if (item == null)
            {
                throw new Exception("The Item is not exist in system");
            }
            XPCollection <NAS.DAL.Nomenclature.Item.ItemUnit> childrentItemUnit = new XPCollection <ItemUnit>(uow,
                                                                                                              new BinaryOperator("ParentItemUnitId!Key", currentItemUnit.ItemUnitId, BinaryOperatorType.Equal));

            currentItemUnit.RowStatus = Utility.Constant.ROWSTATUS_DELETED;
            currentItemUnit.Save();
            uow.FlushChanges();

            foreach (NAS.DAL.Nomenclature.Item.ItemUnit currIU in childrentItemUnit)
            {
                DrillDownDeleteLogicUnitOfItem(uow, itemId, currIU.ItemUnitId);
            }
        }
示例#3
0
        protected void treelstProductUnits_NodeDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e)
        {
            e.Cancel = true;
            if (itemBO.checkIsExistInBillItem(session, ItemId))
            {
                throw new Exception("Đối tượng này đã tồn tại trong phiếu mua hoặc phiếu bán nên không thể sửa hoặc xóa");
            }

            if (itemBO.checkIsItemInInventory(session, ItemId))
            {
                throw new Exception("Đối tượng đã tồn tại trong kho hàng nên không thể chỉnh sửa hoặc xóa đơn vị tính");
            }

            using (UnitOfWork uow = XpoHelper.GetNewUnitOfWork())
            {
                try
                {
                    NAS.DAL.Nomenclature.Item.ItemUnit itemunit = uow.GetObjectByKey <NAS.DAL.Nomenclature.Item.ItemUnit>(Guid.Parse(treelstProductUnits.FocusedNode.Key));
                    itemunit.Coefficient = 0;
                    itemunit.Save();
                    uow.FlushChanges();
                    itemBO.DrillUpUpdateAllCoefficientsOfItem(uow, ItemId, Guid.Parse(treelstProductUnits.FocusedNode.Key));
                    itemBO.DrillDownDeleteLogicUnitOfItem(uow, ItemId, Guid.Parse(treelstProductUnits.FocusedNode.Key));
                }
                catch
                {
                    throw;
                }
                finally
                {
                    uow.Dispose();
                }
            }

            treelstProductUnits.DataBind();
        }