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

            strSql.Append("update ScoreInfo set ");
            strSql.Append("UserID=@UserID,");
            strSql.Append("DateTime=@DateTime,");
            strSql.Append("ScoreDiff=@ScoreDiff,");
            strSql.Append("Note=@Note");
            strSql.Append(" where ID=@ID ");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@UserID",    DbType.String,    2147483647),
                new SQLiteParameter("@DateTime",  DbType.DateTime),
                new SQLiteParameter("@ScoreDiff", DbType.Int32,              8),
                new SQLiteParameter("@Note",      DbType.String,    2147483647),
                new SQLiteParameter("@ID",        DbType.String, 2147483647)
            };
            parameters[0].Value = model.UserID;
            parameters[1].Value = model.DateTime;
            parameters[2].Value = model.ScoreDiff;
            parameters[3].Value = model.Note;
            parameters[4].Value = model.ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public PartyConstruction.Model.DBScore DataRowToModel(DataRow row)
 {
     PartyConstruction.Model.DBScore model = new PartyConstruction.Model.DBScore();
     if (row != null)
     {
         if (row["ID"] != null)
         {
             model.ID = row["ID"].ToString();
         }
         if (row["UserID"] != null)
         {
             model.UserID = row["UserID"].ToString();
         }
         if (row["DateTime"] != null && row["DateTime"].ToString() != "")
         {
             model.DateTime = DateTime.Parse(row["DateTime"].ToString());
         }
         if (row["ScoreDiff"] != null && row["ScoreDiff"].ToString() != "")
         {
             model.ScoreDiff = int.Parse(row["ScoreDiff"].ToString());
         }
         if (row["Note"] != null)
         {
             model.Note = row["Note"].ToString();
         }
     }
     return(model);
 }
Esempio n. 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(PartyConstruction.Model.DBScore model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into ScoreInfo(");
            strSql.Append("ID,UserID,DateTime,ScoreDiff,Note)");
            strSql.Append(" values (");
            strSql.Append("@ID,@UserID,@DateTime,@ScoreDiff,@Note)");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@ID",        DbType.String,    2147483647),
                new SQLiteParameter("@UserID",    DbType.String,    2147483647),
                new SQLiteParameter("@DateTime",  DbType.DateTime),
                new SQLiteParameter("@ScoreDiff", DbType.Int32,              8),
                new SQLiteParameter("@Note",      DbType.String, 2147483647)
            };
            parameters[0].Value = model.ID;
            parameters[1].Value = model.UserID;
            parameters[2].Value = model.DateTime;
            parameters[3].Value = model.ScoreDiff;
            parameters[4].Value = model.Note;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public PartyConstruction.Model.DBScore GetModel(string ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select ID,UserID,DateTime,ScoreDiff,Note from ScoreInfo ");
            strSql.Append(" where ID=@ID ");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@ID", DbType.String, 2147483647)
            };
            parameters[0].Value = ID;

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

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