示例#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
        protected void grdProductUnit_HtmlDataCellPrepared(object sender, TreeListHtmlDataCellEventArgs e)
        {
            //Setting numberRequired
            ASPxTreeList tree = sender as ASPxTreeList;

            if (e.Column.FieldName == "NumRequired" && e.Level == 1)
            {
                e.Cell.Text = "";
            }

            //Setting Description for node
            if (e.Column.Name == "Description")
            {
                TreeListNode node = tree.FindNodeByKeyValue(e.NodeKey);

                NAS.DAL.Nomenclature.Item.ItemUnit currentItem = (NAS.DAL.Nomenclature.Item.ItemUnit)node.DataItem;
                if (e.Level > 1)
                {
                    NAS.DAL.Nomenclature.Item.ItemUnit parentItem = (NAS.DAL.Nomenclature.Item.ItemUnit)node.ParentNode.DataItem;
                    e.Cell.Text = String.Format("1 {0} bao gồm {1} {2}",
                                                parentItem.UnitId.Name,
                                                currentItem.NumRequired,
                                                currentItem.UnitId.Name);
                }
                else
                {
                    e.Cell.Text = String.Format("{0} là đơn vị tính cao nhất",
                                                currentItem.UnitId.Name);
                }
            }
        }
示例#3
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);
            }
        }
示例#4
0
文件: ItemBO.cs 项目: ewin66/dev
        public void DrillDownUpdateAllCoefficientsOfItem(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");
            }
            XPCollection <NAS.DAL.Nomenclature.Item.ItemUnit> childrentItemUnit = new XPCollection <ItemUnit>(uow,
                                                                                                              new BinaryOperator("ParentItemUnitId!Key", currentItemUnit.ItemUnitId, BinaryOperatorType.Equal));

            foreach (NAS.DAL.Nomenclature.Item.ItemUnit currIU in childrentItemUnit)
            {
                currIU.Coefficient = currentItemUnit.Coefficient * currIU.NumRequired;
                currIU.Save();
                uow.FlushChanges();
                DrillDownUpdateAllCoefficientsOfItem(uow, itemId, currIU.ItemUnitId);
            }
        }
示例#5
0
 protected void GridPlanningJournal_CustomColumnDisplayText(object sender, ASPxGridViewColumnDisplayTextEventArgs e)
 {
     if (e.Column.FieldName == "ItemUnitId!Key")
     {
         NAS.DAL.Nomenclature.Item.ItemUnit itemUnit = session.GetObjectByKey <NAS.DAL.Nomenclature.Item.ItemUnit>(Guid.Parse(e.Value.ToString()));
         e.DisplayText = itemUnit.ItemId.Name;
     }
 }
示例#6
0
 private void FillLotCombo(ASPxComboBox combo, Guid itemId)
 {
     NAS.DAL.Nomenclature.Item.ItemUnit itemUnit = session.GetObjectByKey <NAS.DAL.Nomenclature.Item.ItemUnit>(itemId);
     if (itemUnit.ItemId != null)
     {
         combo.DataSource = itemUnit.ItemId.Lots;
     }
     else
     {
         combo.DataSource = null;
     }
     combo.DataBindItems();
 }
示例#7
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();
        }
示例#8
0
文件: ItemBO.cs 项目: ewin66/dev
        public bool UpdateDefaultItemUnitOfItem(Guid itemId, Guid defaultItemUnitId)
        {
            using (UnitOfWork uow = XpoHelper.GetNewUnitOfWork())
            {
                try
                {
                    NAS.DAL.Nomenclature.Item.ItemUnit iu =
                        uow.GetObjectByKey <NAS.DAL.Nomenclature.Item.ItemUnit>(defaultItemUnitId);

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

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

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

                    IEnumerable <NAS.DAL.Nomenclature.Item.ItemUnit> tmpLst =
                        i.ItemUnits.Where(
                            row =>
                            row.UnitId != null &&
                            row.ItemId != null &&
                            row.UnitId.UnitTypeId != null &&
                            row.UnitId.UnitTypeId.Code == iu.UnitId.UnitTypeId.Code);

                    foreach (NAS.DAL.Nomenclature.Item.ItemUnit o in tmpLst)
                    {
                        if (o.ItemUnitId.Equals(defaultItemUnitId))
                        {
                            o.Coefficient = 1;
                            o.IsDefault   = true;
                        }
                        else
                        {
                            o.IsDefault = false;
                        }
                        o.Save();
                    }

                    DrillDownUpdateAllCoefficientsOfItem(uow, itemId, defaultItemUnitId);

                    DrillUpUpdateAllCoefficientsOfItem(uow, itemId, defaultItemUnitId);

                    uow.CommitChanges();
                    return(true);
                }
                catch
                {
                    throw;
                }
                finally
                {
                    uow.Dispose();
                }
            }
        }