Example #1
0
        /// <summary>
        /// 修改指定站点的所有可修改的信息
        /// </summary>
        /// 可能出现:信息超过允许的范围,站点不存在。
        /// <param name="station">传入一个站点对象。</param>
        /// <returns></returns>
        public static helper.DBReturnCode AlterStation(Models.Maintain db, Models.ID_TO_STCD_DK station)
        {
            if (!db.ID_TO_STCD_DK.Any(i => i.ID == station.ID)) //站点不存在
            {
                return(helper.DBReturnCode.NOT_EXIST);
            }
            ID_TO_STCD_DK target = db.ID_TO_STCD_DK.First(i => i.ID == station.ID);

            //修改所有属性
            target.STTYPE       = station.STTYPE;
            target.CNAME        = station.CNAME;
            target.WATERMAX     = station.WATERMAX;
            target.WATERMIN     = station.WATERMIN;
            target.WATERCHANGE  = station.WATERCHANGE;
            target.RAINCHANGE   = station.RAINCHANGE;
            target.BRAIN        = station.BRAIN;
            target.DAYWATERTJ   = station.DAYWATERTJ;
            target.DAYRAINTJ    = station.DAYRAINTJ;
            target.XUNWATERTJ   = station.XUNWATERTJ;
            target.XUNRAINTJ    = station.XUNRAINTJ;
            target.MONTHWATERTJ = station.MONTHWATERTJ;
            target.MONTHRAINTJ  = station.MONTHRAINTJ;
            target.sendflag     = station.sendflag;
            try
            {
                db.SaveChanges();
                return(helper.DBReturnCode.SUCCESS);
            }catch (Exception e)
            {
                return(helper.DBReturnCode.OP_ERROR);
            }
        }
Example #2
0
 /// <summary>
 /// 根据站点ID删除一个站点
 /// </summary>
 /// 可能出现:站点不存在
 /// <param name="id"></param>
 /// <returns></returns>
 public static helper.DBReturnCode DeleteStation(Models.Maintain db, string station8Id, string stationId)
 {
     if (!db.ID_TO_STCD_DK.Any(i => i.ID == station8Id && i.STCD == stationId))
     {
         return(helper.DBReturnCode.NOT_EXIST);
     }
     try
     {
         ID_TO_STCD_DK station = db.ID_TO_STCD_DK.First(i => i.ID == stationId && i.STCD == station8Id);
         db.ID_TO_STCD_DK.Remove(station);
         db.SaveChanges();
         return(helper.DBReturnCode.SUCCESS);
     }catch (Exception e)
     {
         return(helper.DBReturnCode.OP_ERROR);
     }
 }