예제 #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(Garfield.Model.Sys_authority model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Sys_authority(");
            strSql.Append("Role_id,App_ids,Menu_ids,Button_ids,Create_id,Create_date)");
            strSql.Append(" values (");
            strSql.Append("@Role_id,@App_ids,@Menu_ids,@Button_ids,@Create_id,@Create_date)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Role_id",     SqlDbType.Int,       4),
                new SqlParameter("@App_ids",     SqlDbType.VarChar, 250),
                new SqlParameter("@Menu_ids",    SqlDbType.VarChar,  -1),
                new SqlParameter("@Button_ids",  SqlDbType.VarChar,  -1),
                new SqlParameter("@Create_id",   SqlDbType.Int,       4),
                new SqlParameter("@Create_date", SqlDbType.DateTime)
            };
            parameters[0].Value = model.Role_id;
            parameters[1].Value = model.App_ids;
            parameters[2].Value = model.Menu_ids;
            parameters[3].Value = model.Button_ids;
            parameters[4].Value = model.Create_id;
            parameters[5].Value = model.Create_date;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
예제 #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Garfield.Model.Sys_authority GetModel()
        {
            //该表无主键信息,请自定义主键/条件字段
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Role_id,App_ids,Menu_ids,Button_ids,Create_id,Create_date from Sys_authority ");
            strSql.Append(" where ");
            SqlParameter[] parameters =
            {
            };

            Garfield.Model.Sys_authority model = new Garfield.Model.Sys_authority();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Role_id"] != null && ds.Tables[0].Rows[0]["Role_id"].ToString() != "")
                {
                    model.Role_id = int.Parse(ds.Tables[0].Rows[0]["Role_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["App_ids"] != null && ds.Tables[0].Rows[0]["App_ids"].ToString() != "")
                {
                    model.App_ids = ds.Tables[0].Rows[0]["App_ids"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Menu_ids"] != null && ds.Tables[0].Rows[0]["Menu_ids"].ToString() != "")
                {
                    model.Menu_ids = ds.Tables[0].Rows[0]["Menu_ids"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Button_ids"] != null && ds.Tables[0].Rows[0]["Button_ids"].ToString() != "")
                {
                    model.Button_ids = ds.Tables[0].Rows[0]["Button_ids"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Create_id"] != null && ds.Tables[0].Rows[0]["Create_id"].ToString() != "")
                {
                    model.Create_id = int.Parse(ds.Tables[0].Rows[0]["Create_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Create_date"] != null && ds.Tables[0].Rows[0]["Create_date"].ToString() != "")
                {
                    model.Create_date = DateTime.Parse(ds.Tables[0].Rows[0]["Create_date"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
예제 #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Garfield.Model.Sys_authority model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Sys_authority set ");
            strSql.Append("Role_id=@Role_id,");
            strSql.Append("App_ids=@App_ids,");
            strSql.Append("Menu_ids=@Menu_ids,");
            strSql.Append("Button_ids=@Button_ids,");
            strSql.Append("Create_id=@Create_id,");
            strSql.Append("Create_date=@Create_date");
            strSql.Append(" where ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Role_id",     SqlDbType.Int,       4),
                new SqlParameter("@App_ids",     SqlDbType.VarChar, 250),
                new SqlParameter("@Menu_ids",    SqlDbType.VarChar,  -1),
                new SqlParameter("@Button_ids",  SqlDbType.VarChar,  -1),
                new SqlParameter("@Create_id",   SqlDbType.Int,       4),
                new SqlParameter("@Create_date", SqlDbType.DateTime)
            };
            parameters[0].Value = model.Role_id;
            parameters[1].Value = model.App_ids;
            parameters[2].Value = model.Menu_ids;
            parameters[3].Value = model.Button_ids;
            parameters[4].Value = model.Create_id;
            parameters[5].Value = model.Create_date;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }