예제 #1
0
파일: Article.cs 프로젝트: jzxyouok/YYHouse
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.Article model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Article set ");
            strSql.Append("Title=@Title,");
            strSql.Append("Detail=@Detail,");
            strSql.Append("Summary=@Summary,");
            strSql.Append("Author=@Author,");
            strSql.Append("SubmitTime=@SubmitTime,");
            strSql.Append("UpdateTime=@UpdateTime,");
            strSql.Append("Type=@Type,");
            strSql.Append("Click=@Click,");
            strSql.Append("Order=@Order");
            strSql.Append(" where ID=@ID");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@Title",      DbType.String),
                new SQLiteParameter("@Detail",     DbType.String),
                new SQLiteParameter("@Summary",    DbType.String),
                new SQLiteParameter("@Author",     DbType.String),
                new SQLiteParameter("@SubmitTime", DbType.String),
                new SQLiteParameter("@UpdateTime", DbType.String),
                new SQLiteParameter("@Type",       DbType.String),
                new SQLiteParameter("@Click",      DbType.String),
                new SQLiteParameter("@Order",      DbType.Int32,8),
                new SQLiteParameter("@ID",         DbType.Int32, 8)
            };
            parameters[0].Value = model.Title;
            parameters[1].Value = model.Detail;
            parameters[2].Value = model.Summary;
            parameters[3].Value = model.Author;
            parameters[4].Value = model.SubmitTime;
            parameters[5].Value = model.UpdateTime;
            parameters[6].Value = model.Type;
            parameters[7].Value = model.Click;
            parameters[8].Value = model.Order;
            parameters[9].Value = model.ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #2
0
파일: Article.cs 프로젝트: jzxyouok/YYHouse
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Model.Article DataRowToModel(DataRow row)
 {
     Model.Article model = new Model.Article();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = int.Parse(row["ID"].ToString());
         }
         if (row["Title"] != null)
         {
             model.Title = row["Title"].ToString();
         }
         if (row["Detail"] != null)
         {
             model.Detail = row["Detail"].ToString();
         }
         if (row["Summary"] != null)
         {
             model.Summary = row["Summary"].ToString();
         }
         if (row["Author"] != null)
         {
             model.Author = row["Author"].ToString();
         }
         if (row["SubmitTime"] != null)
         {
             model.SubmitTime = row["SubmitTime"].ToString();
         }
         if (row["UpdateTime"] != null)
         {
             model.UpdateTime = row["UpdateTime"].ToString();
         }
         if (row["Type"] != null)
         {
             model.Type = row["Type"].ToString();
         }
         if (row["Click"] != null)
         {
             model.Click = row["Click"].ToString();
         }
         if (row["Order"] != null && row["Order"].ToString() != "")
         {
             model.Order = int.Parse(row["Order"].ToString());
         }
     }
     return(model);
 }
예제 #3
0
파일: Article.cs 프로젝트: jzxyouok/YYHouse
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.Article model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Article(");
            strSql.Append("Title,Detail,Summary,Author,SubmitTime,UpdateTime,Type,Click,Order)");
            strSql.Append(" values (");
            strSql.Append("@Title,@Detail,@Summary,@Author,@SubmitTime,@UpdateTime,@Type,@Click,@Order)");
            strSql.Append(";select LAST_INSERT_ROWID()");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@Title",      DbType.String),
                new SQLiteParameter("@Detail",     DbType.String),
                new SQLiteParameter("@Summary",    DbType.String),
                new SQLiteParameter("@Author",     DbType.String),
                new SQLiteParameter("@SubmitTime", DbType.String),
                new SQLiteParameter("@UpdateTime", DbType.String),
                new SQLiteParameter("@Type",       DbType.String),
                new SQLiteParameter("@Click",      DbType.String),
                new SQLiteParameter("@Order",      DbType.Int32, 8)
            };
            parameters[0].Value = model.Title;
            parameters[1].Value = model.Detail;
            parameters[2].Value = model.Summary;
            parameters[3].Value = model.Author;
            parameters[4].Value = model.SubmitTime;
            parameters[5].Value = model.UpdateTime;
            parameters[6].Value = model.Type;
            parameters[7].Value = model.Click;
            parameters[8].Value = model.Order;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
예제 #4
0
파일: Article.cs 프로젝트: jzxyouok/YYHouse
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.Article GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select * from Article ");
            strSql.Append(" where ID=@ID");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@ID", DbType.Int32, 4)
            };
            parameters[0].Value = ID;

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

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