Beispiel #1
0
        public string UpdateStation(StationDef item, string oldStationId)
        {
            String result = "";
            try
            {
                IStationRepository itemRepository = RepositoryFactory.GetInstance().GetRepository<IStationRepository>();
                Station itemNew = new Station();

                itemNew.StationId = item.station;
                itemNew.StationType = (StationType)Enum.Parse(typeof(StationType), item.stationType);
                itemNew.OperationObject = Int32.Parse(item.operationObject);
                itemNew.Descr = item.descr;
                itemNew.Name = item.name;
                itemNew.Editor = item.editor;
                itemNew.Udt = DateTime.Now;
                //ITC-1361-0095 ITC210012 2012-02-21
                IList<Station> stationObj = itemRepository.GetStationItemByName(item.name);

                if (stationObj.Count>0)
                {
                    if (stationObj[0].StationId != oldStationId)
                    {
                        List<string> param = new List<string>();
                        throw new FisException("DMT139", param);
                    }
                    //itemRepository.AddStation(itemNew);
                    //result = itemNew.StationId;
                }
                        //存在 进行更新操作...
                      itemRepository.UpdateStation(itemNew, oldStationId);
                      result = itemNew.StationId;
               
            }
            catch (Exception)
            {
                throw;
            }

            return result;
        }
Beispiel #2
0
        //Boolean IsExistStation(string station)
        //IF EXISTS(
        //SELECT [Station]     
        //  FROM [Station]
        //where Station ='station)'
        //)
        //set @return='True'
        //ELSE
        //set @return='False' 

        public string AddStation(StationDef item)
        {
            String result = "";
            try
            {
                IStationRepository itemRepository = RepositoryFactory.GetInstance().GetRepository<IStationRepository>();

                Boolean isExist = itemRepository.IsExistStation(item.station);
                if (isExist == true)
                {
                    //已经存在具有相同Station的记录
                    List<string> erpara = new List<string>();
                    FisException ex;
                    ex = new FisException("DMT043", erpara);
                    throw ex;

                }
                bool existFlag = itemRepository.CheckStationExistByName(item.name);
                if (existFlag)
                {
                    List<string> param = new List<string>();
                    throw new FisException("DMT139", param);
                }
                Station itemNew = new Station();

                itemNew.StationId = item.station;
                itemNew.StationType = (StationType)Enum.Parse(typeof(StationType), item.stationType);
                itemNew.OperationObject = Int32.Parse(item.operationObject);
                itemNew.Descr = item.descr;
                itemNew.Name = item.name;

                itemNew.Editor = item.editor;
                itemNew.Udt = DateTime.Now;
                itemNew.Cdt = DateTime.Now;

                itemRepository.AddStation(itemNew);
                result = itemNew.StationId;
            }
            catch (Exception)
            {
                throw;
            }

            return result;
        }