/// <summary> /// 由一行数据得到一个实体 /// </summary> private Model.TaskRegionPoint GetModel(DbDataReader dr) { Model.TaskRegionPoint model = new Model.TaskRegionPoint(); model.TaskID = Convert.ToDecimal(dr["TaskID"]); model.PointID = Convert.ToDecimal(dr["PointID"]); model.Point_Lon = Convert.ToDecimal(dr["Point_Lon"]); model.Point_Lat = Convert.ToDecimal(dr["Point_Lat"]); return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.TaskRegionPoint GetModel(decimal TaskID) { StringBuilder strSql = new StringBuilder(); strSql.Append("SELECT * FROM TaskRequirements_ObservationRegion "); strSql.Append(" WHERE TaskID=" + TaskID); Model.TaskRegionPoint model = null; using (DbDataReader dr = DbHelperSQL.ExecuteReader(strSql.ToString())) { while (dr.Read()) { model = GetModel(dr); } return(model); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.TaskRegionPoint model) { StringBuilder strSql = new StringBuilder(); strSql.Append("INSERT INTO TaskRequirements_ObservationRegion("); strSql.Append("TaskID,PointID,Point_Lon,Point_Lat)"); strSql.Append(" VALUES ("); strSql.Append("@in_TaskID,@in_PointID,@in_Point_Lon,@in_Point_Lat)"); SqlParameter[] cmdParms = new SqlParameter[] { new SqlParameter("@in_TaskID", SqlDbType.Decimal), new SqlParameter("@in_PointID", SqlDbType.Decimal), new SqlParameter("@in_Point_Lon", SqlDbType.Decimal), new SqlParameter("@in_Point_Lat", SqlDbType.Decimal) }; cmdParms[0].Value = model.TaskID; cmdParms[1].Value = model.PointID; cmdParms[2].Value = model.Point_Lon; cmdParms[3].Value = model.Point_Lat; return(DbHelperSQL.ExecuteSql(strSql.ToString(), cmdParms)); }
/// <summary> /// 更新一条数据 /// </summary> public int Update(Model.TaskRegionPoint model) { StringBuilder strSql = new StringBuilder(); strSql.Append("UPDATE TaskRequirements_ObservationRegion SET "); strSql.Append("PointID=@in_PointID,"); strSql.Append("Point_Lon=@in_Point_Lon,"); strSql.Append("Point_Lat=@in_Point_Lat"); strSql.Append(" WHERE TaskID=@in_TaskID"); SqlParameter[] cmdParms = new SqlParameter[] { new SqlParameter("@in_TaskID", SqlDbType.Decimal), new SqlParameter("@in_PointID", SqlDbType.Decimal), new SqlParameter("@in_Point_Lon", SqlDbType.Decimal), new SqlParameter("@in_Point_Lat", SqlDbType.Decimal) }; cmdParms[0].Value = model.TaskID; cmdParms[1].Value = model.PointID; cmdParms[2].Value = model.Point_Lon; cmdParms[3].Value = model.Point_Lat; return(DbHelperSQL.ExecuteSql(strSql.ToString(), cmdParms)); }