示例#1
0
        public CodeRuleDefinition Insert(Session session, Guid artifactCodeRuleId, Guid codeRuleDataTypeId, Guid parentCodeRuleDefinitionId)
        {
            CodeRuleDefinition codeRuleDefinition = null;

            try
            {
                //Get ArtifactCodeRule
                ArtifactCodeRule artifactCodeRule =
                    session.GetObjectByKey <ArtifactCodeRule>(artifactCodeRuleId);
                //Get CodeRuleDataType
                CodeRuleDataType codeRuleDataType =
                    session.GetObjectByKey <CodeRuleDataType>(codeRuleDataTypeId);
                //Get parent CodeRuleDefinition
                CodeRuleDefinition parentCodeRuleDefinition = null;
                if (parentCodeRuleDefinitionId != Guid.Empty)
                {
                    parentCodeRuleDefinition = session.GetObjectByKey <CodeRuleDefinition>(parentCodeRuleDefinitionId);
                }
                //Validate
                bool isInsertingValid =
                    isInsertingCodeRuleDefinitionValid(session, artifactCodeRuleId, parentCodeRuleDefinition);

                if (isInsertingValid)
                {
                    //Create new CodeRuleDefinition
                    codeRuleDefinition = new CodeRuleDefinition(session)
                    {
                        ArtifactCodeRuleId         = artifactCodeRule,
                        CodeRuleDataTypeId         = codeRuleDataType,
                        CodeRuleDefinitionId       = Guid.NewGuid(),
                        ParentCodeRuleDefinitionId = parentCodeRuleDefinition,
                        RowStatus = Utility.Constant.ROWSTATUS_ACTIVE
                    };
                    codeRuleDefinition.Save();
                }

                return(codeRuleDefinition);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
示例#2
0
        public CodeRuleDefinition Update(Session session, Guid codeRuleDefinitionId, Guid codeRuleDataTypeId)
        {
            CodeRuleDefinition codeRuleDefinition = null;

            try
            {
                //Get current CodeRuleDefinition
                codeRuleDefinition = session.GetObjectByKey <CodeRuleDefinition>(codeRuleDefinitionId);
                //Get CodeRuleDataType
                CodeRuleDataType codeRuleDataType = session.GetObjectByKey <CodeRuleDataType>(codeRuleDataTypeId);
                codeRuleDefinition.CodeRuleDataTypeId = codeRuleDataType;
                codeRuleDefinition.Save();
                return(codeRuleDefinition);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
示例#3
0
        public CodeRuleData GetCodeRuleData(Session session, Guid codeRuleDefinitionId, Guid expectedCodeRuleDataTypeId)
        {
            CodeRuleData ret = null;

            try
            {
                XPQuery <CodeRuleDefinition> codeRuleDefinitionQuery = session.Query <CodeRuleDefinition>();
                var codeRuleDefinition = codeRuleDefinitionQuery
                                         .Where(r => r.CodeRuleDefinitionId == codeRuleDefinitionId && r.RowStatus > 0)
                                         .FirstOrDefault();
                CodeRuleDataType expectedCodeRuleDataType =
                    session.GetObjectByKey <CodeRuleDataType>(expectedCodeRuleDataTypeId);
                CodeRuleData tempCodeRuleData = codeRuleDefinition.CodeRuleData.FirstOrDefault(r => r.RowStatus == Utility.Constant.ROWSTATUS_ACTIVE);
                if (tempCodeRuleData.CodeRuleDataFormatId.CodeRuleDataTypeId.Equals(expectedCodeRuleDataType))
                {
                    ret = tempCodeRuleData;
                }
                return(ret);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
        protected void cpnCodeRuleDefinitionEditingForm_Callback(object sender, DevExpress.Web.ASPxClasses.CallbackEventArgsBase e)
        {
            string transition = null;
            bool   isSuccess  = false;

            try
            {
                string[] args = e.Parameter.Split('|');
                transition = args[0];

                if (transition.Equals("Edit"))
                {
                    if (args.Length > 1)
                    {
                        CodeRuleDefinitionId       = Guid.Parse(args[1]);
                        ParentCodeRuleDefinitionId = Guid.Empty;
                    }
                    else
                    {
                        throw new Exception();
                    }

                    GUIContext.State =
                        new ERPSystem.ArtifactCode.State.CodeRuleDefinitionForm.CodeRuleDefinitionEditing(this);
                    CodeRuleData codeRuleData =
                        codeRuleDataBO.GetCodeRuleData(session, CodeRuleDefinitionId);

                    CodeRuleDataId = codeRuleData.CodeRuleDataId;

                    transition =
                        GetTransitionByDataTypeCode(codeRuleData.CodeRuleDefinitionId.CodeRuleDataTypeId.Code);
                    //Request change state
                    GUIContext.Request(transition, this);
                }
                else if (transition.Equals("Create"))
                {
                    if (args.Length > 1)
                    {
                        CodeRuleDefinitionId = Guid.Empty;
                        Guid temp;
                        if (!Guid.TryParse(args[1], out temp))
                        {
                            temp = Guid.Empty;
                        }
                        ParentCodeRuleDefinitionId = temp;
                    }
                    else
                    {
                        throw new Exception();
                    }

                    GUIContext.State =
                        new ERPSystem.ArtifactCode.State.CodeRuleDefinitionForm.CodeRuleDefinitionCreating(this);

                    cbCodeRuleDataType.SelectedIndex = 0;
                    Guid             selectedCodeRuleDataTypeId = Guid.Parse(cbCodeRuleDataType.SelectedItem.Value.ToString());
                    CodeRuleDataType codeRuleDataType           =
                        session.GetObjectByKey <CodeRuleDataType>(selectedCodeRuleDataTypeId);
                    transition =
                        GetTransitionByDataTypeCode(codeRuleDataType.Code);
                    //Request change state
                    GUIContext.Request(transition, this);
                }
                else if (transition.Equals("ChangeDataType"))
                {
                    Guid             selectedCodeRuleDataTypeId = Guid.Parse(cbCodeRuleDataType.SelectedItem.Value.ToString());
                    CodeRuleDataType codeRuleDataType           =
                        session.GetObjectByKey <CodeRuleDataType>(selectedCodeRuleDataTypeId);
                    transition =
                        GetTransitionByDataTypeCode(codeRuleDataType.Code);
                    //Request change state
                    GUIContext.Request(transition, this);
                }
                else
                {
                    //Request change state
                    GUIContext.Request(transition, this);
                }

                isSuccess = true;
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                if (transition != null)
                {
                    cpnCodeRuleDefinitionEditingForm.JSProperties.Add("cpCallbackArgs",
                                                                      String.Format("{{ \"transition\": \"{0}\", \"success\": {1} }}",
                                                                                    transition, isSuccess.ToString().ToLower()));
                }
            }
        }
示例#5
0
文件: Util.cs 项目: 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
            {
            }
        }