private static OfficesDataSet ImportOfficesData(List<int> typeIDs, OfficesDataSet allOffices)
        {
            OfficesDataSet ds = new OfficesDataSet();

            //var selected = from unit in allOffices.CM_LookupOrganisationalUnit
            //               join type in
            //                   (from t in allOffices.CM_LookupOrganisationalUnitByType
            //                    where Contains(typeIDs,t.OrganisationalUnitTypeID)
            //                    select t) on unit.OrganisationalUnitID equals type.OrganisationalUnitID
            //               //join detail in allOffices.CM_LookupOrganisationalUnitDetails on unit.OrganisationalUnitID equals detail.OrganisationalUnitID
            //               into temp
            //               from y in temp.DefaultIfEmpty()
            //               select new DataRow[] { unit, type, y };

            var selected = from unit in allOffices.CM_LookupOrganisationalUnit
                           join type in allOffices.CM_LookupOrganisationalUnitByType on unit.OrganisationalUnitID equals type.OrganisationalUnitID
                           where typeIDs.Contains<int>(type.OrganisationalUnitTypeID)
                           select new DataRow[] { unit, type };

            ds.BeginInit();
            foreach (var rows in selected)
            {
                if (ds.CM_LookupOrganisationalUnit.FindByOrganisationalUnitID(rows[0]["OrganisationalUnitID"].ToString())==null)
                {
                    ds.CM_LookupOrganisationalUnit.ImportRow(rows[0]);

                }
                ds.CM_LookupOrganisationalUnitByType.ImportRow(rows[1]);
                //if (rows[2]!=null) ds.CM_LookupOrganisationalUnitDetails.ImportRow(rows[2]);
            }
            ds.EndInit();

            return ds;
        }
        public OfficesDataSet GetDefaultOfficeDetailForUser(string userName)
        {
            var unitId = this.GetDefaultOfficeIDForUser(userName);

            if (string.IsNullOrEmpty(unitId))
            {
                return new OfficesDataSet();
            }

            var allOffices = this.GetAllOfficesWithoutCopy();

            var lookupOrganisationalUnitRow = allOffices.CM_LookupOrganisationalUnit.FindByOrganisationalUnitID(unitId);
            if (lookupOrganisationalUnitRow==null)
            {
                return new OfficesDataSet();
            }

            var defaultOffices = from type in allOffices.CM_LookupOrganisationalUnitByType
                                 where type.OrganisationalUnitID == unitId
                                 select type;

            var result = new OfficesDataSet();
            result.BeginInit();
            result.CM_LookupOrganisationalUnit.ImportRow(lookupOrganisationalUnitRow);

            foreach (var lookupOrganisationalUnitByTypeRow in defaultOffices)
            {
                result.CM_LookupOrganisationalUnitByType.ImportRow(lookupOrganisationalUnitByTypeRow);
            }
            result.EndInit();

            return result;
        }