コード例 #1
0
        public Core.Business.RoleOperation Select(RoleOperationKey id)
        {
            SqlServerUtility sql = new SqlServerUtility();

            sql.AddParameter("@OperationId", SqlDbType.Int, id.OperationId);
            sql.AddParameter("@RoleId", SqlDbType.Int, id.RoleId);
            SqlDataReader reader = sql.ExecuteSqlReader(SqlSelectRoleOperation);

            if (reader != null && !reader.IsClosed && reader.Read())
            {
                Core.Business.RoleOperation roleOperation = new Core.Business.RoleOperation();

                roleOperation.Id = new Core.Business.RoleOperationKey();
                if (!reader.IsDBNull(0)) roleOperation.Id.OperationId = reader.GetInt32(0);
                if (!reader.IsDBNull(1)) roleOperation.Id.RoleId = reader.GetInt32(1);
                if (!reader.IsDBNull(2)) roleOperation.Status = reader.GetInt32(2);
                if (!reader.IsDBNull(3)) roleOperation.AddDate = reader.GetDateTime(3);

                reader.Close();
                return roleOperation;
            }
            else
            {
                if (reader != null && !reader.IsClosed)
                    reader.Close();

                return null;
            }
        }
コード例 #2
0
        public IList<Core.Business.RoleOperation> GetAllRoleOperation()
        {
            IList<Core.Business.RoleOperation> roleOperationlist = new List<Core.Business.RoleOperation>();
            SqlServerUtility sql = new SqlServerUtility();

            SqlDataReader reader = sql.ExecuteSqlReader(SqlGetAllRoleOperation);

            if(reader != null)
            {
                while(reader.Read())
                {
                    Core.Business.RoleOperation roleOperation = new Core.Business.RoleOperation();

                    roleOperation.Id = new Core.Business.RoleOperationKey();
                    if (!reader.IsDBNull(0)) roleOperation.Id.OperationId = reader.GetInt32(0);
                    if (!reader.IsDBNull(1)) roleOperation.Id.RoleId = reader.GetInt32(1);
                    if (!reader.IsDBNull(2)) roleOperation.Status = reader.GetInt32(2);
                    if (!reader.IsDBNull(3)) roleOperation.AddDate = reader.GetDateTime(3);

                    roleOperation.MarkOld();
                    roleOperationlist.Add(roleOperation);
                }
                reader.Close();
            }
            return roleOperationlist;
        }