Exemplo n.º 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(StationTypeEntity model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Module_type set ");
            strSql.Append("Mp_ID_from_recall=@Mp_ID_from_recall,");
            strSql.Append("Mp_name=@Mp_name,");
            strSql.Append("Mp_manufacture=@Mp_manufacture,");
            strSql.Append("Mp_analog_input_number=@Mp_analog_input_number,");
            strSql.Append("Mp_switching_input_number=@Mp_switching_input_number,");
            strSql.Append("Mp_switching_output_number=@Mp_switching_output_number,");
            strSql.Append("Mp_Counter_number=@Mp_Counter_number");
            strSql.Append(" where Mp_ID=@Mp_ID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Mp_ID_from_recall",          SqlDbType.NVarChar, 50),
                new SqlParameter("@Mp_name",                    SqlDbType.NVarChar, 50),
                new SqlParameter("@Mp_manufacture",             SqlDbType.NVarChar, 50),
                new SqlParameter("@Mp_analog_input_number",     SqlDbType.Int,       4),
                new SqlParameter("@Mp_switching_input_number",  SqlDbType.Int,       4),
                new SqlParameter("@Mp_switching_output_number", SqlDbType.Int,       4),
                new SqlParameter("@Mp_Counter_number",          SqlDbType.Int,       4),
                new SqlParameter("@Mp_ID",                      SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = model.Mp_ID_from_recall;
            parameters[1].Value = model.Mp_name;
            parameters[2].Value = model.Mp_manufacture;
            parameters[3].Value = model.Mp_analog_input_number;
            parameters[4].Value = model.Mp_switching_input_number;
            parameters[5].Value = model.Mp_switching_output_number;
            parameters[6].Value = model.Mp_Counter_number;
            parameters[7].Value = model.Mp_ID;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        /* Methods */

        /// <summary>
        /// Creates an appropriate type for the specified entity.
        /// </summary>
        /// <param name="repository">
        /// The <see cref="IEveRepository" /> which contains the entity adapter.
        /// </param>
        /// <param name="entity">
        /// The data entity.
        /// </param>
        /// <returns>
        /// An <see cref="EveType" /> of the appropriate derived type, based on the
        /// contents of <paramref name="entity" />.
        /// </returns>
        public static EveType Create(IEveRepository repository, EveTypeEntity entity)
        {
            Contract.Requires(repository != null, "The repository associated with the object cannot be null.");
            Contract.Requires(entity != null, "The entity cannot be null.");
            Contract.Ensures(Contract.Result <EveType>() != null);

            // First, check for derived entity types.  These are entities that
            // have additional fields in ancillary tables.

            // BlueprintTypeEntities always map to StationType
            BlueprintTypeEntity blueprintTypeEntity = entity as BlueprintTypeEntity;

            if (blueprintTypeEntity != null)
            {
                return(new BlueprintType(repository, blueprintTypeEntity));
            }

            // StationTypeEntities always map to StationType
            StationTypeEntity stationTypeEntity = entity as StationTypeEntity;

            if (stationTypeEntity != null)
            {
                return(new StationType(repository, stationTypeEntity));
            }

            // For the remainder, the actual entity is the same type, and we need to
            // determine the EVE type based on its property values.

            // Use the item's group and category to determine the correct derived type
            Group group = repository.GetGroupById(entity.GroupId);

            switch (group.CategoryId)
            {
            // All items under category Skill map to SkillType
            case CategoryId.Skill:
                return(new SkillType(repository, entity));
            }

            // If we don't have a specific derived type for the provided entity,
            // fall back on a GenericType wrapper.
            return(new GenericType(repository, entity));
        }
Exemplo n.º 3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public StationTypeEntity DataRowToModel(DataRow row)
        {
            StationTypeEntity model = new StationTypeEntity();

            if (row != null)
            {
                if (row["Mp_ID"] != null)
                {
                    model.Mp_ID = row["Mp_ID"].ToString();
                }
                if (row["Mp_ID_from_recall"] != null)
                {
                    model.Mp_ID_from_recall = row["Mp_ID_from_recall"].ToString();
                }
                if (row["Mp_name"] != null)
                {
                    model.Mp_name = row["Mp_name"].ToString();
                }
                if (row["Mp_manufacture"] != null)
                {
                    model.Mp_manufacture = row["Mp_manufacture"].ToString();
                }
                if (row["Mp_analog_input_number"] != null && row["Mp_analog_input_number"].ToString() != "")
                {
                    model.Mp_analog_input_number = int.Parse(row["Mp_analog_input_number"].ToString());
                }
                if (row["Mp_switching_input_number"] != null && row["Mp_switching_input_number"].ToString() != "")
                {
                    model.Mp_switching_input_number = int.Parse(row["Mp_switching_input_number"].ToString());
                }
                if (row["Mp_switching_output_number"] != null && row["Mp_switching_output_number"].ToString() != "")
                {
                    model.Mp_switching_output_number = int.Parse(row["Mp_switching_output_number"].ToString());
                }
                if (row["Mp_Counter_number"] != null && row["Mp_Counter_number"].ToString() != "")
                {
                    model.Mp_Counter_number = int.Parse(row["Mp_Counter_number"].ToString());
                }
            }
            return(model);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public StationTypeEntity GetModel(string Mp_ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Mp_ID,Mp_ID_from_recall,Mp_name,Mp_manufacture,Mp_analog_input_number,Mp_switching_input_number,Mp_switching_output_number,Mp_Counter_number from Module_type ");
            strSql.Append(" where Mp_ID=@Mp_ID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Mp_ID", SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = Mp_ID;

            StationTypeEntity model = new StationTypeEntity();
            DataSet           ds    = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(StationTypeEntity model)
 {
     return(dal.Update(model));
 }
Exemplo n.º 6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(StationTypeEntity model)
 {
     return(dal.Add(model));
 }