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

            strSql.Append("update subjectType set ");
            strSql.Append("name=@name");
            strSql.Append(" where id=@id");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@name", DbType.String, 10),
                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);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(coodroid.Model.model.subjectType model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into subjectType(");
            strSql.Append("name)");
            strSql.Append(" values (");
            strSql.Append("@name)");
            strSql.Append(";select LAST_INSERT_ROWID()");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@name", DbType.String, 10)
            };
            parameters[0].Value = model.name;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Esempio n. 3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public coodroid.Model.model.subjectType DataRowToModel(DataRow row)
 {
     coodroid.Model.model.subjectType model = new coodroid.Model.model.subjectType();
     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);
 }
Esempio n. 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public coodroid.Model.model.subjectType GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

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

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

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