/*获取科室信息:提交医院编号,返回该医院的所有科室的信息*/
        public AllSectionInfoEntity GetAllSectionInfo(string hospitalID) {

            DrPEDatabaseEntities DEntities = new DrPEDatabaseEntities();

            /*查询HospitalID域匹配的所有Section记录*/
            var sections = from s in DEntities.Sections
                           where s.HospitalID == hospitalID
                           orderby s.SectionID
                           select s;

            int cnt = 0;
            int sectionCount = sections.Count();

            AllSectionInfoEntity allSectionInfoEntity = null;
            if (sectionCount > 0) {
                allSectionInfoEntity                    = new AllSectionInfoEntity();
                allSectionInfoEntity.Count              = sectionCount;
                allSectionInfoEntity.sectionInfoEntity  = new SectionInfoEntity[sectionCount];

                foreach (var s in sections) {
                    allSectionInfoEntity.sectionInfoEntity[cnt] = new SectionInfoEntity();

                    allSectionInfoEntity.sectionInfoEntity[cnt].HospitalID  = s.HospitalID;
                    allSectionInfoEntity.sectionInfoEntity[cnt].SectionID   = s.SectionID;
                    allSectionInfoEntity.sectionInfoEntity[cnt].Place       = s.Place;
                    allSectionInfoEntity.sectionInfoEntity[cnt].Name        = s.Name;
                    allSectionInfoEntity.sectionInfoEntity[cnt].Phone       = s.Phone;
                    allSectionInfoEntity.sectionInfoEntity[cnt].Fax         = s.Fax;

                    cnt++;
                }
            }

            return allSectionInfoEntity;
        }
        /*搜索科室信息:提交关键词,返回含有该关键词的所有科室的信息*/
        public AllSectionInfoEntity FindSectionByName(string keyword) {

            DrPEDatabaseEntities DEntities = new DrPEDatabaseEntities();

            /*查询Name域包含keyword的所有Section记录*/
            keyword = keyword.ToLower();
            var sections = from s in DEntities.Sections
                           where s.Name.ToLower().Contains(keyword)
                           //orderby s.sectionID
                           select s;

            int cnt = 0;
            int sectionCount = sections.Count();

            AllSectionInfoEntity allSectionInfoEntity = null;
            if (sectionCount > 0) {
                allSectionInfoEntity = new AllSectionInfoEntity();
                allSectionInfoEntity.Count = sectionCount;
                allSectionInfoEntity.sectionInfoEntity = new SectionInfoEntity[sectionCount];

                foreach (var s in sections) {
                    allSectionInfoEntity.sectionInfoEntity[cnt] = new SectionInfoEntity();

                    allSectionInfoEntity.sectionInfoEntity[cnt].HospitalID  = s.HospitalID;
                    allSectionInfoEntity.sectionInfoEntity[cnt].SectionID   = s.SectionID;
                    allSectionInfoEntity.sectionInfoEntity[cnt].Place       = s.Place;
                    allSectionInfoEntity.sectionInfoEntity[cnt].Name        = s.Name;
                    allSectionInfoEntity.sectionInfoEntity[cnt].Phone       = s.Phone;
                    allSectionInfoEntity.sectionInfoEntity[cnt].Fax         = s.Fax;

                    cnt++;
                }
            }

            return allSectionInfoEntity;
        }
        /*获取科室信息:提交医院编号,返回该医院的所有科室的信息*/
        public AllSectionInfoEntity GetAllSectionInfo(string hospitalID) {

            AllSectionInfoEntity allSectionInfoEntity = openAccessDAO.GetAllSectionInfo(hospitalID);

            if (allSectionInfoEntity == null) {
                allSectionInfoEntity = new AllSectionInfoEntity();
                allSectionInfoEntity.ErrorMessage = "132 No Sections in " + hospitalID + "! @Logic";
            }

            return allSectionInfoEntity;
        }
        /*搜索科室信息:提交关键词,返回含有该关键词的所有科室的信息*/
        public AllSectionInfoEntity FindSectionByName(string keyword) {

            AllSectionInfoEntity allSectionInfoEntity = openAccessDAO.FindSectionByName(keyword);

            if (allSectionInfoEntity == null) {
                allSectionInfoEntity = new AllSectionInfoEntity();
                allSectionInfoEntity.ErrorMessage = "151 No Sections of " + keyword + "! @Logic";
            }

            return allSectionInfoEntity;
        }
        /*将AllSectionInfo对应的Entity翻译为数据契约,调用TranslateSectionInfoEntityToSectionInfoContractData()*/
        private void TranslateAllSectionInfoEntityToAllSectionInfoContractData(
            AllSectionInfoEntity    allSectionInfoEntity,
            AllSectionInfo          allSectionInfo) {

                int cnt = 0;

                allSectionInfo.ErrorMessage     = allSectionInfoEntity.ErrorMessage;
                allSectionInfo.Count            = allSectionInfoEntity.Count;

                if (allSectionInfo.Count > 0) {
                    allSectionInfo.sectionInfo = new SectionInfo[allSectionInfo.Count];
                    for (cnt = 0; cnt < allSectionInfo.Count; cnt++) {
                        allSectionInfo.sectionInfo[cnt] = new SectionInfo();
                        TranslateSectionInfoEntityToSectionInfoContractData(
                            allSectionInfoEntity.sectionInfoEntity[cnt],
                            allSectionInfo.sectionInfo[cnt]);
                    }
                }
        }
        /*搜索科室信息:提交关键词,返回含有该关键词的所有科室的信息*/
        public AllSectionInfo FindSectionByName(string keyword) {

            AllSectionInfoEntity allSectionInfoEntity = null;

            if (keyword == null) {
                allSectionInfoEntity = new AllSectionInfoEntity();
                allSectionInfoEntity.ErrorMessage = "121 Empty Keyword of SectionName! @Service";
            }
            else {
                allSectionInfoEntity = openAccessLogic.FindSectionByName(keyword);
            }
            AllSectionInfo allSectionInfo = new AllSectionInfo();
            TranslateAllSectionInfoEntityToAllSectionInfoContractData(allSectionInfoEntity, allSectionInfo);

            return allSectionInfo;
        }
        /*获取科室信息:提交医院编号,返回该医院的所有科室的信息*/
        public AllSectionInfo GetAllSectionInfo(string hospitalID) {

            AllSectionInfoEntity allSectionInfoEntity = null;

            if (hospitalID == null) {
                allSectionInfoEntity = new AllSectionInfoEntity();
                allSectionInfoEntity.ErrorMessage = "102 Empty HospitalID! @Service";
            }
            else {
                allSectionInfoEntity = openAccessLogic.GetAllSectionInfo(hospitalID);
            }
            AllSectionInfo allSectionInfo = new AllSectionInfo();
            TranslateAllSectionInfoEntityToAllSectionInfoContractData(allSectionInfoEntity, allSectionInfo);

            return allSectionInfo;
        }