Exemple #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(XCLShouCang.Model.RoleInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update RoleInfo set ");
            strSql.Append("ParentRoleInfoID=@ParentRoleInfoID,");
            strSql.Append("RoleName=@RoleName");
            strSql.Append(" where RoleInfoID=@RoleInfoID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ParentRoleInfoID", SqlDbType.BigInt,    8),
                new SqlParameter("@RoleName",         SqlDbType.VarChar, 100),
                new SqlParameter("@RoleInfoID",       SqlDbType.BigInt, 8)
            };
            parameters[0].Value = model.ParentRoleInfoID;
            parameters[1].Value = model.RoleName;
            parameters[2].Value = model.RoleInfoID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public long Add(XCLShouCang.Model.RoleInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into RoleInfo(");
            strSql.Append("ParentRoleInfoID,RoleName)");
            strSql.Append(" values (");
            strSql.Append("@ParentRoleInfoID,@RoleName)");
            strSql.Append(";select SCOPE_IDENTITY()");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ParentRoleInfoID", SqlDbType.BigInt,  8),
                new SqlParameter("@RoleName",         SqlDbType.VarChar, 100)
            };
            parameters[0].Value = model.ParentRoleInfoID;
            parameters[1].Value = model.RoleName;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt64(obj));
            }
        }
Exemple #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public XCLShouCang.Model.RoleInfo DataRowToModel(DataRow row)
 {
     XCLShouCang.Model.RoleInfo model = new XCLShouCang.Model.RoleInfo();
     if (row != null)
     {
         if (row["RoleInfoID"] != null && row["RoleInfoID"].ToString() != "")
         {
             model.RoleInfoID = long.Parse(row["RoleInfoID"].ToString());
         }
         if (row["ParentRoleInfoID"] != null && row["ParentRoleInfoID"].ToString() != "")
         {
             model.ParentRoleInfoID = long.Parse(row["ParentRoleInfoID"].ToString());
         }
         if (row["RoleName"] != null)
         {
             model.RoleName = row["RoleName"].ToString();
         }
     }
     return(model);
 }
Exemple #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public XCLShouCang.Model.RoleInfo GetModel(long RoleInfoID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 RoleInfoID,ParentRoleInfoID,RoleName from RoleInfo ");
            strSql.Append(" where RoleInfoID=@RoleInfoID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@RoleInfoID", SqlDbType.BigInt)
            };
            parameters[0].Value = RoleInfoID;

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

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