/*搜索药物信息:提交关键词,返回含有该关键词的所有药物的信息*/
        public AllPhysicInfoEntity FindPhysicByName(string keyword) {

            DrPEDatabaseEntities DEntities = new DrPEDatabaseEntities();
            keyword = keyword.ToLower();

            /*查询所有的药物记录*/
            var physics = from p in DEntities.Physics
                          where p.Name.ToLower().Contains(keyword)
                          orderby p.PhysicID
                          select p;

            int cnt = 0;
            int physicCount = physics.Count();

            AllPhysicInfoEntity allPhysicInfoEntity = null;
            if (physicCount > 0) {
                allPhysicInfoEntity                     = new AllPhysicInfoEntity();
                allPhysicInfoEntity.Count               = physicCount;
                allPhysicInfoEntity.physicInfoEntity    = new PhysicInfoEntity[physicCount];

                foreach (var p in physics) {
                    allPhysicInfoEntity.physicInfoEntity[cnt] = new PhysicInfoEntity();

                    allPhysicInfoEntity.physicInfoEntity[cnt].PhysicID      = p.PhysicID;
                    allPhysicInfoEntity.physicInfoEntity[cnt].Name          = p.Name;
                    allPhysicInfoEntity.physicInfoEntity[cnt].Description   = p.Description;
                    allPhysicInfoEntity.physicInfoEntity[cnt].Method        = p.Method;
                    allPhysicInfoEntity.physicInfoEntity[cnt].Notice        = p.Notice;

                    cnt++;
                }
            }

            return allPhysicInfoEntity;
        }
        /*取回所有药物编号和名称*/
        public AllPhysicInfoEntity RetrievePhysicList() {

            DrPEDatabaseEntities DEntities = new DrPEDatabaseEntities();

            /*查询所有的药物记录*/
            var physics = from p in DEntities.Physics
                          orderby p.Name
                          select p;

            int cnt = 0;
            int physicCount = physics.Count();

            AllPhysicInfoEntity allPhysicInfoEntity = null;
            if (physicCount > 0) {
                allPhysicInfoEntity                     = new AllPhysicInfoEntity();
                allPhysicInfoEntity.Count               = physicCount;
                allPhysicInfoEntity.physicInfoEntity    = new PhysicInfoEntity[physicCount];

                foreach (var p in physics) {
                    allPhysicInfoEntity.physicInfoEntity[cnt] = new PhysicInfoEntity();

                    allPhysicInfoEntity.physicInfoEntity[cnt].PhysicID  = p.PhysicID;
                    allPhysicInfoEntity.physicInfoEntity[cnt].Name      = p.Name;

                    cnt++;
                }
            }

            return allPhysicInfoEntity;
        }
        /*搜索药物信息:提交关键词,返回含有该关键词的所有药物的信息*/
        public AllPhysicInfoEntity FindPhysicByName(string keyword) {
            AllPhysicInfoEntity allPhysicInfoEntity = openAccessDAO.FindPhysicByName(keyword);

            if (allPhysicInfoEntity == null) {
                allPhysicInfoEntity = new AllPhysicInfoEntity();
                allPhysicInfoEntity.ErrorMessage = "153 No Physic of " + keyword +"! @Logic";
            }

            return allPhysicInfoEntity;
        }
        /*取回所有药物编号和名称*/
        public AllPhysicInfoEntity RetrievePhysicList() {
            AllPhysicInfoEntity allPhysicInfoEntity = openAccessDAO.RetrievePhysicList();

            if (allPhysicInfoEntity == null) {
                allPhysicInfoEntity = new AllPhysicInfoEntity();
                allPhysicInfoEntity.ErrorMessage = "161 No Physic Records! @Logic";
            }

            return allPhysicInfoEntity;
        }
        /*将AllPhysicInfo对应的Entity翻译为数据契约,调用TranslatePhysicInfoEntityToPhysicInfoContractData()*/
        private void TranslateAllPhysicInfoEntityToAllPhysicInfoContractData(
            AllPhysicInfoEntity allPhysicInfoEntity,
            AllPhysicInfo       allPhysicInfo) {

            int cnt = 0;

            allPhysicInfo.ErrorMessage  = allPhysicInfoEntity.ErrorMessage;
            allPhysicInfo.Count         = allPhysicInfoEntity.Count;

            if (allPhysicInfo.Count > 0) {
                allPhysicInfo.physicInfo = new PhysicInfo[allPhysicInfo.Count];
                for (cnt = 0; cnt < allPhysicInfo.Count; cnt++) {
                    allPhysicInfo.physicInfo[cnt] = new PhysicInfo();
                    TranslatePhysicInfoEntityToPhysicInfoContractData(
                        allPhysicInfoEntity.physicInfoEntity[cnt],
                        allPhysicInfo.physicInfo[cnt]);
                }
            }
        }
        /*搜索药物信息:提交关键词,返回含有该关键词的所有药物的信息*/
        public AllPhysicInfo FindPhysicByName(string keyword) {
            AllPhysicInfoEntity allPhysicInfoEntity = null;

            if (keyword == null) {
                allPhysicInfoEntity = new AllPhysicInfoEntity();
                allPhysicInfoEntity.ErrorMessage = "123 Empty Keyword of Physic Name! @Service";
            }
            else {
                allPhysicInfoEntity = openAccessLogic.FindPhysicByName(keyword);
            }
            AllPhysicInfo allPhysicInfo = new AllPhysicInfo();
            TranslateAllPhysicInfoEntityToAllPhysicInfoContractData(allPhysicInfoEntity, allPhysicInfo);

            return allPhysicInfo;
        }