/*获取医师信息:提交科室编号,返回该科室的所有医师的信息*/
        public AllDoctorInfoEntity GetAllDoctorInfo(string sectionID) {

            DrPEDatabaseEntities DEntities = new DrPEDatabaseEntities();

            /*查询SectionID域匹配的所有Doctor记录*/
            var doctors = from d in DEntities.Doctors
                          where d.SectionID == sectionID
                          orderby d.DoctorID
                          select d;

            int cnt = 0;
            int doctorCount = doctors.Count();

            AllDoctorInfoEntity allDoctorInfoEntity = null;
            if (doctorCount > 0) {

                allDoctorInfoEntity = new AllDoctorInfoEntity();
                allDoctorInfoEntity.Count = doctorCount;
                allDoctorInfoEntity.doctorInfoEntity = new DoctorInfoEntity[doctorCount];

                foreach (var d in doctors) {
                    allDoctorInfoEntity.doctorInfoEntity[cnt] = new DoctorInfoEntity();

                    allDoctorInfoEntity.doctorInfoEntity[cnt].SectionID     = d.SectionID;
                    allDoctorInfoEntity.doctorInfoEntity[cnt].DoctorID      = d.DoctorID;
                    allDoctorInfoEntity.doctorInfoEntity[cnt].UserID        = d.UserID;
                    allDoctorInfoEntity.doctorInfoEntity[cnt].LastName      = d.LastName;
                    allDoctorInfoEntity.doctorInfoEntity[cnt].FirstName     = d.FirstName;
                    allDoctorInfoEntity.doctorInfoEntity[cnt].Designation   = d.Designation;
                    allDoctorInfoEntity.doctorInfoEntity[cnt].Resume        = d.Resume;
                    allDoctorInfoEntity.doctorInfoEntity[cnt].Phone         = d.Phone;
                    allDoctorInfoEntity.doctorInfoEntity[cnt].Fax           = d.Fax;
                    allDoctorInfoEntity.doctorInfoEntity[cnt].Email         = d.Email;
                    allDoctorInfoEntity.doctorInfoEntity[cnt].Vocation      = d.Vocation;
                    allDoctorInfoEntity.doctorInfoEntity[cnt].Portrait      = d.Portrait;

                    cnt++;
                }
            }

            return allDoctorInfoEntity;
        }
        /*搜索医师信息:提交关键词,返回含有该关键词的所有医师的信息*/
        public AllDoctorInfoEntity FindDoctorByName(string keyword) {

            DrPEDatabaseEntities DEntities = new DrPEDatabaseEntities();

            /*查询Name域包含keyword的所有Doctor记录*/
            keyword = keyword.ToLower();
            var doctors = from d in DEntities.Doctors
                          where (d.LastName + " " + d.FirstName).ToLower().Contains(keyword)
                             || (d.FirstName + " " + d.LastName).ToLower().Contains(keyword)
                          //orderby d.DoctorID
                          select d;

            int cnt = 0;
            int doctorCount = doctors.Count();

            AllDoctorInfoEntity allDoctorInfoEntity = null;
            if (doctorCount > 0) {

                allDoctorInfoEntity = new AllDoctorInfoEntity();
                allDoctorInfoEntity.Count = doctorCount;
                allDoctorInfoEntity.doctorInfoEntity = new DoctorInfoEntity[doctorCount];

                foreach (var d in doctors) {
                    allDoctorInfoEntity.doctorInfoEntity[cnt] = new DoctorInfoEntity();

                    allDoctorInfoEntity.doctorInfoEntity[cnt].SectionID     = d.SectionID;
                    allDoctorInfoEntity.doctorInfoEntity[cnt].DoctorID      = d.DoctorID;
                    allDoctorInfoEntity.doctorInfoEntity[cnt].UserID        = d.UserID;
                    allDoctorInfoEntity.doctorInfoEntity[cnt].LastName      = d.LastName;
                    allDoctorInfoEntity.doctorInfoEntity[cnt].FirstName     = d.FirstName;
                    allDoctorInfoEntity.doctorInfoEntity[cnt].Designation   = d.Designation;
                    allDoctorInfoEntity.doctorInfoEntity[cnt].Resume        = d.Resume;
                    allDoctorInfoEntity.doctorInfoEntity[cnt].Phone         = d.Phone;
                    allDoctorInfoEntity.doctorInfoEntity[cnt].Fax           = d.Fax;
                    allDoctorInfoEntity.doctorInfoEntity[cnt].Email         = d.Email;
                    allDoctorInfoEntity.doctorInfoEntity[cnt].Vocation      = d.Vocation;
                    allDoctorInfoEntity.doctorInfoEntity[cnt].Portrait      = d.Portrait;

                    cnt++;
                }
            }

            return allDoctorInfoEntity;
        }
        /*搜索医师信息:提交关键词,返回含有该关键词的所有医师的信息*/
        public AllDoctorInfoEntity FindDoctorByName(string keyword) {
            AllDoctorInfoEntity allDoctorInfoEntity = openAccessDAO.FindDoctorByName(keyword);

            if (allDoctorInfoEntity == null) {
                allDoctorInfoEntity = new AllDoctorInfoEntity();
                allDoctorInfoEntity.ErrorMessage = "152 No Doctors of " + keyword + "! @Logic";
            }

            return allDoctorInfoEntity;
        }
        /*获取医师信息:提交科室编号,返回该科室的所有医师的信息*/
        public AllDoctorInfoEntity GetAllDoctorInfo(string sectionID) {

            AllDoctorInfoEntity allDoctorInfoEntity = openAccessDAO.GetAllDoctorInfo(sectionID);

            if (allDoctorInfoEntity == null) {
                allDoctorInfoEntity = new AllDoctorInfoEntity();
                allDoctorInfoEntity.ErrorMessage = "133 No Doctors in " + sectionID + "! @Logic";
            }

            return allDoctorInfoEntity;
        }
        /*将AllDoctorInfo对应的Entity翻译为数据契约,调用TranslateDoctorInfoEntityToDoctorInfoContractData()*/
        private void TranslateAllDoctorInfoEntityToAllDoctorInfoContractData(
            AllDoctorInfoEntity     allDoctorInfoEntity,
            AllDoctorInfo           allDoctorInfo) {

                int cnt = 0;

                allDoctorInfo.ErrorMessage  = allDoctorInfoEntity.ErrorMessage;
                allDoctorInfo.Count         = allDoctorInfoEntity.Count;

                if (allDoctorInfo.Count > 0) {
                    allDoctorInfo.doctorInfo = new DoctorInfo[allDoctorInfo.Count];
                    for (cnt = 0; cnt < allDoctorInfo.Count; cnt++) {
                        allDoctorInfo.doctorInfo[cnt] = new DoctorInfo();
                        TranslateDoctorInfoEntityToDoctorInfoContractData(
                            allDoctorInfoEntity.doctorInfoEntity[cnt],
                            allDoctorInfo.doctorInfo[cnt]);
                    }
                }
        }
        /*搜索医师信息:提交关键词,返回含有该关键词的所有医师的信息*/
        public AllDoctorInfo FindDoctorByName(string keyword) {

            AllDoctorInfoEntity allDoctorInfoEntity = null;

            if (keyword == null) {
                allDoctorInfoEntity = new AllDoctorInfoEntity();
                allDoctorInfoEntity.ErrorMessage = "122 Empty Keyword of DoctorName! @Service";
            }
            else {
                allDoctorInfoEntity = openAccessLogic.FindDoctorByName(keyword);
            }
            AllDoctorInfo allDoctorInfo = new AllDoctorInfo();
            TranslateAllDoctorInfoEntityToAllDoctorInfoContractData(allDoctorInfoEntity, allDoctorInfo);

            return allDoctorInfo;
        }
        /*获取医师信息:提交科室编号,返回该科室的所有医师的信息*/
        public AllDoctorInfo GetAllDoctorInfo(string sectionID) {

            AllDoctorInfoEntity allDoctorInfoEntity = null;

            if (sectionID == null) {
                allDoctorInfoEntity = new AllDoctorInfoEntity();
                allDoctorInfoEntity.ErrorMessage = "103 Empty SectionID! @Service";
            }
            else {
                allDoctorInfoEntity = openAccessLogic.GetAllDoctorInfo(sectionID);
            }
            AllDoctorInfo allDoctorInfo = new AllDoctorInfo();
            TranslateAllDoctorInfoEntityToAllDoctorInfoContractData(allDoctorInfoEntity, allDoctorInfo);

            return allDoctorInfo;
        }