Ejemplo n.º 1
0
        private bool AttachObjectCustomFieldWithDefaultValue(Session session
                                                             , DAL.CMS.ObjectDocument.Object CMSObject
                                                             , NAS.DAL.CMS.ObjectDocument.ObjectTypeCustomField objectTypeCustomField
                                                             , CustomFieldTypeFlag option)
        {
            try
            {
                //Create ObjectCustomField
                ObjectCustomField objectCustomField = new ObjectCustomField(session)
                {
                    ObjectCustomFieldId     = Guid.NewGuid(),
                    ObjectId                = CMSObject,
                    ObjectTypeCustomFieldId = objectTypeCustomField,
                    CustomFieldType         = option.Value
                };
                objectCustomField.Save();

                //Insert default value for custom field
                CustomFieldData customFieldData = null;

                string customFieldTypeCode = objectTypeCustomField.CustomFieldId.CustomFieldTypeId.Code;

                BasicCustomFieldTypeEnum basicCustomFieldType = BasicCustomFieldTypeEnum.NONE;

                bool isBasicType =
                    Enum.TryParse <BasicCustomFieldTypeEnum>(customFieldTypeCode, out basicCustomFieldType);

                if (isBasicType)
                {
                    customFieldData = InitDefaultDataForBasicCustomFieldType(session,
                                                                             (BasicCustomFieldTypeEnum)Enum.Parse(typeof(BasicCustomFieldTypeEnum), customFieldTypeCode),
                                                                             objectTypeCustomField.CustomFieldId.CustomFieldId);

                    if (customFieldData != null)
                    {
                        //Insert into ObjectCustomFieldData
                        ObjectCustomFieldData defaultObjectCustomFieldData =
                            new ObjectCustomFieldData(session)
                        {
                            ObjectCustomFieldDataId = Guid.NewGuid(),
                            CustomFieldDataId       = customFieldData,
                            ObjectCustomFieldId     = objectCustomField
                        };
                        defaultObjectCustomFieldData.Save();
                    }
                }
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 2
0
        public static ObjectTypeCustomField GetDefault(Session session,
                                                       DefaultObjectTypeCustomFieldEnum value)
        {
            ObjectTypeCustomField ret = null;

            try
            {
                ret = session.FindObject <ObjectTypeCustomField>(
                    new BinaryOperator("Code", Enum.GetName(typeof(DefaultObjectTypeCustomFieldEnum), value)));
                return(ret);
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 3
0
        public static void Populate()
        {
            #region Receipt Voucher
            //Populate custom field to receipt voucher
            List <CustomFieldOption> options = new List <CustomFieldOption>();
            CustomFieldOption        option  = new CustomFieldOption()
            {
                ObjectTypeFieldCode       = "RECEIPT_VOUCHER_SALE_INVOICE",
                FieldCode                 = "SALE_INVOICE",
                FieldName                 = "Phiếu bán",
                CustomFieldFlag           = CustomFieldTypeFlag.CUSTOM_FIELD_TYPE_READONLY,
                CustomFieldType           = CustomFieldTypeEnum.SINGLE_CHOICE_LIST_INVOICE_SALE,
                ObjectTypeCustomFieldFlag = CustomFieldTypeFlag.CUSTOM_FIELD_TYPE_MASTER
            };
            options.Add(option);
            /*2014-01-20 ERP-1458 Khoa.Truong INS START*/
            option = new CustomFieldOption()
            {
                ObjectTypeFieldCode       = "RECEIPT_VOUCHER_CUSTOMER",
                FieldCode                 = "CLIENT",
                FieldName                 = "Khách hàng",
                CustomFieldFlag           = CustomFieldTypeFlag.CUSTOM_FIELD_TYPE_READONLY,
                CustomFieldType           = CustomFieldTypeEnum.SINGLE_CHOICE_LIST_CUSTOMER,
                ObjectTypeCustomFieldFlag = CustomFieldTypeFlag.CUSTOM_FIELD_TYPE_READONLY
            };
            options.Add(option);
            /*2014-01-20 ERP-1458 Khoa.Truong INS END*/

            /*2014-01-22 ERP-1458 Khoa.Truong INS START*/
            option = new CustomFieldOption()
            {
                ObjectTypeFieldCode       = "RECEIPT_VOUCHER_SUPPLIER",
                FieldCode                 = "SUPPLIER",
                FieldName                 = "Nhà cung cấp",
                CustomFieldFlag           = CustomFieldTypeFlag.CUSTOM_FIELD_TYPE_READONLY,
                CustomFieldType           = CustomFieldTypeEnum.SINGLE_CHOICE_LIST_CUSTOMER,
                ObjectTypeCustomFieldFlag = CustomFieldTypeFlag.CUSTOM_FIELD_TYPE_READONLY
            };
            options.Add(option);
            /*2014-01-22 ERP-1458 Khoa.Truong INS END*/
            ObjectTypeCustomField.AttachCustomFieldsToObjectType(options, ObjectTypeEnum.VOUCHER_RECEIPT);
            #endregion

            #region Payment Voucher
            //Populate custom field to payment voucher
            options = new List <CustomFieldOption>();
            option  = new CustomFieldOption()
            {
                ObjectTypeFieldCode       = "PAYMENT_VOUCHER_PURCHASE_INVOICE",
                FieldCode                 = "PURCHASE_INVOICE",
                FieldName                 = "Phiếu mua",
                CustomFieldFlag           = CustomFieldTypeFlag.CUSTOM_FIELD_TYPE_READONLY,
                CustomFieldType           = CustomFieldTypeEnum.SINGLE_CHOICE_LIST_INVOICE_PURCHASE,
                ObjectTypeCustomFieldFlag = CustomFieldTypeFlag.CUSTOM_FIELD_TYPE_MASTER
            };
            options.Add(option);
            /*2014-01-20 ERP-1458 Khoa.Truong INS START*/
            option = new CustomFieldOption()
            {
                ObjectTypeFieldCode       = "PAYMENT_VOUCHER_SUPPLIER",
                FieldCode                 = "SUPPLIER",
                FieldName                 = "Nhà cung cấp",
                CustomFieldFlag           = CustomFieldTypeFlag.CUSTOM_FIELD_TYPE_READONLY,
                CustomFieldType           = CustomFieldTypeEnum.SINGLE_CHOICE_LIST_CUSTOMER,
                ObjectTypeCustomFieldFlag = CustomFieldTypeFlag.CUSTOM_FIELD_TYPE_READONLY
            };
            options.Add(option);
            /*2014-01-20 ERP-1458 Khoa.Truong INS END*/

            /*2014-01-22 ERP-1458 Khoa.Truong INS START*/
            option = new CustomFieldOption()
            {
                ObjectTypeFieldCode       = "PAYMENT_VOUCHER_CUSTOMER",
                FieldCode                 = "CLIENT",
                FieldName                 = "Khách hàng",
                CustomFieldFlag           = CustomFieldTypeFlag.CUSTOM_FIELD_TYPE_READONLY,
                CustomFieldType           = CustomFieldTypeEnum.SINGLE_CHOICE_LIST_CUSTOMER,
                ObjectTypeCustomFieldFlag = CustomFieldTypeFlag.CUSTOM_FIELD_TYPE_READONLY
            };
            options.Add(option);
            /*2014-01-22 ERP-1458 Khoa.Truong INS END*/

            ObjectTypeCustomField.AttachCustomFieldsToObjectType(options, ObjectTypeEnum.VOUCHER_PAYMENT);
            #endregion

            #region Inventory command
            options = new List <CustomFieldOption>();
            option  = new CustomFieldOption()
            {
                ObjectTypeFieldCode       = "INVENTORY_OUT_CLIENT",
                FieldCode                 = "CLIENT",
                FieldName                 = "Khách hàng",
                CustomFieldFlag           = CustomFieldTypeFlag.CUSTOM_FIELD_TYPE_READONLY,
                CustomFieldType           = CustomFieldTypeEnum.SINGLE_CHOICE_LIST_CUSTOMER,
                ObjectTypeCustomFieldFlag = CustomFieldTypeFlag.CUSTOM_FIELD_TYPE_READONLY
            };
            options.Add(option);
            option = new CustomFieldOption()
            {
                ObjectTypeFieldCode       = "INVENTORY_OUT_SALE_INVOICE",
                FieldCode                 = "SALE_INVOICE",
                FieldName                 = "Phiếu bán",
                CustomFieldFlag           = CustomFieldTypeFlag.CUSTOM_FIELD_TYPE_READONLY,
                CustomFieldType           = CustomFieldTypeEnum.SINGLE_CHOICE_LIST_INVOICE_SALE,
                ObjectTypeCustomFieldFlag = CustomFieldTypeFlag.CUSTOM_FIELD_TYPE_MASTER
            };
            options.Add(option);
            ObjectTypeCustomField.AttachCustomFieldsToObjectType(options, ObjectTypeEnum.INVENTORY_OUT);

            //Populate custom field to in inventory command
            options = new List <CustomFieldOption>();
            option  = new CustomFieldOption()
            {
                ObjectTypeFieldCode       = "INVENTORY_IN_CLIENT",
                FieldCode                 = "CLIENT",
                FieldName                 = "Khách hàng",
                CustomFieldFlag           = CustomFieldTypeFlag.CUSTOM_FIELD_TYPE_READONLY,
                CustomFieldType           = CustomFieldTypeEnum.SINGLE_CHOICE_LIST_CUSTOMER,
                ObjectTypeCustomFieldFlag = CustomFieldTypeFlag.CUSTOM_FIELD_TYPE_READONLY
            };
            options.Add(option);
            option = new CustomFieldOption()
            {
                ObjectTypeFieldCode       = "INVENTORY_IN_PURCHASE_INVOICE",
                FieldCode                 = "PURCHASE_INVOICE",
                FieldName                 = "Phiếu mua",
                CustomFieldFlag           = CustomFieldTypeFlag.CUSTOM_FIELD_TYPE_READONLY,
                CustomFieldType           = CustomFieldTypeEnum.SINGLE_CHOICE_LIST_INVOICE_PURCHASE,
                ObjectTypeCustomFieldFlag = CustomFieldTypeFlag.CUSTOM_FIELD_TYPE_MASTER
            };
            options.Add(option);
            ObjectTypeCustomField.AttachCustomFieldsToObjectType(options, ObjectTypeEnum.INVENTORY_IN);
            #endregion

            #region BalanceForward Inventory
            options = new List <CustomFieldOption>();
            option  = new CustomFieldOption()
            {
                ObjectTypeFieldCode       = "INVENTORY_OPEN_BALANCE",
                FieldCode                 = "INVENTORY",
                FieldName                 = "Kho đầu kỳ",
                CustomFieldFlag           = CustomFieldTypeFlag.CUSTOM_FIELD_TYPE_READONLY,
                CustomFieldType           = CustomFieldTypeEnum.SINGLE_CHOICE_LIST_INVENTORY,
                ObjectTypeCustomFieldFlag = CustomFieldTypeFlag.CUSTOM_FIELD_TYPE_MASTER
            };

            option = new CustomFieldOption()
            {
                ObjectTypeFieldCode       = "BALANCE_FORWARD_TRANSACTION_ITEM",
                FieldCode                 = "ITEM",
                FieldName                 = "Hàng hóa",
                CustomFieldFlag           = CustomFieldTypeFlag.CUSTOM_FIELD_TYPE_READONLY,
                CustomFieldType           = CustomFieldTypeEnum.SINGLE_CHOICE_LIST_ITEM,
                ObjectTypeCustomFieldFlag = CustomFieldTypeFlag.CUSTOM_FIELD_TYPE_READONLY
            };
            options.Add(option);

            ObjectTypeCustomField.AttachCustomFieldsToObjectType(options, ObjectTypeEnum.OPENBALANCE_ACCOUTING);
            #endregion

            #region Manual Booking
            options = new List <CustomFieldOption>();
            option  = new CustomFieldOption()
            {
                ObjectTypeFieldCode       = "MANUAL_BOOKING_PURCHASE_INVOICE",
                FieldCode                 = "PURCHASE_INVOICE",
                FieldName                 = "Phiếu mua",
                CustomFieldFlag           = CustomFieldTypeFlag.CUSTOM_FIELD_TYPE_READONLY,
                CustomFieldType           = CustomFieldTypeEnum.SINGLE_CHOICE_LIST_INVOICE_PURCHASE,
                ObjectTypeCustomFieldFlag = CustomFieldTypeFlag.CUSTOM_FIELD_TYPE_READONLY
            };
            options.Add(option);

            option = new CustomFieldOption()
            {
                ObjectTypeFieldCode       = "MANUAL_BOOKING_INPUT_INVENTORY_COMMAND",
                FieldCode                 = "INPUT_INVENTORY_COMMAND",
                FieldName                 = "Phiếu nhập kho",
                CustomFieldFlag           = CustomFieldTypeFlag.CUSTOM_FIELD_TYPE_READONLY,
                CustomFieldType           = CustomFieldTypeEnum.SINGLE_CHOICE_LIST_INPUT_INVENTORY_COMMAND,
                ObjectTypeCustomFieldFlag = CustomFieldTypeFlag.CUSTOM_FIELD_TYPE_READONLY
            };
            options.Add(option);

            option = new CustomFieldOption()
            {
                ObjectTypeFieldCode       = "MANUAL_BOOKING_CUSTOMER",
                FieldCode                 = "CUSTOMER",
                FieldName                 = "Khách hàng",
                CustomFieldFlag           = CustomFieldTypeFlag.CUSTOM_FIELD_TYPE_READONLY,
                CustomFieldType           = CustomFieldTypeEnum.SINGLE_CHOICE_LIST_CUSTOMER,
                ObjectTypeCustomFieldFlag = CustomFieldTypeFlag.CUSTOM_FIELD_TYPE_READONLY
            };
            options.Add(option);

            option = new CustomFieldOption()
            {
                ObjectTypeFieldCode       = "MANUAL_BOOKING_SUPPLIER",
                FieldCode                 = "SUPPLIER",
                FieldName                 = "Nhà cung cấp",
                CustomFieldFlag           = CustomFieldTypeFlag.CUSTOM_FIELD_TYPE_READONLY,
                CustomFieldType           = CustomFieldTypeEnum.SINGLE_CHOICE_LIST_SUPPLIER,
                ObjectTypeCustomFieldFlag = CustomFieldTypeFlag.CUSTOM_FIELD_TYPE_READONLY
            };
            options.Add(option);

            ObjectTypeCustomField.AttachCustomFieldsToObjectType(options, ObjectTypeEnum.MANUAL_BOOKING);

            #endregion
        }