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

            strSql.Append("update Role set ");
            strSql.Append("RolseName=@RolseName,");
            strSql.Append("Url=@Url");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@RolseName", SqlDbType.VarChar,  50),
                new SqlParameter("@Url",       SqlDbType.VarChar, 200),
                new SqlParameter("@id",        SqlDbType.Int, 4)
            };
            parameters[0].Value = model.RoleName;
            parameters[1].Value = model.Url;
            parameters[2].Value = model.Id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.RoleModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Role(");
            strSql.Append("RolseName,Url)");
            strSql.Append(" values (");
            strSql.Append("@RolseName,@Url)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@RolseName", SqlDbType.VarChar, 50),
                new SqlParameter("@Url",       SqlDbType.VarChar, 200)
            };
            parameters[0].Value = model.RoleName;
            parameters[1].Value = model.Url;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Model.RoleModel DataRowToModel(DataRow row)
 {
     Model.RoleModel model = new Model.RoleModel();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.Id = int.Parse(row["id"].ToString());
         }
         if (row["RolseName"] != null)
         {
             model.RoleName = row["RolseName"].ToString();
         }
         if (row["Url"] != null)
         {
             model.Url = row["Url"].ToString();
         }
     }
     return(model);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.RoleModel GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,RolseName,Url from Role ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 5
0
 public bool Add(Model.RoleModel RoleModel)
 {
     return(false);
 }