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

            strSql.Append("update Pic set ");
            strSql.Append("ImageURL=@ImageURL,");
            strSql.Append("AID=@AID,");
            strSql.Append("Type=@Type,");
            strSql.Append("Number=@Number,");
            strSql.Append("Title=@Title,");
            strSql.Append("Summary=@Summary");
            strSql.Append(" where ID=@ID");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@ImageURL", DbType.String),
                new SQLiteParameter("@AID",      DbType.String),
                new SQLiteParameter("@Type",     DbType.String),
                new SQLiteParameter("@Number",   DbType.String),
                new SQLiteParameter("@Title",    DbType.String),
                new SQLiteParameter("@Summary",  DbType.String),
                new SQLiteParameter("@ID",       DbType.Int32, 8)
            };
            parameters[0].Value = model.ImageURL;
            parameters[1].Value = model.AID;
            parameters[2].Value = model.Type;
            parameters[3].Value = model.Number;
            parameters[4].Value = model.Title;
            parameters[5].Value = model.Summary;
            parameters[6].Value = model.ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Model.Pic DataRowToModel(DataRow row)
 {
     Model.Pic model = new Model.Pic();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = int.Parse(row["ID"].ToString());
         }
         if (row["ImageURL"] != null)
         {
             model.ImageURL = row["ImageURL"].ToString();
         }
         if (row["AID"] != null)
         {
             model.AID = row["AID"].ToString();
         }
         if (row["Type"] != null)
         {
             model.Type = row["Type"].ToString();
         }
         if (row["Number"] != null)
         {
             model.Number = row["Number"].ToString();
         }
         if (row["Title"] != null)
         {
             model.Title = row["Title"].ToString();
         }
         if (row["Summary"] != null)
         {
             model.Summary = row["Summary"].ToString();
         }
     }
     return(model);
 }
Exemplo n.º 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.Pic model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Pic(");
            strSql.Append("ImageURL,AID,Type,Number,Title,Summary)");
            strSql.Append(" values (");
            strSql.Append("@ImageURL,@AID,@Type,@Number,@Title,@Summary)");
            strSql.Append(";select LAST_INSERT_ROWID()");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@ImageURL", DbType.String),
                new SQLiteParameter("@AID",      DbType.String),
                new SQLiteParameter("@Type",     DbType.String),
                new SQLiteParameter("@Number",   DbType.String),
                new SQLiteParameter("@Title",    DbType.String),
                new SQLiteParameter("@Summary",  DbType.String)
            };
            parameters[0].Value = model.ImageURL;
            parameters[1].Value = model.AID;
            parameters[2].Value = model.Type;
            parameters[3].Value = model.Number;
            parameters[4].Value = model.Title;
            parameters[5].Value = model.Summary;

            object obj = DbHelperSQLite.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.Pic GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select ID,ImageURL,AID,Type,Number,Title,Summary from Pic ");
            strSql.Append(" where ID=@ID");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@ID", DbType.Int32, 4)
            };
            parameters[0].Value = ID;

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

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