Beispiel #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(User_RoleModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update User_Role set ");
            strSql.Append("RoleName=@RoleName,");
            strSql.Append("Remarks=@Remarks");
            strSql.Append(" where RoleID=@RoleID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@RoleName", SqlDbType.NVarChar, 50),
                new SqlParameter("@Remarks",  SqlDbType.NVarChar, 50),
                new SqlParameter("@RoleID",   SqlDbType.Int, 4)
            };
            parameters[0].Value = model.RoleName;
            parameters[1].Value = model.Remarks;
            parameters[2].Value = model.RoleID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(User_RoleModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into User_Role(");
            strSql.Append("RoleName,Remarks)");
            strSql.Append(" values (");
            strSql.Append("@RoleName,@Remarks)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@RoleName", SqlDbType.NVarChar, 50),
                new SqlParameter("@Remarks",  SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = model.RoleName;
            parameters[1].Value = model.Remarks;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Beispiel #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public User_RoleModel DataRowToModel(DataRow row)
        {
            User_RoleModel model = new User_RoleModel();

            if (row != null)
            {
                if (row["RoleID"] != null && row["RoleID"].ToString() != "")
                {
                    model.RoleID = int.Parse(row["RoleID"].ToString());
                }
                if (row["RoleName"] != null)
                {
                    model.RoleName = row["RoleName"].ToString();
                }
                if (row["Remarks"] != null)
                {
                    model.Remarks = row["Remarks"].ToString();
                }
            }
            return(model);
        }
Beispiel #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public User_RoleModel GetModel(int RoleID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 RoleID,RoleName,Remarks from User_Role ");
            strSql.Append(" where RoleID=@RoleID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@RoleID", SqlDbType.Int, 4)
            };
            parameters[0].Value = RoleID;

            User_RoleModel model = new User_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);
            }
        }
Beispiel #5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(User_RoleModel model)
 {
     return(dal.Update(model));
 }
Beispiel #6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(User_RoleModel model)
 {
     return(dal.Add(model));
 }