Esempio n. 1
0
        /// <summary>
        /// 无人机添加函数,添加删除和管理的数据库连接还存在问题
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int Add(Model.UAV_RANGE model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("INSERT INTO UAV_RANGE(");
            strSql.Append("PLATFORM_ID,PLATFORM_Name,NumberOfSensor,CruisingVelocity,RollVelocity,PitchVelocity,MaxVelocity,MinVelocity,Acceleration,CruisingTime,");
            strSql.Append("MaxSlewAngle,MinSlewAngle,CruisingAltitude,MaxAltitude,MaxDistance,MinTurningRadius,PayLoad,");
            strSql.Append("MaxLoad,Base_ID)");
            strSql.Append(" Values(");
            strSql.Append("@in_PLATFORM_ID,@in_PLATFORM_Name,@in_NumberOfSensor,@in_CruisingVelocity,@in_RollVelocity,@in_PitchVelocity,@in_MaxVelocity,");
            strSql.Append("@in_MinVelocity,@in_Acceleration,@in_CruisingTime,");
            strSql.Append("@in_MaxSlewAngle,@in_MinSlewAngle,@in_CruisingAltitude,@in_MaxAltitude,@in_MaxDistance,@in_MinTurningRadius,");
            strSql.Append("@in_PayLoad,@in_MaxLoad,@in_Base_ID)");
            SqlParameter[] cmdParms = new SqlParameter[] {
                new SqlParameter("@in_PLATFORM_ID", SqlDbType.Decimal),
                new SqlParameter("@in_PLATFORM_Name", SqlDbType.NVarChar),
                new SqlParameter("@in_NumberOfSensor", SqlDbType.Decimal),
                new SqlParameter("@in_CruisingVelocity", SqlDbType.Decimal),
                new SqlParameter("@in_RollVelocity", SqlDbType.Decimal),
                new SqlParameter("@in_PitchVelocity", SqlDbType.Decimal),
                new SqlParameter("@in_MaxVelocity", SqlDbType.Decimal),
                new SqlParameter("@in_MinVelocity", SqlDbType.Decimal),
                new SqlParameter("@in_Acceleration", SqlDbType.Decimal),
                new SqlParameter("@in_CruisingTime", SqlDbType.Decimal),

                new SqlParameter("@in_MaxSlewAngle", SqlDbType.Decimal),
                new SqlParameter("@in_MinSlewAngle", SqlDbType.Decimal),
                new SqlParameter("@in_CruisingAltitude", SqlDbType.Decimal),
                new SqlParameter("@in_MaxAltitude", SqlDbType.Decimal),
                new SqlParameter("@in_MaxDistance", SqlDbType.Decimal),
                new SqlParameter("@in_MinTurningRadius", SqlDbType.Decimal),
                new SqlParameter("@in_PayLoad", SqlDbType.Decimal),
                new SqlParameter("@in_MaxLoad", SqlDbType.Decimal),
                new SqlParameter("@in_Base_ID", SqlDbType.Decimal)
            };

            cmdParms[0].Value = model.PLATFORM_ID;
            cmdParms[1].Value = model.PLATFORM_Name;
            cmdParms[2].Value = model.NumberOfSensor;
            cmdParms[3].Value = model.CruisingVelocity;
            cmdParms[4].Value = model.RollVelocity;
            cmdParms[5].Value = model.PitchVelocity;
            cmdParms[6].Value = model.MaxVelocity;
            cmdParms[7].Value = model.MinVelocity;
            cmdParms[8].Value = model.Acceleration;
            cmdParms[9].Value = model.CruisingTime;

            cmdParms[10].Value = model.MaxSlewAngle;
            cmdParms[11].Value = model.MinSlewAngle;
            cmdParms[12].Value = model.CruisingAltitude;
            cmdParms[13].Value = model.MaxAltitude;
            cmdParms[14].Value = model.MaxDistance;
            cmdParms[15].Value = model.MinTurningRadius;
            cmdParms[16].Value = model.PayLoad;
            cmdParms[17].Value = model.MaxLoad;
            cmdParms[18].Value = model.Base_ID;

            return(DbHelperSQL.ExecuteSql(strSql.ToString(), cmdParms));//执行SQL语句,还需修改数据库连接的问题
        }
Esempio n. 2
0
        //该类中需要实现 通过PLATFORM_ID来查找所需的无人机速度和续航时间
        public Model.UAV_RANGE GetModel(decimal platformid)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("Select * From UAV_RANGE ");
            strSql.Append(" Where PLATFORM_ID=" + platformid);
            Model.UAV_RANGE model = null;

            //数据库连接
            SqlConnection connection = new SqlConnection(connectionString);
            SqlCommand    cmd        = new SqlCommand(strSql.ToString(), connection);

            connection.Open();
            SqlDataReader myReader = cmd.ExecuteReader(CommandBehavior.CloseConnection);

            using (DbDataReader dr = myReader)
            {
                while (dr.Read())
                {
                    model = GetModel(dr);//本类中的重载函数
                }
                return(model);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 根据无人机ID修改数据库中的一条记录
        /// </summary>
        /// <param name="model"></param>无人机平台实体类的实例
        /// <returns></returns>返回值为修改的记录数
        public int Update(Model.UAV_RANGE model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("Update UAV_RANGE set ");

            strSql.Append("PLATFORM_Name=@in_PLATFORM_Name,");
            strSql.Append("NumberOfSensor=@in_NumberOfSensor,");
            strSql.Append("CruisingVelocity=@in_CruisingVelocity,");
            strSql.Append("RollVelocity=@in_RollVelocity,");
            strSql.Append("PitchVelocity=@in_PitchVelocity,");
            strSql.Append("MaxVelocity=@in_MaxVelocity,");
            strSql.Append("MinVelocity=@in_MinVelocity,");
            strSql.Append("Acceleration=@in_Acceleration,");
            strSql.Append("CruisingTime=@in_CruisingTime,");

            strSql.Append("MaxSlewAngle=@in_MaxSlewAngle,");
            strSql.Append("MinSlewAngle=@in_MinSlewAngle,");
            strSql.Append("CruisingAltitude=@in_CruisingAltitude,");
            strSql.Append("MaxAltitude=@in_MaxAltitude,");
            strSql.Append("MaxDistance=@in_MaxDistance,");
            strSql.Append("MinTurningRadius=@in_MinTurningRadius,");
            strSql.Append("PayLoad=@in_PayLoad,");
            strSql.Append("MaxLoad=@in_MaxLoad,");
            strSql.Append("Base_ID=@in_Base_ID,");

            strSql.Append(" where PLATFORM_ID=@in_PLATFORM_ID");

            SqlParameter[] cmdParms = new SqlParameter[] {
                new SqlParameter("@in_PLATFORM_ID", SqlDbType.Decimal),
                new SqlParameter("@in_PLATFORM_Name", SqlDbType.NVarChar),
                new SqlParameter("@in_NumberOfSensor", SqlDbType.Decimal),
                new SqlParameter("@in_CruisingVelocity", SqlDbType.Decimal),
                new SqlParameter("@in_RollVelocity", SqlDbType.Decimal),
                new SqlParameter("@in_PitchVelocity", SqlDbType.Decimal),
                new SqlParameter("@in_MaxVelocity", SqlDbType.Decimal),
                new SqlParameter("@in_MinVelocity", SqlDbType.Decimal),
                new SqlParameter("@in_Acceleration", SqlDbType.Decimal),
                new SqlParameter("@in_CruisingTime", SqlDbType.Decimal),

                new SqlParameter("@in_MaxSlewAngle", SqlDbType.Decimal),
                new SqlParameter("@in_MinSlewAngle", SqlDbType.Decimal),
                new SqlParameter("@in_CruisingAltitude", SqlDbType.Decimal),
                new SqlParameter("@in_MaxAltitude", SqlDbType.Decimal),
                new SqlParameter("@in_MaxDistance", SqlDbType.Decimal),
                new SqlParameter("@in_MinTurningRadius", SqlDbType.Decimal),
                new SqlParameter("@in_PayLoad", SqlDbType.Decimal),
                new SqlParameter("@in_MaxLoad", SqlDbType.Decimal),
                new SqlParameter("@in_Base_ID", SqlDbType.Decimal)
            };

            cmdParms[0].Value = model.PLATFORM_ID;
            cmdParms[1].Value = model.PLATFORM_Name;
            cmdParms[2].Value = model.NumberOfSensor;
            cmdParms[3].Value = model.CruisingVelocity;
            cmdParms[4].Value = model.RollVelocity;
            cmdParms[5].Value = model.PitchVelocity;
            cmdParms[6].Value = model.MaxVelocity;
            cmdParms[7].Value = model.MinVelocity;
            cmdParms[8].Value = model.Acceleration;
            cmdParms[9].Value = model.CruisingTime;

            cmdParms[10].Value = model.MaxSlewAngle;
            cmdParms[11].Value = model.MinSlewAngle;
            cmdParms[12].Value = model.CruisingAltitude;
            cmdParms[13].Value = model.MaxAltitude;
            cmdParms[14].Value = model.MaxDistance;
            cmdParms[15].Value = model.MinTurningRadius;
            cmdParms[16].Value = model.PayLoad;
            cmdParms[17].Value = model.MaxLoad;
            cmdParms[18].Value = model.Base_ID;
            return(DbHelperSQL.ExecuteSql(strSql.ToString(), cmdParms));
        }