Exemplo n.º 1
0
        public static IEnumerable <Item> getItemUnitInInventory(Session session, Guid inventoryId)
        {
            List <Item> rs = null;

            try
            {
                XPQuery <Item> itemQuery = session.Query <Item>();
                XPQuery <ItemUnitRelationType> itemUnitRelationTypeQ = session.Query <ItemUnitRelationType>();
                ItemUnitRelationType           unitRelationType      = itemUnitRelationTypeQ.Where(r => r.Name == "UNIT").FirstOrDefault();
                XPQuery <InventoryJournal>     inventoryJournalQuery = session.Query <InventoryJournal>();
                rs = (from ivj in inventoryJournalQuery
                      where ivj.InventoryId.InventoryId == inventoryId &&
                      ivj.ItemUnitId.ItemUnitRelationTypeId == unitRelationType
                      group ivj by ivj.ItemUnitId.ItemId into it
                      select it.Key).ToList();
                return(rs);
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
            }
        }
Exemplo n.º 2
0
Arquivo: ItemBO.cs Projeto: ewin66/dev
        public bool checkIsItemInInventory(Session session, Guid ItemId)
        {
            List <Item> rs = null;

            try
            {
                XPQuery <ItemUnitRelationType> itemUnitRelationTypeQ = session.Query <ItemUnitRelationType>();
                ItemUnitRelationType           unitRelationType      = itemUnitRelationTypeQ.Where(r => r.Name == "UNIT").FirstOrDefault();
                XPQuery <InventoryJournal>     inventoryJournalQuery = session.Query <InventoryJournal>();
                rs = (from ivj in inventoryJournalQuery
                      where ivj.InventoryId.RowStatus > 0 && ivj.ItemUnitId.ItemId.ItemId == ItemId &&
                      ivj.ItemUnitId.ItemUnitRelationTypeId == unitRelationType
                      group ivj by ivj.ItemUnitId.ItemId into it
                      select it.Key).ToList();

                if (rs.Count > 0)
                {
                    return(true);
                }
                return(false);
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
            }
        }
Exemplo n.º 3
0
        protected void treelstProductUnits_NodeInserted(object sender, DevExpress.Web.Data.ASPxDataInsertedEventArgs e)
        {
            ItemUnitRelationType itemUnitRelationType = session.FindObject <ItemUnitRelationType>(new BinaryOperator("Name", "UNIT", BinaryOperatorType.Equal));

            if (itemUnitRelationType == null)
            {
                throw new Exception("The key is not exist in ItemUnitRelationType");
            }
            e.NewValues["ItemUnitRelationTypeId!Key"] = itemUnitRelationType.ItemUnitRelationTypeId;
        }
Exemplo n.º 4
0
        protected void grdProductUnit_NodeInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
        {
            collectData();
            e.NewValues["RowStatus"] = Constant.ROWSTATUS_ACTIVE;
            e.NewValues["ItemId"]    = currentItem;
            NAS.DAL.Nomenclature.Item.Unit unit = session.FindObject <NAS.DAL.Nomenclature.Item.Unit>(new BinaryOperator("Code", e.NewValues["UnitId.Code"]));
            if (unit != null)
            {
                e.NewValues["UnitId"] = unit;
            }
            ItemUnitRelationType itemUnitRType = session.FindObject <ItemUnitRelationType>(new BinaryOperator("Name", "UNIT"));

            if (itemUnitRType != null)
            {
                e.NewValues["ItemUnitRelationTypeId"] = itemUnitRType;
            }
            e.NewValues["RowCreationTimeStamp"] = DateTime.Now;
            treelstProductUnits.CancelEdit();
        }
Exemplo n.º 5
0
Arquivo: UnitBO.cs Projeto: ewin66/dev
        //DND
        public bool populateDefaultUnitToItemUnit(Guid itemId, Guid unitTypeId)
        {
            using (UnitOfWork uow = NAS.DAL.XpoHelper.GetNewUnitOfWork())
            {
                try
                {
                    string[] values = { "km,m,dm,cm,mm",
                                        "tan,kg,g,mg",
                                        "m³,lit,ml",
                                        "m²,dm²,cm²,mm²" };

                    string[] numOfUnits = { "1,1000,10,10,10",
                                            "1,1000,1000,1000",
                                            "1,1000,1000",
                                            "1,100,10000,1000000" };

                    string[] Code_unittype = { "LENGTH", "WEIGHT", "CAPACITY", "AREA" };

                    #region check database not null
                    Item item_id = uow.GetObjectByKey <Item>(itemId);
                    if (item_id == null)
                    {
                        throw new Exception("The key is not exist in Item");
                    }

                    UnitType unittype_id = uow.GetObjectByKey <UnitType>(unitTypeId);
                    if (unittype_id == null)
                    {
                        throw new Exception("The key is not exist in UnitType");
                    }

                    ItemUnitRelationType itemUnitRelationType = uow.FindObject <ItemUnitRelationType>(
                        CriteriaOperator.And(
                            new BinaryOperator("Name", "UNIT", BinaryOperatorType.Equal),
                            new BinaryOperator("RowStatus", 0, BinaryOperatorType.GreaterOrEqual
                                               )));
                    if (itemUnitRelationType == null)
                    {
                        throw new Exception("The key is not exist in ItemUnitRelationType");
                    }
                    #endregion

                    XPCollection <ItemUnit> itemUnits = new XPCollection <ItemUnit>(uow,
                                                                                    CriteriaOperator.And(
                                                                                        new BinaryOperator("ItemId", item_id, BinaryOperatorType.Equal),
                                                                                        new BinaryOperator("UnitId.UnitTypeId.Code", unittype_id.Code, BinaryOperatorType.Equal)
                                                                                        ));

                    foreach (ItemUnit iu in itemUnits)
                    {
                        iu.RowStatus = Utility.Constant.ROWSTATUS_DELETED;
                        iu.Save();
                    }

                    uow.FlushChanges();


                    for (int i = 0; i < Code_unittype.Length; i++)
                    {
                        if (unittype_id.Code.Equals(Code_unittype[i]))
                        {
                            string[] codeOfUnits    = values[i].Split(',');
                            string[] numOfUnit      = numOfUnits[i].Split(',');
                            ItemUnit parentItemUnit = null;


                            for (int j = 0; j < codeOfUnits.Length; j++)
                            {
                                Unit Unit_id = uow.FindObject <Unit>(
                                    CriteriaOperator.And(
                                        new BinaryOperator("Code", codeOfUnits[j], BinaryOperatorType.Equal),
                                        new BinaryOperator("RowStatus", Utility.Constant.ROWSTATUS_DEFAULT, BinaryOperatorType.Equal)
                                        ));
                                if (Unit_id == null)
                                {
                                    throw new Exception(string.Format("The code '{0}' is not exist in Unit", codeOfUnits[j]));
                                }

                                ItemUnit itemunit = new ItemUnit(uow)
                                {
                                    ItemId                 = item_id,
                                    UnitId                 = Unit_id,
                                    NumRequired            = int.Parse(numOfUnit[j].ToString()),
                                    ParentItemUnitId       = j == 0 ? null : parentItemUnit,
                                    ItemUnitRelationTypeId = itemUnitRelationType,
                                    RowStatus              = Utility.Constant.ROWSTATUS_DEFAULT,
                                    RowCreationTimeStamp   = DateTime.Now
                                };
                                itemunit.Save();
                                uow.FlushChanges();
                                parentItemUnit = itemunit;
                            }
                        }
                    }

                    uow.CommitChanges();
                    return(true);
                }
                catch
                {
                    throw;
                }
                finally
                {
                    uow.Dispose();
                }
            }
        }
Exemplo n.º 6
0
Arquivo: Util.cs Projeto: ewin66/dev
        /// <summary>
        /// Populate default data to database
        /// </summary>
        public static void Populate()
        {
            try
            {
                ////NAS.DAL.Accounting.AccountChart
                NAS.DAL.BI.Accounting.Account.CorrespondFinancialAccountDim.Populate();
                NAS.DAL.BI.Accounting.Account.FinancialAccountDim.Populate();
                Account.Populate();
                AccountType.Populate();
                AccountCategory.Populate();
                Currency.Populate();

                ////NAS.DAL.Accounting.Configure
                AllocationType.Populate();

                ////NAS.DAL.CMS.ObjectDocument
                ObjectType.Populate();
                CustomFieldType.Populate();
                ObjectTypeCustomField.Populate();

                ////NAS.DAL.Inventory.Item
                RecordedType.Populate();

                ////NAS.DAL.Inventory.Operation
                CommanderStockCartStatus.Populate();
                CommanderStockCartType.Populate();

                ////NAS.DAL.Inventory.StockCart
                StockCartActorType.Populate();

                ////NAS.DAL.Invoice
                TaxType.Populate();
                PromotionType.Populate();

                ////NAS.DAL.Nomenclature.Inventory
                Nomenclature.Inventory.Inventory.Populate();
                InventoryUnit.Populate();

                ////NAS.DAL.Nomenclature.Item
                ItemUnitRelationType.Populate();
                UnitType.Populate();
                Unit.Populate();
                ItemUnit.Populate();
                ItemTradingType.Populate();
                ItemCustomType.Populate();

                ////NAS.DAL.Nomenclature.Organization
                TradingCategory.Populate();
                AuthenticationProvider.Populate();
                DepartmentType.Populate();
                OrganizationType.Populate();
                Person.Populate();
                Organization.Populate();
                OwnerOrg.Populate();
                CustomerOrg.Populate();
                SupplierOrg.Populate();
                ManufacturerOrg.Populate();
                Department.Populate();
                DepartmentPerson.Populate();

                //NAS.DAL.Staging.Accounting.Journal
                AccountActorType.Populate();

                ////NAS.DAL.Vouches
                VouchesType.Populate();
                VouchesActorType.Populate();
                ReceiptVouchesType.Populate();
                PaymentVouchesType.Populate();
                ForeignCurrency.Populate();

                ////NAS.DAL.Accounting.Journal
                AccountingPeriod.Populate();
                //SalesInvoicePickingStockCart.Populate();

                ////NAS.DAL.System.ArtifactCode
                ArtifactType.Populate();
                CodeRuleDataType.Populate();
                CodeRuleDataFormat.Populate();
                RuleRepeaterType.Populate();

                //NAS.DAL.Sales.Price
                PricePolicyType.Populate();

                //NAS.DAL.Inventory.Lot.Lot
                NAS.DAL.Inventory.Lot.Lot.Populate();

                //NAS.DAL.Inventory.Command.InventoryCommandActorType
                NAS.DAL.Inventory.Command.InventoryCommandActorType.Populate();
                NAS.DAL.BI.Inventory.InventoryCommandDim.Populate();

                #region Other populate
                using (Session session = XpoHelper.GetNewSession())
                {
                    //Insert undefined supplier
                    if (!Util.isExistXpoObject <SupplierOrg>("OrganizationId",
                                                             Guid.Parse("3DEF2B62-2162-46CD-8418-DEE6F8E59E21")))
                    {
                        SupplierOrg undefinedSupplierOrg = new SupplierOrg(session)
                        {
                            OrganizationId       = Guid.Parse("3DEF2B62-2162-46CD-8418-DEE6F8E59E21"),
                            Name                 = "Mặc định",
                            Description          = "Mặc định",
                            Code                 = "MACDINH",
                            RowCreationTimeStamp = DateTime.Now,
                            RowStatus            = Constant.ROWSTATUS_ACTIVE,
                            OrganizationTypeId   =
                                NAS.DAL.Util.getDefaultXpoObject <OrganizationType>(session)
                        };
                        undefinedSupplierOrg.Save();
                    }
                }
                #endregion
            }
            catch (Exception)
            {
                throw new Exception("Populate failed");
            }
            finally
            {
            }
        }