Пример #1
0
        public OfficesDataSet GetAllOffices()
        {
            OfficesDataSet ds = new OfficesDataSet();

            Helper.Fill(ds,
                new []{ds.CM_LookupOrganisationalUnit.TableName,
                    ds.CM_LookupOrganisationalUnitByType.TableName},
                   "P_IC_ALL_OFFICES_GET");

            return ds;
        }
Пример #2
0
        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;
        }
Пример #3
0
        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;
        }