Exemplo n.º 1
0
 protected void gridviewObjectType_CommandButtonInitialize(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewCommandButtonEventArgs e)
 {
     if (e.ButtonType == ColumnCommandButtonType.SelectCheckbox)
     {
         //Determine type of object type custom field
         //Get current object type
         var objectId = gridviewObjectType.GetRowValues(e.VisibleIndex, "ObjectTypeId");
         if (objectId != null)
         {
             NAS.DAL.CMS.ObjectDocument.CustomField customField = GetCurrentCustomField(session);
             if (customField == null)
             {
                 return;
             }
             ObjectType objectType = session.GetObjectByKey <ObjectType>((Guid)objectId);
             //Get ObjectTypeCustomField
             CriteriaOperator criteria = CriteriaOperator.And(
                 new BinaryOperator("ObjectTypeId", objectType),
                 new BinaryOperator("CustomFieldId", customField),
                 CriteriaOperator.Or(
                     new BinaryOperator("CustomFieldType", CustomFieldTypeConstant.CUSTOM_FIELD_TYPE_MASTER),
                     new BinaryOperator("CustomFieldType", CustomFieldTypeConstant.CUSTOM_FIELD_TYPE_MASTER_READONLY),
                     new BinaryOperator("CustomFieldType", CustomFieldTypeConstant.CUSTOM_FIELD_TYPE_READONLY)
                     )
                 );
             ObjectTypeCustomField objectTypeCustomField =
                 session.FindObject <ObjectTypeCustomField>(criteria);
             if (objectTypeCustomField != null)
             {
                 e.Enabled = false;
             }
         }
     }
 }
Exemplo n.º 2
0
        public bool CustomFieldCreatingHasNoInitData_PreTransitionCRUD(string transition)
        {
            switch (transition.ToUpper())
            {
            case "ACCEPT":
                if (ASPxEdit.ValidateEditorsInContainer(formlayoutGeneralInfo))
                {
                    using (UnitOfWork uow = XpoHelper.GetNewUnitOfWork())
                    {
                        Guid selectedCustomFieldTypeId =
                            Guid.Parse(cbbCustomFieldType.SelectedItem.Value.ToString());
                        CustomFieldType customFieldType =
                            uow.GetObjectByKey <CustomFieldType>(selectedCustomFieldTypeId);
                        //Create new CustomField
                        NAS.DAL.CMS.ObjectDocument.CustomField customField =
                            new NAS.DAL.CMS.ObjectDocument.CustomField(uow)
                        {
                            CustomFieldId     = Guid.NewGuid(),
                            Name              = txtCustomFieldName.Text,
                            CustomFieldTypeId = customFieldType
                        };
                        //Attach CustomField to ObjectTypeId
                        if (ObjectTypeId != null && !ObjectTypeId.Equals(Guid.Empty))
                        {
                            /*2013-12-12 Khoa.Truong DEL START
                             * Decoupling with the client using this form
                             * //Guid objectTypeId = ((ObjectTypeCustomFieldListing)Parent).ObjectTypeId;
                             * 2013-12-12 Khoa.Truong DEL END*/
                            ObjectType            objectType            = uow.GetObjectByKey <ObjectType>(ObjectTypeId);
                            ObjectTypeCustomField objectTypeCustomField = new ObjectTypeCustomField(uow)
                            {
                                ObjectTypeCustomFieldId = Guid.NewGuid(),
                                CustomFieldId           = customField,
                                ObjectTypeId            = objectType
                            };
                        }
                        //Attach new custom fields for all object of the object type

                        /*These code is replace with lazy updating for custom fields of each object
                         * //ObjectBO objectBO = new ObjectBO();
                         * //objectBO.UpdateCMSObjects(uow, objectTypeId);
                         */

                        uow.CommitChanges();
                    }
                }
                else
                {
                    return(false);
                }
                break;

            default:
                break;
            }
            return(true);
        }
Exemplo n.º 3
0
        public override XPCollection <GeneralJournal> GetActuallyCollectedOfBill(Session session, Guid billId)
        {
            try
            {
                XPCollection <GeneralJournal> ret = null;
                ObjectBO    objectBO = new ObjectBO();
                List <Guid> billIds  = new List <Guid>();
                billIds.Add(billId);

                ObjectTypeCustomField objectTypeCustomField =
                    ObjectTypeCustomField.GetDefault(session,
                                                     DefaultObjectTypeCustomFieldEnum.RECEIPT_VOUCHER_SALE_INVOICE);

                var relatedObjectList =
                    objectBO.FindCMSObjectsOfBuiltInCustomField(
                        session,
                        objectTypeCustomField.ObjectTypeCustomFieldId,
                        billIds);

                if (relatedObjectList == null)
                {
                    return(null);
                }

                var relatedObjectIdList = relatedObjectList.Select(r => r.ObjectId);

                XPCollection <ReceiptVouchesTransaction> receiptVouchesTransactions
                    = new XPCollection <ReceiptVouchesTransaction>(session,
                                                                   new BinaryOperator("RowStatus", Utility.Constant.ROWSTATUS_ACTIVE, BinaryOperatorType.GreaterOrEqual));

                CriteriaOperator criteria = CriteriaOperator.And(
                    new BinaryOperator("RowStatus", Utility.Constant.ROWSTATUS_TEMP, BinaryOperatorType.GreaterOrEqual),
                    new BinaryOperator("Debit", 0, BinaryOperatorType.Greater),
                    new ContainsOperator("GeneralJournalObjects",
                                         new InOperator("ObjectId.ObjectId", relatedObjectIdList)));

                ret = new XPCollection <GeneralJournal>(session,
                                                        receiptVouchesTransactions.SelectMany(r => r.GeneralJournals), criteria);

                //var generalJournalObjects =
                //    receiptVouchesTransactions
                //    .SelectMany(r => r.GeneralJournals)
                //    .SelectMany(r => r.GeneralJournalObjects)
                //    .Where(r => r.GeneralJournalId.RowStatus >= Utility.Constant.ROWSTATUS_TEMP
                //        && relatedObjectIdList.Contains(r.ObjectId.ObjectId));

                //ret = new XPCollection<GeneralJournal>(session,
                //    generalJournalObjects.Select(r => r.GeneralJournalId));

                return(ret);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 4
0
        public XPCollection <NAS.DAL.CMS.ObjectDocument.Object> FindCMSObjectsOfBuiltInCustomField(
            Session session,
            Guid objectTypeCustomFieldId,
            List <Guid> refIds)
        {
            try
            {
                if (refIds == null)
                {
                    return(null);
                }

                XPCollection <NAS.DAL.CMS.ObjectDocument.Object> objectList = null;
                //Get object type custom field
                ObjectTypeCustomField objectTypeCustomField =
                    session.GetObjectByKey <ObjectTypeCustomField>(objectTypeCustomFieldId);

                if (objectTypeCustomField == null)
                {
                    return(null);
                }
                if (objectTypeCustomField.ObjectCustomFields == null ||
                    objectTypeCustomField.ObjectCustomFields.Count == 0)
                {
                    return(null);
                }

                CriteriaOperator criteria =
                    new ContainsOperator("ObjectCustomFieldDatas",
                                         new InOperator("CustomFieldDataId.<PredefinitionData>RefId", refIds));

                XPCollection <ObjectCustomField> objectCustomFieldList =
                    objectTypeCustomField.ObjectCustomFields;
                objectCustomFieldList.Criteria = criteria;

                objectList =
                    new XPCollection <DAL.CMS.ObjectDocument.Object>(session,
                                                                     objectCustomFieldList.Select(r => r.ObjectId));
                //(XPCollection<NAS.DAL.CMS.ObjectDocument.Object>)
                //    objectCustomFieldList.Select(r => r.ObjectId);

                return(objectList);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Get supplier that allocated for the ReceiptVouchesTransaction
        /// </summary>
        /// <param name="session">DevExpress.Xpo.Session</param>
        /// <param name="transactionId">Id of type ReceiptVouchesTransaction</param>
        /// <returns></returns>
        public Organization GetAllocatedSupplier(Session session, Guid transactionId)
        {
            Organization ret = null;

            try
            {
                ReceiptVouchesTransaction transaction =
                    session.GetObjectByKey <ReceiptVouchesTransaction>(transactionId);
                TransactionObject transactionObject = transaction.TransactionObjects.First();
                if (transactionObject == null)
                {
                    return(null);
                }
                ObjectTypeCustomField objectTypeCustomField =
                    ObjectTypeCustomField.GetDefault(session, DefaultObjectTypeCustomFieldEnum.RECEIPT_VOUCHER_SUPPLIER);

                ObjectCustomField objectCustomField = transactionObject.ObjectId.ObjectCustomFields.Where(
                    r => r.ObjectTypeCustomFieldId.ObjectTypeCustomFieldId ==
                    objectTypeCustomField.ObjectTypeCustomFieldId).FirstOrDefault();
                if (objectCustomField == null)
                {
                    return(null);
                }

                ObjectCustomFieldData objectCustomFieldData =
                    objectCustomField.ObjectCustomFieldDatas.FirstOrDefault();
                if (objectCustomFieldData == null)
                {
                    return(null);
                }

                PredefinitionData predefinitionData =
                    (PredefinitionData)objectCustomFieldData.CustomFieldDataId;

                ret = session.GetObjectByKey <Organization>(predefinitionData.RefId);

                return(ret);
            }
            catch (Exception)
            {
                throw;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            List <CustomFieldOption> fields = new List <CustomFieldOption>();
            CustomFieldOption        field  = new CustomFieldOption();

            field.FieldName                 = "Phiếu bán";
            field.CustomFieldType           = NAS.DAL.CMS.ObjectDocument.CustomFieldTypeEnum.SINGLE_CHOICE_LIST_INVOICE_SALE;
            field.CustomFieldFlag           = CustomFieldTypeFlag.CUSTOM_FIELD_TYPE_MASTER;
            field.ObjectTypeCustomFieldFlag = CustomFieldTypeFlag.CUSTOM_FIELD_TYPE_MASTER;
            fields.Add(field);

            field                           = new CustomFieldOption();
            field.FieldName                 = "Người tạo";
            field.CustomFieldType           = NAS.DAL.CMS.ObjectDocument.CustomFieldTypeEnum.SINGLE_CHOICE_LIST_PERSON;
            field.CustomFieldFlag           = CustomFieldTypeFlag.CUSTOM_FIELD_TYPE_MASTER;
            field.ObjectTypeCustomFieldFlag = CustomFieldTypeFlag.CUSTOM_FIELD_TYPE_MASTER;
            fields.Add(field);
            ObjectTypeCustomField.AttachCustomFieldsToObjectType(fields, NAS.DAL.CMS.ObjectDocument.ObjectTypeEnum.INVENTORY_OUT);
        }
Exemplo n.º 7
0
        public InventoryCommand GetAllocatedInputInventoryCommandByManualTransaction(Session session, Guid manualBookingTransactionId)
        {
            InventoryCommand ret = null;

            try
            {
                Transaction transaction =
                    session.GetObjectByKey <Transaction>(manualBookingTransactionId);
                TransactionObject transactionObject = transaction.TransactionObjects.First();
                if (transactionObject == null)
                {
                    return(null);
                }
                ObjectTypeCustomField objectTypeCustomField =
                    ObjectTypeCustomField.GetDefault(session, DefaultObjectTypeCustomFieldEnum.MANUAL_BOOKING_INPUT_INVENTORY_COMMAND);

                ObjectCustomField objectCustomField = transactionObject.ObjectId.ObjectCustomFields.Where(
                    r => r.ObjectTypeCustomFieldId.ObjectTypeCustomFieldId ==
                    objectTypeCustomField.ObjectTypeCustomFieldId).FirstOrDefault();
                if (objectCustomField == null)
                {
                    return(null);
                }

                ObjectCustomFieldData objectCustomFieldData =
                    objectCustomField.ObjectCustomFieldDatas.FirstOrDefault();
                if (objectCustomFieldData == null)
                {
                    return(null);
                }

                PredefinitionData predefinitionData =
                    (PredefinitionData)objectCustomFieldData.CustomFieldDataId;

                ret = session.GetObjectByKey <InventoryCommand>(predefinitionData.RefId);

                return(ret);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 8
0
        public NAS.DAL.Invoice.PurchaseInvoice GetAllocatedPurchaseInvoiceByInventoryCommand(Session session, Guid inventoryCommandId)
        {
            NAS.DAL.Invoice.PurchaseInvoice ret = null;
            try
            {
                InventoryCommand command =
                    session.GetObjectByKey <InventoryCommand>(inventoryCommandId);
                InventoryCommandObject commandObject = command.InventoryCommandObjects.First();
                if (commandObject == null)
                {
                    return(null);
                }
                ObjectTypeCustomField objectTypeCustomField =
                    ObjectTypeCustomField.GetDefault(session, DefaultObjectTypeCustomFieldEnum.INVENTORY_IN_PURCHASE_INVOICE);

                ObjectCustomField objectCustomField = commandObject.ObjectId.ObjectCustomFields.Where(
                    r => r.ObjectTypeCustomFieldId.ObjectTypeCustomFieldId ==
                    objectTypeCustomField.ObjectTypeCustomFieldId).FirstOrDefault();
                if (objectCustomField == null)
                {
                    return(null);
                }

                ObjectCustomFieldData objectCustomFieldData =
                    objectCustomField.ObjectCustomFieldDatas.FirstOrDefault();
                if (objectCustomFieldData == null)
                {
                    return(null);
                }

                PredefinitionData predefinitionData =
                    (PredefinitionData)objectCustomFieldData.CustomFieldDataId;

                ret = session.GetObjectByKey <NAS.DAL.Invoice.PurchaseInvoice>(predefinitionData.RefId);

                return(ret);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 9
0
        public NAS.DAL.Invoice.PurchaseInvoice GetAllocatedPurchaseInvoiceByManualTransaction(Session session, Guid manualBookingTransactionId)
        {
            NAS.DAL.Invoice.PurchaseInvoice ret = null;
            try
            {
                Transaction transaction =
                    session.GetObjectByKey <Transaction>(manualBookingTransactionId);
                TransactionObject transactionObject = transaction.TransactionObjects.First();
                if (transactionObject == null)
                {
                    return(null);
                }
                ObjectTypeCustomField objectTypeCustomField =
                    ObjectTypeCustomField.GetDefault(session, DefaultObjectTypeCustomFieldEnum.MANUAL_BOOKING_PURCHASE_INVOICE);

                ObjectCustomField objectCustomField = transactionObject.ObjectId.ObjectCustomFields.Where(
                    r => r.ObjectTypeCustomFieldId.ObjectTypeCustomFieldId ==
                    objectTypeCustomField.ObjectTypeCustomFieldId).FirstOrDefault();
                if (objectCustomField == null)
                {
                    return(null);
                }

                ObjectCustomFieldData objectCustomFieldData =
                    objectCustomField.ObjectCustomFieldDatas.FirstOrDefault();
                if (objectCustomFieldData == null)
                {
                    return(null);
                }

                PredefinitionData predefinitionData =
                    (PredefinitionData)objectCustomFieldData.CustomFieldDataId;

                ret = session.GetObjectByKey <NAS.DAL.Invoice.PurchaseInvoice>(predefinitionData.RefId);

                return(ret);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 10
0
        public NAS.DAL.Nomenclature.Organization.Organization GetAllocatedCustomerByManualTransaction(Session session, Guid manualBookingTransactionId)
        {
            NAS.DAL.Nomenclature.Organization.Organization ret = null;
            try
            {
                Transaction transaction =
                    session.GetObjectByKey <Transaction>(manualBookingTransactionId);
                TransactionObject transactionObject = transaction.TransactionObjects.First();
                if (transactionObject == null)
                {
                    return(null);
                }
                ObjectTypeCustomField objectTypeCustomField =
                    ObjectTypeCustomField.GetDefault(session, DefaultObjectTypeCustomFieldEnum.MANUAL_BOOKING_CUSTOMER);

                ObjectCustomField objectCustomField = transactionObject.ObjectId.ObjectCustomFields.Where(
                    r => r.ObjectTypeCustomFieldId.ObjectTypeCustomFieldId ==
                    objectTypeCustomField.ObjectTypeCustomFieldId).FirstOrDefault();
                if (objectCustomField == null)
                {
                    return(null);
                }

                ObjectCustomFieldData objectCustomFieldData =
                    objectCustomField.ObjectCustomFieldDatas.FirstOrDefault();
                if (objectCustomFieldData == null)
                {
                    return(null);
                }

                PredefinitionData predefinitionData =
                    (PredefinitionData)objectCustomFieldData.CustomFieldDataId;

                ret = session.GetObjectByKey <NAS.DAL.Nomenclature.Organization.Organization>(predefinitionData.RefId);

                return(ret);
            }
            catch (Exception)
            {
                return(null);
            }
        }
Exemplo n.º 11
0
        private void LinkVoucherWithBill(Session _session, Guid _billId, Vouches voucher)
        {
            ObjectCustomFieldBO objectCustomFieldBO = new ObjectCustomFieldBO();

            ObjectTypeCustomField defaultObjectTypeCustomField =
                ObjectTypeCustomField.GetDefault(_session, DefaultObjectTypeCustomFieldEnum.RECEIPT_VOUCHER_SALE_INVOICE);

            ObjectCustomField objectCustomField = voucher.VoucherObjects.First().ObjectId.ObjectCustomFields
                                                  .Where(r => r.ObjectTypeCustomFieldId.Equals(defaultObjectTypeCustomField)).First();

            List <Guid> billId = new List <Guid>();

            billId.Add(_billId);

            objectCustomFieldBO.UpdatePredefinitionData(
                objectCustomField.ObjectCustomFieldId,
                billId,
                PredefinitionCustomFieldTypeEnum.SINGLE_CHOICE_LIST_INVOICE_SALE,
                CustomFieldTypeFlag.CUSTOM_FIELD_TYPE_MASTER_READONLY);
        }
Exemplo n.º 12
0
        public override XPCollection <Transaction> GetRelatedTransactionsWithBill(Session session, Guid billId)
        {
            try
            {
                XPCollection <Transaction> ret = null;
                ObjectBO    objectBO           = new ObjectBO();
                List <Guid> billIds            = new List <Guid>();
                billIds.Add(billId);

                ObjectTypeCustomField objectTypeCustomField =
                    ObjectTypeCustomField.GetDefault(session,
                                                     DefaultObjectTypeCustomFieldEnum.RECEIPT_VOUCHER_SALE_INVOICE);

                var relatedObjectList =
                    objectBO.FindCMSObjectsOfBuiltInCustomField(
                        session,
                        objectTypeCustomField.ObjectTypeCustomFieldId,
                        billIds);

                if (relatedObjectList == null)
                {
                    return(null);
                }

                var relatedObjectIdList = relatedObjectList.Select(r => r.ObjectId);

                CriteriaOperator criteria = CriteriaOperator.And(
                    new BinaryOperator("RowStatus", Utility.Constant.ROWSTATUS_ACTIVE, BinaryOperatorType.GreaterOrEqual),
                    new ContainsOperator("TransactionObjects",
                                         new InOperator("ObjectId.ObjectId", relatedObjectIdList)));

                ret = new XPCollection <Transaction>(session,
                                                     new XPCollection <ReceiptVouchesTransaction>(session), criteria);

                return(ret);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 13
0
        public bool CustomFieldDataCreating_PreTransitionCRUD(string transition)
        {
            switch (transition.ToUpper())
            {
            case "ACCEPT":
                using (UnitOfWork uow = XpoHelper.GetNewUnitOfWork())
                {
                    //Get creating custom field
                    NAS.DAL.CMS.ObjectDocument.CustomField customField =
                        uow.GetObjectByKey <NAS.DAL.CMS.ObjectDocument.CustomField>(CustomFieldId);
                    //Attach CustomField to ObjectTypeId
                    if (ObjectTypeId != null && !ObjectTypeId.Equals(Guid.Empty))
                    {
                        /*2013-12-12 Khoa.Truong DEL START
                         * Decoupling with the client using this form
                         * //Guid objectTypeId = ((ObjectTypeCustomFieldListing)Parent).ObjectTypeId;
                         * 2013-12-12 Khoa.Truong DEL END*/
                        ObjectType            objectType            = uow.GetObjectByKey <ObjectType>(ObjectTypeId);
                        ObjectTypeCustomField objectTypeCustomField = new ObjectTypeCustomField(uow)
                        {
                            ObjectTypeCustomFieldId = Guid.NewGuid(),
                            CustomFieldId           = customField,
                            ObjectTypeId            = objectType
                        };
                    }

                    /*These code is replace with lazy updating for custom fields of each object
                     * ////Attach new custom fields for all object of the object type
                     * //ObjectBO objectBO = new ObjectBO();
                     * //objectBO.UpdateCMSObjects(uow, objectTypeId);
                     */
                    uow.CommitChanges();
                }
                break;

            default:
                break;
            }
            return(true);
        }
Exemplo n.º 14
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
            {
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// Lấy chứng từ phiếu gốc của phiếu xuất/nhập/chuyển kho
        /// </summary>
        /// <param name="uow"></param>
        /// <param name="_InventoryCommandId"></param>
        /// <returns></returns>
        public Bill GetSourceArtifactFromInventoryCommand(
            UnitOfWork uow,
            Guid _InventoryCommandId)
        {
            InventoryCommand command = uow.GetObjectByKey <InventoryCommand>(_InventoryCommandId);

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

            ObjectTypeCustomField ArtifactTypeCustomField = null;
            ObjectCustomField     ArtifactCustomField     = null;
            Bill billArtifact = null;

            if (command.CommandType.Equals(INVENTORY_COMMAND_TYPE.OUT))
            {
                ArtifactTypeCustomField =
                    ObjectTypeCustomField.GetDefault(uow, DefaultObjectTypeCustomFieldEnum.INVENTORY_OUT_SALE_INVOICE);
                try
                {
                    ArtifactCustomField = command.InventoryCommandObjects.First().ObjectId.ObjectCustomFields
                                          .Where(r => r.ObjectTypeCustomFieldId.Equals(ArtifactTypeCustomField)).First();
                }
                catch (Exception)
                {
                    if (ArtifactCustomField == null)
                    {
                        return(null);
                    }
                }
            }
            else if (command.CommandType.Equals(INVENTORY_COMMAND_TYPE.IN))
            {
                ArtifactTypeCustomField =
                    ObjectTypeCustomField.GetDefault(uow, DefaultObjectTypeCustomFieldEnum.INVENTORY_IN_PURCHASE_INVOICE);
                try
                {
                    //ArtifactCustomField = command.InventoryCommandObjects.First().ObjectId.ObjectCustomFields
                    //.Where(r => r.ObjectTypeCustomFieldId.Equals(ArtifactTypeCustomField)).First();

                    foreach (ObjectCustomField cf in command.InventoryCommandObjects.First().ObjectId.ObjectCustomFields)
                    {
                        if (cf.ObjectTypeCustomFieldId.Code != null && cf.ObjectTypeCustomFieldId.Code.Equals(ArtifactTypeCustomField.Code))
                        {
                            ArtifactCustomField = cf;
                        }
                    }
                }
                catch (Exception)
                {
                    if (ArtifactCustomField == null)
                    {
                        return(null);
                    }
                }
            }
            else
            {
                return(null);
            }

            if (ArtifactCustomField != null)
            {
                try
                {
                    billArtifact = uow.GetObjectByKey <Bill>((ArtifactCustomField.ObjectCustomFieldDatas.First().CustomFieldDataId as PredefinitionData).RefId);
                }
                catch (Exception)
                {
                    billArtifact = null;
                }
            }
            return(billArtifact);
        }
Exemplo n.º 16
0
        protected void customFieldDataGridView_DataUpdated(object sender,
                                                           ERPSystem.CustomField.GUI.Control.CustomFieldControlEventArgs args)
        {
            using (UnitOfWork uow = XpoHelper.GetNewUnitOfWork())
            {
                //Get all journal of transaction
                NAS.DAL.Accounting.Journal.Transaction transaction =
                    uow.GetObjectByKey <NAS.DAL.Accounting.Journal.Transaction>(TransactionId);
                var cmsObjects =
                    transaction.GeneralJournals
                    .Where(r => r.RowStatus >= 0)
                    .Select(r => r.GeneralJournalObjects.FirstOrDefault())
                    .Select(r => r.ObjectId);

                ObjectTypeCustomField objectTypeCustomField =
                    uow.GetObjectByKey <ObjectTypeCustomField>(args.ObjectTypeCustomFieldId);

                if (cmsObjects != null)
                {
                    ObjectCustomFieldBO objectCustomFieldBO = new ObjectCustomFieldBO();
                    foreach (var cmsObject in cmsObjects)
                    {
                        ObjectCustomField objectCustomField =
                            cmsObject.ObjectCustomFields
                            .Where(r => r.ObjectTypeCustomFieldId == objectTypeCustomField)
                            .FirstOrDefault();
                        if (objectCustomField != null)
                        {
                            //Copy new data to all jounal of the transaction
                            switch (args.CustomFieldCategory)
                            {
                            case CustomFieldControlEventArgs.CustomFieldCategoryEnum.BASIC:
                                objectCustomFieldBO.UpdateBasicData(
                                    objectCustomField.ObjectCustomFieldId,
                                    args.NewBasicDataValue,
                                    args.BasicCustomFieldType);
                                break;

                            case CustomFieldControlEventArgs.CustomFieldCategoryEnum.LIST:
                                objectCustomFieldBO.UpdateUserDefinedListData(
                                    objectCustomField.ObjectCustomFieldId,
                                    args.NewCustomFieldDataIds);
                                break;

                            case CustomFieldControlEventArgs.CustomFieldCategoryEnum.BUILT_IN:
                                NASCustomFieldPredefinitionData temp = args.NewBuiltInData.FirstOrDefault();
                                if (temp != null)
                                {
                                    PredefinitionCustomFieldTypeEnum predefinitionType =
                                        (PredefinitionCustomFieldTypeEnum)Enum
                                        .Parse(typeof(PredefinitionCustomFieldTypeEnum), temp.PredefinitionType);
                                    objectCustomFieldBO.UpdatePredefinitionData(
                                        objectCustomField.ObjectCustomFieldId,
                                        args.NewBuiltInData.Select(r => r.RefId).ToList(),
                                        predefinitionType);
                                }
                                break;

                            default:
                                break;
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 17
0
        protected void popupCustomFieldAttachment_WindowCallback(object source, DevExpress.Web.ASPxPopupControl.PopupWindowCallbackArgs e)
        {
            try
            {
                string[] args = e.Parameter.Split('|');
                NAS.DAL.CMS.ObjectDocument.CustomField customField = null;
                string command = args[0];
                switch (command)
                {
                    #region AttachTo
                case "AttachTo":
                    //Get CustomField
                    if (args.Length > 1)
                    {
                        CustomFieldId = Guid.Parse(args[1]);
                    }
                    else
                    {
                        throw new Exception("Invalid parameter");
                    }
                    customField = GetCurrentCustomField(session);

                    //Bind data to form
                    formlayoutCustomFieldAttachment_DataBind();

                    /////Set Selection for gridview
                    gridviewObjectType.Selection.UnselectAll();
                    if (customField.ObjectTypeCustomFields != null)
                    {
                        foreach (var objectTypeCustomField in customField.ObjectTypeCustomFields)
                        {
                            gridviewObjectType.Selection
                            .SetSelectionByKey(objectTypeCustomField.ObjectTypeId.ObjectTypeId, true);
                        }
                    }
                    break;
                    #endregion

                    #region Save
                case "Save":
                    using (UnitOfWork uow = XpoHelper.GetNewUnitOfWork())
                    {
                        //Delete all object type custom field which it's type is not master and system
                        customField = GetCurrentCustomField(uow);
                        var userDefinedObjectTypeCustomFields = customField.ObjectTypeCustomFields.Where(r =>
                                                                                                         !r.CustomFieldType.Equals(CustomFieldTypeConstant.CUSTOM_FIELD_TYPE_MASTER) &&
                                                                                                         !r.CustomFieldType.Equals(CustomFieldTypeConstant.CUSTOM_FIELD_TYPE_MASTER_READONLY) &&
                                                                                                         !r.CustomFieldType.Equals(CustomFieldTypeConstant.CUSTOM_FIELD_TYPE_READONLY)).ToList();
                        uow.Delete(userDefinedObjectTypeCustomFields);
                        //Get selection to save
                        var selectedObjectTypeIds = gridviewObjectType.GetSelectedFieldValues("ObjectTypeId")
                                                    .Select(r => Guid.Parse(r.ToString()));

                        //Update object custom field table
                        foreach (var selectedObjectTypeId in selectedObjectTypeIds)
                        {
                            //Check exist
                            int count = customField.ObjectTypeCustomFields.Where(r =>
                                                                                 r.CustomFieldType.Equals(CustomFieldTypeConstant.CUSTOM_FIELD_TYPE_MASTER) ||
                                                                                 r.CustomFieldType.Equals(CustomFieldTypeConstant.CUSTOM_FIELD_TYPE_MASTER_READONLY) ||
                                                                                 r.CustomFieldType.Equals(CustomFieldTypeConstant.CUSTOM_FIELD_TYPE_READONLY))
                                        .Count(r => r.ObjectTypeId.ObjectTypeId == selectedObjectTypeId);
                            if (count != 0)
                            {
                                continue;
                            }
                            //get ObjectType
                            ObjectType objectType = uow.GetObjectByKey <ObjectType>(selectedObjectTypeId);
                            //Create new ObjectTypeCustomField
                            ObjectTypeCustomField objectTypeCustomField = new ObjectTypeCustomField(uow)
                            {
                                CustomFieldId = customField,
                                ObjectTypeId  = objectType
                            };
                            objectTypeCustomField.Save();
                        }
                        uow.CommitChanges();
                    }
                    break;
                    #endregion

                default:
                    break;
                }
            }
            catch (Exception)
            {
                throw;
            }
        }