Example #1
0
        //================================================================================
        /// <summary>
        /// Bind CompanyUnitDataTablesCollection, CompanyDataItemCollection & CompanyDataEnumerationCollection
        /// to each CompanyUnit from CompanyUnitHierarchyCollection
        /// </summary>
        /// <param name="allDataTables"></param>
        /// <param name="allDataItems"></param>
        /// <param name="allDataEnumeration"></param>
        /// <returns></returns>
        public void BindDataTablesToEachCompanyUnitHierarchy
            (CompanyUnitDataTablesCollection <CompanyUnitDataTables> allDataTables,
            CompanyDataItemCollection <CompanyDataItem> allDataItems,
            CompanyDataEnumerationCollection <CompanyDataEnumeration> allDataEnumeration
            )
        {
            foreach (T companyUnitObj in this)
            {
                CompanyUnitDataTablesCollection <CompanyUnitDataTables> companyUnitDataTableColl =
                    allDataTables[companyUnitObj];

                CompanyDataItemCollection <CompanyDataItem> companyUnitDataItemColl = allDataItems[companyUnitObj];

                CompanyDataEnumerationCollection <CompanyDataEnumeration> companyUnitDataEnumerationColl =
                    allDataEnumeration[companyUnitObj];

                companyUnitDataItemColl.BindDataEnumerationToEachDataItems(companyUnitDataEnumerationColl);

                companyUnitDataTableColl.BindDataItemsToEachDataTable(companyUnitDataItemColl);

                if (companyUnitDataTableColl.Count > 0)
                {
                    companyUnitObj.DataTables = companyUnitDataTableColl;
                }
            }
        }
Example #2
0
        //================================================================================
        /// <summary>
        /// Binds DataDataItems to respective DataTable, Removes duplicate DataItems and
        /// Assigned DataTableDesc from BindingDataTableRefs
        /// </summary>
        /// <param name="enumColl"></param>
        public void BindDataItemsToEachDataTable(CompanyDataItemCollection <CompanyDataItem> dataItemColl
                                                 )
        {
            foreach (T obj in this)
            {
                CompanyDataItemCollection <CompanyDataItem> forEachDataTableDataItemColl =
                    new CompanyDataItemCollection <CompanyDataItem>();
                forEachDataTableDataItemColl = dataItemColl.Find(obj.BindingDataTableRefs);
                if (forEachDataTableDataItemColl.Count != 0)
                {
                    obj.DataItems = forEachDataTableDataItemColl.RemoveDuplicateDataItems();
                }
                string[] tableDescs = new string[obj.BindingDataTableRefs.Length];

                for (int i = 0; i < obj.BindingDataTableRefs.Length; i++)
                {
                    tableDescs[i] = this.GetDataTableDesc(obj.BindingDataTableRefs[i]);
                }
                obj.BindingDataTableDescs = tableDescs;

                string sqlScriptText = Null.String;
                //if (obj.DataItems != null)
                //    sqlScriptText = (new Company.DMS.BusinessEntities.SqlDataItemScriptBuilder())
                //                    .BuildDataItemSqlScript(obj);

                obj.DataTableSqlScript = sqlScriptText;
            }
        }
 /// <summary>
 /// Finds DataTableRefs within CompanyDataItemCollection
 /// </summary>
 /// <param name="dataTableRefs">Collection of int[dataTableRef]</param>
 /// <returns>CompanyDataItemCollection Object</returns>
 public CompanyDataItemCollection <T> Find(params int[] dataTableRefs)
 {
     if (dataTableRefs.Length > 0)
     {
         CompanyDataItemCollection <T> tempColl = new CompanyDataItemCollection <T>();
         for (int i = 0; i < dataTableRefs.Length && dataTableRefs[i] != Null.Integer; i++)
         {
             tempColl.Merge(this.Find(dataTableRefs[i]));
         }
         return(tempColl);
     }
     return(null);
 }
 /// <summary>
 /// Merge given CompanyDataItemCollection (mergeFromColl) using DataItemCode, DataTableRef
 /// to existing CompanyDataItemCollection
 /// </summary>
 /// <param name="mergeFromColl"></param>
 public CompanyDataItemCollection <T> Merge(CompanyDataItemCollection <T> mergeFromColl)
 {
     if (mergeFromColl != null)
     {
         foreach (T obj in mergeFromColl)
         {
             if (!this.Contains(obj.DataItemCode, obj.DataTableRef))
             {
                 this.Add(obj);
             }
         }
     }
     return(this);
 }
        public CompanyDataItemCollection <T> this[
            CompanyUnitHierarchy CompanyUnitObj, params int[] dataTableRefs]
        {
            get
            {
                CompanyDataItemCollection <T> tempColl =
                    this.GetAllDataItemForCompanyHierarchy(
                        CompanyUnitObj.CompanyUnitRef, CompanyUnitObj.CompanyUnitParentRef,
                        CompanyUnitObj.CompanyUnitGrandParentRef, CompanyUnitObj.CompanyUnitGreatGrandParentRef);

                //tempColl = tempColl.Find(dataTableRefs);

                return(tempColl.Find(dataTableRefs));
            }
        }
 /// <summary>
 /// Remove Duplicate DataItems (DataItemCode) within Collection
 /// </summary>
 /// <returns></returns>
 public CompanyDataItemCollection <T> RemoveDuplicateDataItems()
 {
     if (this != null || this.Count > 0)
     {
         CompanyDataItemCollection <T> distinctDataItemColl = new CompanyDataItemCollection <T>();
         foreach (T obj in this)
         {
             if (!distinctDataItemColl.Contains(obj.DataItemCode))
             {
                 distinctDataItemColl.Add(obj);
             }
         }
         return(distinctDataItemColl);
     }
     return(this);
 }
 /// <summary>
 /// Finds and Return all DataItems for given DataTableRef within CompanyDataItemCollection
 /// </summary>
 /// <param name="DataTableRef"></param>
 /// <returns></returns>
 public CompanyDataItemCollection <T> Find(int dataTableRef)
 {
     if (this != null && dataTableRef != Null.Integer)
     {
         CompanyDataItemCollection <T> tempColl = new CompanyDataItemCollection <T>();
         foreach (T obj in this)
         {
             if (obj.DataTableRef == dataTableRef)
             {
                 tempColl.Add(obj);
             }
         }
         return(tempColl);
     }
     return(null);
 }
        /// <summary>
        /// Returns CompanyUnitDataTablesCollection for given CompanyRef
        /// </summary>
        public CompanyDataItemCollection <T> this[int CompanyRef]
        {
            get
            {
                if (CompanyRef != Null.Integer || !CompanyRef.Equals(null))
                {
                    CompanyDataItemCollection <T> tempColl = new CompanyDataItemCollection <T>();
                    foreach (T obj in this)
                    {
                        if (obj.CompanyUnitRef == CompanyRef)
                        {
                            tempColl.Add(obj);
                        }
                    }

                    return(tempColl);
                }
                return(null);
            }
        }