示例#1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Material.Model.level1 model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update level1 set ");
            strSql.Append("name=@name");
            strSql.Append(" where id=@id ");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@name", DbType.String, 2147483647),
                new SQLiteParameter("@id",   DbType.Int32, 8)
            };
            parameters[0].Value = model.name;
            parameters[1].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Material.Model.level1 model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into level1(");
            strSql.Append("id,name)");
            strSql.Append(" values (");
            strSql.Append("@id,@name)");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@id",   DbType.Int32,  8),
                new SQLiteParameter("@name", DbType.String, 2147483647)
            };
            parameters[0].Value = model.id;
            parameters[1].Value = model.name;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Material.Model.level1 model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into level1(");
            strSql.Append("id,name)");
            strSql.Append(" values (");
            strSql.Append("@id,@name)");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@id",   DbType.Int32, 8),
                new SQLiteParameter("@name", DbType.char, 2147483647)
            };
示例#4
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Material.Model.level1 DataRowToModel(DataRow row)
 {
     Material.Model.level1 model = new Material.Model.level1();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["name"] != null)
         {
             model.name = row["name"].ToString();
         }
     }
     return(model);
 }
示例#5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Material.Model.level1 GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id,name from level1 ");
            strSql.Append(" where id=@id ");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@id", DbType.Int32, 8)
            };
            parameters[0].Value = id;

            Material.Model.level1 model = new Material.Model.level1();
            DataSet ds = DbHelperSQLite.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }