Exemple #1
0
        public bool NASCustomFieldTypeBuiltInSingleSelectionListControlDataViewingState_CRUD()
        {
            NASCustomFieldPredefinitionData predefinitionData =
                NASCustomFieldTypeBuiltInSingleSelectionListStrategy.GetPredefinitionDataOfObject(ObjectCustomFieldId);
            string text = String.Empty;

            if (predefinitionData != null)
            {
                text = predefinitionData.Name == null || predefinitionData.Name.Trim().Length == 0 ?
                       predefinitionData.Code : predefinitionData.Name;
                imgRemove.Visible = true;
            }
            else
            {
                text = "Chỉnh sửa";
                imgRemove.Visible = false;
            }
            hyperlinkBuiltInSingleSelectionListDataViewing.Text = text;

            ObjectCustomField objectCustomField =
                session.GetObjectByKey <ObjectCustomField>(ObjectCustomFieldId);

            //////12/22/2013 Duc.Vo----START
            /// Dump - null object khi ko co du lieu cho CustomFieldType
            ////////////////////////////////
            if (objectCustomField.CustomFieldType == null)
            {
                objectCustomField.CustomFieldType = CustomFieldTypeFlag.CUSTOM_FIELD_TYPE_DEFAULT.Value;
                objectCustomField.Save();
            }
            //////12/22/2013 Duc.Vo----END
            if (objectCustomField.CustomFieldType.Equals(CustomFieldTypeFlag.CUSTOM_FIELD_TYPE_MASTER.Value))
            {
                hyperlinkBuiltInSingleSelectionListDataViewing.Font.Bold = true;
                imgRemove.Visible = false;
            }
            else if (objectCustomField.CustomFieldType.Equals(CustomFieldTypeFlag.CUSTOM_FIELD_TYPE_READONLY.Value))
            {
                hyperlinkBuiltInSingleSelectionListDataViewing.ClientSideEvents.Click = null;
                hyperlinkBuiltInSingleSelectionListDataViewing.Cursor    = "default";
                hyperlinkBuiltInSingleSelectionListDataViewing.ForeColor = Color.Gray;
                imgRemove.Visible = false;
            }
            else if (objectCustomField.CustomFieldType.Equals(CustomFieldTypeFlag.CUSTOM_FIELD_TYPE_MASTER_READONLY.Value))
            {
                hyperlinkBuiltInSingleSelectionListDataViewing.ClientSideEvents.Click = null;
                hyperlinkBuiltInSingleSelectionListDataViewing.Cursor    = "default";
                hyperlinkBuiltInSingleSelectionListDataViewing.ForeColor = Color.Gray;
                hyperlinkBuiltInSingleSelectionListDataViewing.Font.Bold = true;
                imgRemove.Visible = false;
            }

            return(true);
        }
        public override List <NASCustomFieldPredefinitionData> GetSelectedPredefinitionDataFromList(object source)
        {
            List <NASCustomFieldPredefinitionData> ret = null;
            Session session = null;

            try
            {
                session = XpoHelper.GetNewSession();

                ASPxGridLookup gridlookup = source as ASPxGridLookup;

                var selectedIds = gridlookup.GridView
                                  .GetSelectedFieldValues("OrganizationId")
                                  .Select(r => Guid.Parse(r.ToString()));

                if (selectedIds != null)
                {
                    ret = new List <NASCustomFieldPredefinitionData>();
                    foreach (var Id in selectedIds)
                    {
                        Organization organization =
                            session.GetObjectByKey <Organization>(Id);

                        if (organization != null)
                        {
                            NASCustomFieldPredefinitionData retItem = new NASCustomFieldPredefinitionData()
                            {
                                Code              = organization.Code,
                                Description       = organization.Description,
                                Name              = organization.Name,
                                PredefinitionType = Enum.GetName(typeof(MultiSelectionBuiltInTypeEnum),
                                                                 MultiSelectionBuiltInTypeEnum.MULTI_CHOICE_LIST_SUPPLIER),
                                RefId = organization.OrganizationId
                            };
                            ret.Add(retItem);
                        }
                    }
                }
                return(ret);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (session != null)
                {
                    session.Dispose();
                }
            }
        }
Exemple #3
0
        public override List <NASCustomFieldPredefinitionData> GetSelectedPredefinitionDataFromList(object source)
        {
            List <NASCustomFieldPredefinitionData> ret = null;
            Session session = null;

            try
            {
                session = XpoHelper.GetNewSession();

                ASPxGridLookup gridlookup = source as ASPxGridLookup;

                var selectedIds = gridlookup.GridView
                                  .GetSelectedFieldValues("BillId")
                                  .Select(r => Guid.Parse(r.ToString()));

                if (selectedIds != null)
                {
                    ret = new List <NASCustomFieldPredefinitionData>();
                    foreach (var Id in selectedIds)
                    {
                        PurchaseInvoice purchaseInvoice =
                            session.GetObjectByKey <PurchaseInvoice>(Id);

                        if (purchaseInvoice != null)
                        {
                            NASCustomFieldPredefinitionData retItem = new NASCustomFieldPredefinitionData()
                            {
                                Code              = purchaseInvoice.Code,
                                Description       = String.Empty,
                                Name              = String.Empty,
                                PredefinitionType = Enum.GetName(typeof(MultiSelectionBuiltInTypeEnum),
                                                                 MultiSelectionBuiltInTypeEnum.MULTI_CHOICE_LIST_INVOICE_PURCHASE),
                                RefId = purchaseInvoice.BillId
                            };
                            ret.Add(retItem);
                        }
                    }
                }
                return(ret);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (session != null)
                {
                    session.Dispose();
                }
            }
        }
        public override List <NASCustomFieldPredefinitionData> GetPredefinitionDataOfObject(Guid objectCustomFieldId)
        {
            List <NASCustomFieldPredefinitionData> ret = null;
            Session session = null;

            try
            {
                session = XpoHelper.GetNewSession();

                ObjectCustomField objectCustomField = session.GetObjectByKey <ObjectCustomField>(objectCustomFieldId);

                if (objectCustomField.ObjectCustomFieldDatas != null)
                {
                    ret = new List <NASCustomFieldPredefinitionData>();

                    foreach (var data in objectCustomField.ObjectCustomFieldDatas)
                    {
                        PredefinitionData predefinitionData = (PredefinitionData)data.CustomFieldDataId;

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

                        if (organization != null)
                        {
                            NASCustomFieldPredefinitionData retItem = new NASCustomFieldPredefinitionData()
                            {
                                Code              = organization.Code,
                                Description       = organization.Description,
                                Name              = organization.Name,
                                PredefinitionType = Enum.GetName(typeof(MultiSelectionBuiltInTypeEnum),
                                                                 MultiSelectionBuiltInTypeEnum.MULTI_CHOICE_LIST_CUSTOMER),
                                RefId = organization.OrganizationId
                            };
                            ret.Add(retItem);
                        }
                    }
                }
                return(ret);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (session != null)
                {
                    session.Dispose();
                }
            }
        }
        public override List <NASCustomFieldPredefinitionData> GetPredefinitionDataOfObject(Guid objectCustomFieldId)
        {
            List <NASCustomFieldPredefinitionData> ret = null;
            Session session = null;

            try
            {
                session = XpoHelper.GetNewSession();

                ObjectCustomField objectCustomField = session.GetObjectByKey <ObjectCustomField>(objectCustomFieldId);

                if (objectCustomField.ObjectCustomFieldDatas != null)
                {
                    ret = new List <NASCustomFieldPredefinitionData>();

                    foreach (var data in objectCustomField.ObjectCustomFieldDatas)
                    {
                        PredefinitionData predefinitionData = (PredefinitionData)data.CustomFieldDataId;

                        SalesInvoice salesInvoice =
                            session.GetObjectByKey <SalesInvoice>(predefinitionData.RefId);

                        if (salesInvoice != null)
                        {
                            NASCustomFieldPredefinitionData retItem = new NASCustomFieldPredefinitionData()
                            {
                                Code              = salesInvoice.Code,
                                Description       = String.Empty,
                                Name              = String.Empty,
                                PredefinitionType = Enum.GetName(typeof(MultiSelectionBuiltInTypeEnum),
                                                                 MultiSelectionBuiltInTypeEnum.MULTI_CHOICE_LIST_INVOICE_SALE),
                                RefId = salesInvoice.BillId
                            };
                            ret.Add(retItem);
                        }
                    }
                }
                return(ret);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (session != null)
                {
                    session.Dispose();
                }
            }
        }
Exemple #6
0
        public override NASCustomFieldPredefinitionData GetSelectedPredefinitionDataFromList(object source)
        {
            NASCustomFieldPredefinitionData ret = null;
            Session session = null;

            try
            {
                ASPxComboBox combo = source as ASPxComboBox;
                session = XpoHelper.GetNewSession();

                if (combo.Value == null)
                {
                    return(null);
                }

                Guid customerId = (Guid)combo.Value;

                Organization customer =
                    session.GetObjectByKey <Organization>(customerId);

                if (customer != null)
                {
                    ret = new NASCustomFieldPredefinitionData()
                    {
                        Code              = customer.Code,
                        Description       = customer.Description,
                        Name              = customer.Name,
                        PredefinitionType = Enum.GetName(typeof(SingleSelectionBuiltInTypeEnum),
                                                         SingleSelectionBuiltInTypeEnum.SINGLE_CHOICE_LIST_CUSTOMER),
                        RefId = customer.OrganizationId
                    };
                }

                return(ret);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (session != null)
                {
                    session.Dispose();
                }
            }
        }
        public override NASCustomFieldPredefinitionData GetSelectedPredefinitionDataFromList(object source)
        {
            NASCustomFieldPredefinitionData ret = null;
            Session session = null;

            try
            {
                ASPxComboBox combo = source as ASPxComboBox;
                session = XpoHelper.GetNewSession();

                if (combo.Value == null)
                {
                    return(null);
                }

                Guid salesInvoiceId = (Guid)combo.Value;

                SalesInvoice salesInvoice =
                    session.GetObjectByKey <SalesInvoice>(salesInvoiceId);

                if (salesInvoice != null)
                {
                    ret = new NASCustomFieldPredefinitionData()
                    {
                        Code              = salesInvoice.Code,
                        Description       = String.Empty,
                        Name              = String.Empty,
                        PredefinitionType = Enum.GetName(typeof(SingleSelectionBuiltInTypeEnum),
                                                         SingleSelectionBuiltInTypeEnum.SINGLE_CHOICE_LIST_INVOICE_SALE),
                        RefId = salesInvoice.BillId
                    };
                }

                return(ret);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (session != null)
                {
                    session.Dispose();
                }
            }
        }
        public override NASCustomFieldPredefinitionData GetSelectedPredefinitionDataFromList(object source)
        {
            NASCustomFieldPredefinitionData ret = null;
            Session session = null;

            try
            {
                ASPxComboBox combo = source as ASPxComboBox;
                session = XpoHelper.GetNewSession();

                if (combo.Value == null)
                {
                    return(null);
                }

                Guid commandId = (Guid)combo.Value;

                InventoryCommand command =
                    session.GetObjectByKey <InventoryCommand>(commandId);

                if (command != null)
                {
                    ret = new NASCustomFieldPredefinitionData()
                    {
                        Code              = command.Code,
                        Description       = command.Description,
                        Name              = command.Name,
                        PredefinitionType = Enum.GetName(typeof(SingleSelectionBuiltInTypeEnum),
                                                         SingleSelectionBuiltInTypeEnum.SINGLE_CHOICE_LIST_INPUT_INVENTORY_COMMAND),
                        RefId = command.InventoryCommandId
                    };
                }

                return(ret);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (session != null)
                {
                    session.Dispose();
                }
            }
        }
Exemple #9
0
        public override NASCustomFieldPredefinitionData GetSelectedPredefinitionDataFromList(object source)
        {
            NASCustomFieldPredefinitionData ret = null;
            Session session = null;

            try
            {
                ASPxComboBox combo = source as ASPxComboBox;
                session = XpoHelper.GetNewSession();

                if (combo.Value == null)
                {
                    return(null);
                }

                Guid supplierId = (Guid)combo.Value;

                Lot lot = session.GetObjectByKey <Lot>(supplierId);

                if (lot != null)
                {
                    ret = new NASCustomFieldPredefinitionData()
                    {
                        Code              = lot.Code,
                        Description       = String.Empty,
                        Name              = lot.Description,
                        PredefinitionType = Enum.GetName(typeof(SingleSelectionBuiltInTypeEnum),
                                                         SingleSelectionBuiltInTypeEnum.SINGLE_CHOICE_LIST_LOT),
                        RefId = lot.LotId
                    };
                }

                return(ret);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (session != null)
                {
                    session.Dispose();
                }
            }
        }
Exemple #10
0
        public override NASCustomFieldPredefinitionData GetPredefinitionDataOfObject(Guid objectCustomFieldId)
        {
            NASCustomFieldPredefinitionData ret = null;
            Session session = null;

            try
            {
                session = XpoHelper.GetNewSession();
                ObjectCustomFieldData objectCustomFieldData =
                    session.GetObjectByKey <ObjectCustomField>(objectCustomFieldId).ObjectCustomFieldDatas.FirstOrDefault();
                if (objectCustomFieldData != null)
                {
                    PredefinitionData predefinitionData =
                        (PredefinitionData)objectCustomFieldData.CustomFieldDataId;

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

                    if (customer != null)
                    {
                        ret = new NASCustomFieldPredefinitionData()
                        {
                            Code              = customer.Code,
                            Description       = customer.Description,
                            Name              = customer.Name,
                            PredefinitionType = Enum.GetName(typeof(SingleSelectionBuiltInTypeEnum),
                                                             SingleSelectionBuiltInTypeEnum.SINGLE_CHOICE_LIST_CUSTOMER),
                            RefId = customer.OrganizationId
                        };
                    }
                }
                return(ret);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (session != null)
                {
                    session.Dispose();
                }
            }
        }
        public override NASCustomFieldPredefinitionData GetPredefinitionDataOfObject(Guid objectCustomFieldId)
        {
            NASCustomFieldPredefinitionData ret = null;
            Session session = null;

            try
            {
                session = XpoHelper.GetNewSession();
                ObjectCustomFieldData objectCustomFieldData =
                    session.GetObjectByKey <ObjectCustomField>(objectCustomFieldId).ObjectCustomFieldDatas.FirstOrDefault();
                if (objectCustomFieldData != null)
                {
                    PredefinitionData predefinitionData =
                        (PredefinitionData)objectCustomFieldData.CustomFieldDataId;

                    SalesInvoice salesInvoice =
                        session.GetObjectByKey <SalesInvoice>(predefinitionData.RefId);

                    if (salesInvoice != null)
                    {
                        ret = new NASCustomFieldPredefinitionData()
                        {
                            Code              = salesInvoice.Code,
                            Description       = String.Empty,
                            Name              = String.Empty,
                            PredefinitionType = Enum.GetName(typeof(SingleSelectionBuiltInTypeEnum),
                                                             SingleSelectionBuiltInTypeEnum.SINGLE_CHOICE_LIST_INVOICE_SALE),
                            RefId = salesInvoice.BillId
                        };
                    }
                }
                return(ret);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (session != null)
                {
                    session.Dispose();
                }
            }
        }
        public override NASCustomFieldPredefinitionData GetPredefinitionDataOfObject(Guid objectCustomFieldId)
        {
            NASCustomFieldPredefinitionData ret = null;
            Session session = null;

            try
            {
                session = XpoHelper.GetNewSession();
                ObjectCustomFieldData objectCustomFieldData =
                    session.GetObjectByKey <ObjectCustomField>(objectCustomFieldId).ObjectCustomFieldDatas.FirstOrDefault();
                if (objectCustomFieldData != null)
                {
                    PredefinitionData predefinitionData =
                        (PredefinitionData)objectCustomFieldData.CustomFieldDataId;

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

                    if (command != null)
                    {
                        ret = new NASCustomFieldPredefinitionData()
                        {
                            Code              = command.Code,
                            Description       = command.Description,
                            Name              = command.Name,
                            PredefinitionType = Enum.GetName(typeof(SingleSelectionBuiltInTypeEnum),
                                                             SingleSelectionBuiltInTypeEnum.SINGLE_CHOICE_LIST_INPUT_INVENTORY_COMMAND),
                            RefId = command.InventoryCommandId
                        };
                    }
                }
                return(ret);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (session != null)
                {
                    session.Dispose();
                }
            }
        }
Exemple #13
0
        public bool NASCustomFieldTypeBuiltInSingleSelectionListControlDataEditingState_CRUD()
        {
            NASCustomFieldPredefinitionData predefinitionData =
                NASCustomFieldTypeBuiltInSingleSelectionListStrategy.GetPredefinitionDataOfObject(ObjectCustomFieldId);

            if (predefinitionData != null)
            {
                cboBuiltInSingleSelectionList.Value = predefinitionData.RefId;
                cboBuiltInSingleSelectionList.DataBindItems();
                //imgRemove.Visible = true;
            }
            else
            {
                cboBuiltInSingleSelectionList.SelectedIndex = -1;
                //imgRemove.Visible = false;
            }
            imgRemove.Visible = false;
            return(true);
        }
Exemple #14
0
 public bool NASCustomFieldTypeBuiltInSingleSelectionListControlDataEditingState_PreTransitionCRUD(string transition)
 {
     if (transition.ToUpper()
         .Equals(NASCustomFieldTypeControlStateTransition.UpdateTransition.TransitionName))
     {
         //Validate flag
         ObjectCustomField objectCustomField =
             session.GetObjectByKey <ObjectCustomField>(ObjectCustomFieldId);
         if (!objectCustomField.CustomFieldType.Equals(CustomFieldTypeFlag.CUSTOM_FIELD_TYPE_DEFAULT.Value))
         {
             return(false);
         }
         NASCustomFieldPredefinitionData selectedItem =
             NASCustomFieldTypeBuiltInSingleSelectionListStrategy.GetSelectedPredefinitionDataFromList(cboBuiltInSingleSelectionList);
         //Update data of custom field by ObjectCustomFieldId
         if (NASCustomFieldTypeBuiltInSingleSelectionListStrategy.UpdatePredefinitionDataForObject(ObjectCustomFieldId, selectedItem))
         {
             if (DataUpdated != null)
             {
                 List <NASCustomFieldPredefinitionData> builtInData = new List <NASCustomFieldPredefinitionData>();
                 builtInData.Add(selectedItem);
                 //Raise DataUpdated event
                 DataUpdated(this,
                             new CustomFieldControlEventArgs(
                                 ObjectCustomFieldId,
                                 objectCustomField.ObjectTypeCustomFieldId.ObjectTypeCustomFieldId,
                                 objectCustomField.ObjectId.ObjectId,
                                 objectCustomField.ObjectTypeCustomFieldId.CustomFieldId.CustomFieldId,
                                 CustomFieldControlEventArgs.CustomFieldCategoryEnum.BUILT_IN,
                                 null,
                                 BasicCustomFieldTypeEnum.NONE,
                                 builtInData,
                                 null));
             }
         }
     }
     return(true);
 }
Exemple #15
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;
                            }
                        }
                    }
                }
            }
        }
        public virtual bool UpdatePredefinitionDataForObject(Guid objectCustomFieldId, NASCustomFieldPredefinitionData data)
        {
            try
            {
                ObjectCustomFieldBO objectCustomFieldBO = new ObjectCustomFieldBO();
                PredefinitionCustomFieldTypeEnum predefinitionType;
                List <Guid> IDList = null;
                if (data == null)
                {
                    string customfieldType;
                    using (Session session = XpoHelper.GetNewSession())
                    {
                        customfieldType =
                            objectCustomFieldBO.GetObjectCustomField(session, objectCustomFieldId)
                            .ObjectTypeCustomFieldId.CustomFieldId.CustomFieldTypeId.Code;
                    }
                    predefinitionType = (PredefinitionCustomFieldTypeEnum)
                                        Enum.Parse(typeof(PredefinitionCustomFieldTypeEnum), customfieldType);
                    return(objectCustomFieldBO.UpdatePredefinitionData(
                               objectCustomFieldId, null, predefinitionType));
                }
                else
                {
                    predefinitionType =
                        (PredefinitionCustomFieldTypeEnum)Enum.Parse(
                            typeof(PredefinitionCustomFieldTypeEnum), data.PredefinitionType);
                    IDList = new List <Guid>();
                    IDList.Add(data.RefId);

                    return(objectCustomFieldBO
                           .UpdatePredefinitionData(objectCustomFieldId, IDList, predefinitionType));
                }
            }
            catch (Exception)
            {
                throw;
            }
        }