/// <summary> /// 根据UID更新一条数据 /// </summary> public int UpdateByUID(Model.UAVCurrentTask model) { StringBuilder strSql = new StringBuilder(); strSql.Append("UPDATE UAVCurrentTask SET "); strSql.Append("PID=@in_PID,"); strSql.Append("LON=@in_LON,"); strSql.Append("LAT=@in_LAT,"); strSql.Append("TaskString=@in_TaskString,"); strSql.Append("TID=@in_TID"); strSql.Append(" WHERE UID=@in_UID"); SqlParameter[] cmdParms = new SqlParameter[] { new SqlParameter("@in_PID", SqlDbType.Int), new SqlParameter("@in_LON", SqlDbType.Decimal), new SqlParameter("@in_LAT", SqlDbType.Decimal), new SqlParameter("@in_TaskString", SqlDbType.NVarChar), new SqlParameter("@in_TID", SqlDbType.Int), new SqlParameter("@in_UID", SqlDbType.Int) }; cmdParms[0].Value = model.PID; cmdParms[1].Value = model.LON; cmdParms[2].Value = model.LAT; cmdParms[3].Value = model.TaskString; cmdParms[4].Value = model.TID; cmdParms[5].Value = model.UID; return(DbHelperSQL.ExecuteSql(strSql.ToString(), cmdParms)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.UAVCurrentTask model) { StringBuilder strSql = new StringBuilder(); strSql.Append("INSERT INTO UAVCurrentTask("); strSql.Append("PID,LON,LAT,TaskString,UID,TID)"); strSql.Append(" VALUES ("); strSql.Append("@in_PID,@in_LON,@in_LAT,@in_TaskString,@in_UID,@in_TID)"); SqlParameter[] cmdParms = new SqlParameter[] { new SqlParameter("@in_PID", SqlDbType.Int), new SqlParameter("@in_LON", SqlDbType.Decimal), new SqlParameter("@in_LAT", SqlDbType.Decimal), new SqlParameter("@in_TaskString", SqlDbType.NVarChar), new SqlParameter("@in_UID", SqlDbType.Int), new SqlParameter("@in_TID", SqlDbType.Int) }; cmdParms[0].Value = model.PID; cmdParms[1].Value = model.LON; cmdParms[2].Value = model.LAT; cmdParms[3].Value = model.TaskString; cmdParms[4].Value = model.UID; cmdParms[5].Value = model.TID; return(DbHelperSQL.ExecuteSql(strSql.ToString(), cmdParms)); }
/// <summary> /// 由一行数据得到一个实体 /// </summary> private Model.UAVCurrentTask GetModel(DbDataReader dr) { Model.UAVCurrentTask model = new Model.UAVCurrentTask(); model.ID = DbHelperSQL.GetInt(dr["ID"]); model.PID = DbHelperSQL.GetInt(dr["PID"]); model.LON = DbHelperSQL.GetDouble(dr["LON"]); model.LAT = DbHelperSQL.GetDouble(dr["LAT"]); model.TaskString = DbHelperSQL.GetString(dr["TaskString"]); model.UID = DbHelperSQL.GetInt(dr["UID"]); model.TID = DbHelperSQL.GetInt(dr["TID"]); return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.UAVCurrentTask GetModel(int ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("SELECT * FROM UAVCurrentTask "); strSql.Append(" WHERE ID=" + ID); Model.UAVCurrentTask model = null; using (SqlDataReader dr = DbHelperSQL.ExecuteReader(strSql.ToString())) { while (dr.Read()) { model = GetModel(dr); } return(model); } }