예제 #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(RF.Model.sys_button model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update sys_button set ");
            strSql.Append("b_title=@b_title,");
            strSql.Append("b_id=@b_id,");
            strSql.Append("b_class=@b_class,");
            strSql.Append("b_icon=@b_icon,");
            strSql.Append("b_pid=@b_pid,");
            strSql.Append("b_state=@b_state,");
            strSql.Append("b_order=@b_order,");
            strSql.Append("b_remark=@b_remark");
            strSql.Append(" where id=@id");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@b_title",  DbType.String, 20),
                new SQLiteParameter("@b_id",     DbType.String, 40),
                new SQLiteParameter("@b_class",  DbType.String, 40),
                new SQLiteParameter("@b_icon",   DbType.String, 40),
                new SQLiteParameter("@b_pid",    DbType.Int32,   8),
                new SQLiteParameter("@b_state",  DbType.Int32,   4),
                new SQLiteParameter("@b_order",  DbType.Int32,   4),
                new SQLiteParameter("@b_remark", DbType.String, 40),
                new SQLiteParameter("@id",       DbType.Int32, 8)
            };
            parameters[0].Value = model.b_title;
            parameters[1].Value = model.b_id;
            parameters[2].Value = model.b_class;
            parameters[3].Value = model.b_icon;
            parameters[4].Value = model.b_pid;
            parameters[5].Value = model.b_state;
            parameters[6].Value = model.b_order;
            parameters[7].Value = model.b_remark;
            parameters[8].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public RF.Model.sys_button DataRowToModel(DataRow row)
 {
     RF.Model.sys_button model = new RF.Model.sys_button();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["b_title"] != null)
         {
             model.b_title = row["b_title"].ToString();
         }
         if (row["b_id"] != null)
         {
             model.b_id = row["b_id"].ToString();
         }
         if (row["b_class"] != null)
         {
             model.b_class = row["b_class"].ToString();
         }
         if (row["b_icon"] != null)
         {
             model.b_icon = row["b_icon"].ToString();
         }
         if (row["b_pid"] != null && row["b_pid"].ToString() != "")
         {
             model.b_pid = int.Parse(row["b_pid"].ToString());
         }
         if (row["b_state"] != null && row["b_state"].ToString() != "")
         {
             model.b_state = int.Parse(row["b_state"].ToString());
         }
         if (row["b_order"] != null && row["b_order"].ToString() != "")
         {
             model.b_order = int.Parse(row["b_order"].ToString());
         }
         if (row["b_remark"] != null)
         {
             model.b_remark = row["b_remark"].ToString();
         }
     }
     return(model);
 }
예제 #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(RF.Model.sys_button model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into sys_button(");
            strSql.Append("b_title,b_id,b_class,b_icon,b_pid,b_state,b_order,b_remark)");
            strSql.Append(" values (");
            strSql.Append("@b_title,@b_id,@b_class,@b_icon,@b_pid,@b_state,@b_order,@b_remark)");
            strSql.Append(";select LAST_INSERT_ROWID()");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@b_title",  DbType.String, 20),
                new SQLiteParameter("@b_id",     DbType.String, 40),
                new SQLiteParameter("@b_class",  DbType.String, 40),
                new SQLiteParameter("@b_icon",   DbType.String, 40),
                new SQLiteParameter("@b_pid",    DbType.Int32,   8),
                new SQLiteParameter("@b_state",  DbType.Int32,   4),
                new SQLiteParameter("@b_order",  DbType.Int32,   4),
                new SQLiteParameter("@b_remark", DbType.String, 40)
            };
            parameters[0].Value = model.b_title;
            parameters[1].Value = model.b_id;
            parameters[2].Value = model.b_class;
            parameters[3].Value = model.b_icon;
            parameters[4].Value = model.b_pid;
            parameters[5].Value = model.b_state;
            parameters[6].Value = model.b_order;
            parameters[7].Value = model.b_remark;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
예제 #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public RF.Model.sys_button GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id,b_title,b_id,b_class,b_icon,b_pid,b_state,b_order,b_remark from sys_button ");
            strSql.Append(" where id=@id");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@id", DbType.Int32, 4)
            };
            parameters[0].Value = id;

            RF.Model.sys_button model = new RF.Model.sys_button();
            DataSet             ds    = DB.HelperSQLite.Query(strSql.ToString(), parameters);

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